enonic-wizardry
Advanced tools
Comparing version 0.2.31 to 0.2.32
@@ -30,4 +30,9 @@ import { EnonicError } from "enonic-fp/lib/errors"; | ||
export declare function deleteAndPublish(params: DeleteContentParams): IOEither<EnonicError, void>; | ||
export declare function modifyAndPublish<A extends object>(key: string, changes: Partial<A>): IOEither<EnonicError, Content<A>>; | ||
export declare function modifyAndPublish<A extends object>(a: WithId<A>): IOEither<EnonicError, Content<A>>; | ||
export declare function modifyAndPublish<A extends object>(a: Partial<A>, key: string): IOEither<EnonicError, Content<A>>; | ||
export declare function isDataWithId<A>(data: any): data is WithId<A>; | ||
export declare function getContentDataWithId<A extends object>(content: Content<A>): WithId<A>; | ||
export declare function splitDataWithId<A extends object>(a: A & { | ||
_id: string; | ||
}): [string, A]; | ||
export declare function createMediaFromAttachment<A extends object>(params: CreateMediaFromAttachmentParams): IOEither<EnonicError, Content<A>>; |
@@ -13,2 +13,13 @@ "use strict"; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -21,2 +32,3 @@ var IOEither_1 = require("fp-ts/lib/IOEither"); | ||
var Apply_1 = require("fp-ts/lib/Apply"); | ||
var function_1 = require("fp-ts/lib/function"); | ||
function publishFromDraftToMaster(content) { | ||
@@ -56,6 +68,13 @@ return pipeable_1.pipe(content_1.publish({ | ||
exports.deleteAndPublish = deleteAndPublish; | ||
function modifyAndPublish(key, changes) { | ||
return pipeable_1.pipe(context_1.runInDraftContext(content_1.modify(applyChangesToData(key, changes))), IOEither_1.chain(publishFromDraftToMaster)); | ||
function modifyAndPublish(a, key) { | ||
var doModify = isDataWithId(a) | ||
? content_1.modify(function_1.tupled(applyChangesToData)(splitDataWithId(a))) | ||
: content_1.modify(applyChangesToData(key !== null && key !== void 0 ? key : '', a)); | ||
return pipeable_1.pipe(context_1.runInDraftContext(doModify), IOEither_1.chain(publishFromDraftToMaster)); | ||
} | ||
exports.modifyAndPublish = modifyAndPublish; | ||
function isDataWithId(data) { | ||
return (data === null || data === void 0 ? void 0 : data._id) !== undefined; | ||
} | ||
exports.isDataWithId = isDataWithId; | ||
function getContentDataWithId(content) { | ||
@@ -65,2 +84,7 @@ return __assign(__assign({}, content.data), { _id: content._id }); | ||
exports.getContentDataWithId = getContentDataWithId; | ||
function splitDataWithId(a) { | ||
var _id = a._id, data = __rest(a, ["_id"]); | ||
return [_id, data]; | ||
} | ||
exports.splitDataWithId = splitDataWithId; | ||
function createMediaFromAttachment(params) { | ||
@@ -67,0 +91,0 @@ return pipeable_1.pipe(Apply_1.sequenceS(IOEither_1.ioEither)({ |
{ | ||
"name": "enonic-wizardry", | ||
"version": "0.2.31", | ||
"version": "0.2.32", | ||
"description": "Functional utility library for Enonic XP", | ||
@@ -34,8 +34,8 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^2.21.0", | ||
"@typescript-eslint/parser": "^2.21.0", | ||
"@typescript-eslint/eslint-plugin": "^2.22.0", | ||
"@typescript-eslint/parser": "^2.22.0", | ||
"eslint": "^6.8.0", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^3.8.2" | ||
"typescript": "^3.8.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24791
448