enonic-wizardry
Advanced tools
Comparing version 0.2.37 to 0.2.38
@@ -6,2 +6,4 @@ import { EnonicError } from "enonic-fp/lib/errors"; | ||
import { IO } from "fp-ts/lib/IO"; | ||
export declare function getContentByIds<A extends object>(ids: Array<string>): IOEither<EnonicError, ReadonlyArray<Content<A>>>; | ||
export declare function getContentByIds<A extends object>(ids: Array<string | undefined>): IOEither<EnonicError, ReadonlyArray<Content<A> | undefined>>; | ||
export interface CreateMediaFromAttachmentParams { | ||
@@ -8,0 +10,0 @@ /** |
@@ -14,3 +14,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createMediaFromAttachment = exports.modifyAndPublish = exports.deleteAndPublish = exports.createAndPublish = exports.createAll = exports.applyChangesToData = exports.publishContentByKey = exports.publishFromDraftToMaster = void 0; | ||
exports.createMediaFromAttachment = exports.modifyAndPublish = exports.deleteAndPublish = exports.createAndPublish = exports.createAll = exports.applyChangesToData = exports.publishContentByKey = exports.publishFromDraftToMaster = exports.getContentByIds = void 0; | ||
var IOEither_1 = require("fp-ts/lib/IOEither"); | ||
@@ -25,2 +25,29 @@ var pipeable_1 = require("fp-ts/lib/pipeable"); | ||
var IO_1 = require("fp-ts/lib/IO"); | ||
function getContentByIds(ids) { | ||
return (ids.length > 0) | ||
? pipeable_1.pipe(content_1.query({ | ||
count: ids.length, | ||
query: "_id IN (" + idsAsString(ids) + ")" | ||
}), IOEither_1.map(function (result) { return sortResultByIdOrder(result.hits, ids); })) | ||
: IOEither_1.right([]); | ||
} | ||
exports.getContentByIds = getContentByIds; | ||
function idsAsString(ids) { | ||
return ids | ||
.filter(notEmptyOrUndefined) | ||
.map(function (id) { return "\"" + id + "\""; }) | ||
.join(','); | ||
} | ||
function sortResultByIdOrder(hits, ids) { | ||
return hits.reduce(function (result, content) { | ||
var originalIndex = ids.indexOf(content._id); | ||
result[originalIndex] = content; | ||
return result; | ||
}, []); | ||
} | ||
function notEmptyOrUndefined(str) { | ||
return (str !== undefined) | ||
&& (str !== null) | ||
&& (str.length > 0); | ||
} | ||
function publishFromDraftToMaster(content) { | ||
@@ -27,0 +54,0 @@ return pipeable_1.pipe(content_1.publish({ |
{ | ||
"name": "enonic-wizardry", | ||
"version": "0.2.37", | ||
"version": "0.2.38", | ||
"description": "Functional utility library for Enonic XP", | ||
@@ -10,3 +10,3 @@ "main": "lib/index.js", | ||
"build": "npm run clean && tsc", | ||
"lint": "eslint --fix 'src/**/*.ts'", | ||
"lint": "eslint --fix --ext .ts .", | ||
"prepublishOnly": "npm run lint && npm run build" | ||
@@ -29,4 +29,4 @@ }, | ||
"dependencies": { | ||
"enonic-fp": "^0.2.45", | ||
"enonic-types": "^0.0.67", | ||
"enonic-fp": "^0.2.46", | ||
"enonic-types": "^0.0.68", | ||
"fp-ts": "2.6.1", | ||
@@ -36,5 +36,5 @@ "io-ts": "^2.2.4" | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^3.3.0", | ||
"@typescript-eslint/parser": "^3.3.0", | ||
"eslint": "^7.2.0", | ||
"@typescript-eslint/eslint-plugin": "^3.4.0", | ||
"@typescript-eslint/parser": "^3.4.0", | ||
"eslint": "^7.3.1", | ||
"rimraf": "^3.0.2", | ||
@@ -41,0 +41,0 @@ "typescript": "^3.9.5" |
Sorry, the diff of this file is not supported yet
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
23934
406
+ Addedenonic-types@0.0.68(transitive)
- Removedenonic-types@0.0.67(transitive)
Updatedenonic-fp@^0.2.46
Updatedenonic-types@^0.0.68