enonic-wizardry
Advanced tools
Comparing version 0.0.8 to 0.1.0
@@ -42,2 +42,3 @@ "use strict"; | ||
"src/main/resources/site/site.xml", | ||
"src/main/resources/idprovider/idprovider.xml", | ||
"src/main/resources/site/content-types", | ||
@@ -44,0 +45,0 @@ "src/main/resources/site/parts", |
@@ -1,3 +0,3 @@ | ||
import { Error } from "enonic-fp/lib/common"; | ||
import { Either } from "fp-ts/lib/Either"; | ||
import { EnonicError } from "enonic-fp/lib/common"; | ||
import { IOEither } from "fp-ts/lib/IOEither"; | ||
import { Content, ModifyContentParams, CreateContentParams, DeleteContentParams } from "enonic-fp/lib/content"; | ||
@@ -7,8 +7,8 @@ export interface WithId { | ||
} | ||
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 publishFromDraftToMaster<A>(content: Content<A>): IOEither<EnonicError, Content<A>>; | ||
export declare function publishContentByKey<A>(key: string): (a: A) => IOEither<EnonicError, 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, void>; | ||
export declare function modifyAndPublish<A>(key: string, changes: any): Either<Error, Content<A>>; | ||
export declare function createAndPublish<A>(params: CreateContentParams<A>): IOEither<EnonicError, Content<A>>; | ||
export declare function deleteAndPublish(params: DeleteContentParams): IOEither<EnonicError, void>; | ||
export declare function modifyAndPublish<A>(key: string, changes: any): IOEither<EnonicError, Content<A>>; | ||
export declare function getContentDataWithId<T>(content: Content<T>): T & WithId; |
@@ -14,3 +14,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Either_1 = require("fp-ts/lib/Either"); | ||
var IOEither_1 = require("fp-ts/lib/IOEither"); | ||
var pipeable_1 = require("fp-ts/lib/pipeable"); | ||
@@ -24,3 +24,3 @@ var content_1 = require("enonic-fp/lib/content"); | ||
targetBranch: 'master', | ||
}), Either_1.map(function () { return content; })); | ||
}), IOEither_1.map(function () { return content; })); | ||
} | ||
@@ -34,3 +34,3 @@ exports.publishFromDraftToMaster = publishFromDraftToMaster; | ||
targetBranch: 'master', | ||
}), Either_1.map(function () { return a; })); | ||
}), IOEither_1.map(function () { return a; })); | ||
}; | ||
@@ -51,11 +51,11 @@ } | ||
function createAndPublish(params) { | ||
return pipeable_1.pipe(context_1.runInDraftContext(content_1.create)(params), Either_1.chain(publishFromDraftToMaster)); | ||
return pipeable_1.pipe(context_1.runInDraftContext(content_1.create)(params), IOEither_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))); | ||
return pipeable_1.pipe(context_1.runInDraftContext(content_1.remove)(params), IOEither_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)); | ||
return pipeable_1.pipe(context_1.runInDraftContext(content_1.modify)(applyChangesToData(key, changes)), IOEither_1.chain(publishFromDraftToMaster)); | ||
} | ||
@@ -62,0 +62,0 @@ exports.modifyAndPublish = modifyAndPublish; |
@@ -1,18 +0,19 @@ | ||
import { Error, ErrorKey, Response } from "enonic-fp/lib/common"; | ||
import { EnonicError, EnonicErrorKey, Response } from "enonic-fp/lib/common"; | ||
import { IO } from "fp-ts/lib/IO"; | ||
export declare const defaultStatusNumbers: { | ||
[key in ErrorKey]: number; | ||
[key in EnonicErrorKey]: number; | ||
}; | ||
export declare function status(status: number, body?: string | object): Response; | ||
export declare function errorResponse(i18nPrefix: string, debug?: boolean): (err: Error) => Response; | ||
export declare const ok: (body: any) => Response; | ||
export declare const created: (body: any) => Response; | ||
export declare const noContent: () => Response; | ||
export declare const redirect: (redirect: string) => Response; | ||
export declare const badRequest: (body: any) => Response; | ||
export declare const unauthorized: (body: any) => Response; | ||
export declare const forbidden: (body: any) => Response; | ||
export declare const notFound: (body: any) => Response; | ||
export declare const methodNotAllowed: (body: any) => Response; | ||
export declare const internalServerError: (body: any) => Response; | ||
export declare const badGateway: (body: any) => Response; | ||
export declare function setTotal(total: number, response: Response): Response; | ||
export declare function status(status: number, body?: string | object): IO<Response>; | ||
export declare function errorResponse(i18nPrefix: string, debug?: boolean): (err: EnonicError) => IO<Response>; | ||
export declare const ok: (body: any) => IO<Response>; | ||
export declare const created: (body: any) => IO<Response>; | ||
export declare const noContent: () => IO<Response>; | ||
export declare const redirect: (redirect: string) => IO<Response>; | ||
export declare const badRequest: (body: any) => IO<Response>; | ||
export declare const unauthorized: (body: any) => IO<Response>; | ||
export declare const forbidden: (body: any) => IO<Response>; | ||
export declare const notFound: (body: any) => IO<Response>; | ||
export declare const methodNotAllowed: (body: any) => IO<Response>; | ||
export declare const internalServerError: (body: any) => IO<Response>; | ||
export declare const badGateway: (body: any) => IO<Response>; | ||
export declare function setTotal(total: number, response: IO<Response>): IO<Response>; |
@@ -5,2 +5,3 @@ "use strict"; | ||
var Option_1 = require("fp-ts/lib/Option"); | ||
var IO_1 = require("fp-ts/lib/IO"); | ||
exports.defaultStatusNumbers = { | ||
@@ -22,7 +23,7 @@ "BadRequestError": 400, | ||
function status(status, body) { | ||
return { | ||
return IO_1.io.of({ | ||
status: status, | ||
body: body, | ||
contentType: contentType(body) | ||
}; | ||
}); | ||
} | ||
@@ -43,4 +44,4 @@ exports.status = status; | ||
exports.created = function (body) { return status(201, body); }; | ||
exports.noContent = function () { return ({ status: 204, body: '' }); }; | ||
exports.redirect = function (redirect) { return ({ status: 303, redirect: redirect }); }; | ||
exports.noContent = function () { return IO_1.io.of({ status: 204, body: '' }); }; | ||
exports.redirect = function (redirect) { return IO_1.io.of({ status: 303, redirect: redirect }); }; | ||
exports.badRequest = function (body) { return status(400, body); }; | ||
@@ -54,7 +55,9 @@ exports.unauthorized = function (body) { return status(401, body); }; | ||
function setTotal(total, response) { | ||
response.headers = { | ||
'X-Total-Count': String(total) | ||
}; | ||
return response; | ||
return IO_1.map(function (res) { | ||
res.headers = { | ||
'X-Total-Count': String(total) | ||
}; | ||
return res; | ||
})(response); | ||
} | ||
exports.setTotal = setTotal; |
import * as E from 'fp-ts/lib/Either'; | ||
import { Option } from 'fp-ts/lib/Option'; | ||
import { Request, Error } from "enonic-fp/lib/common"; | ||
export declare function json(req: Request): E.Either<Error, any>; | ||
import { Request, EnonicError } from "enonic-fp/lib/common"; | ||
export declare function json(req: Request): E.Either<EnonicError, any>; | ||
export declare function getUuidFromPath(path: string): Option<string>; | ||
export declare function forceArray(data: any): any[]; | ||
export declare function uuidv4(): string; |
{ | ||
"name": "enonic-wizardry", | ||
"version": "0.0.8", | ||
"version": "0.1.0", | ||
"description": "Functional utility library for Enonic XP", | ||
"main": "lib/index.js", | ||
"module": "es6/index.js", | ||
"typings": "lib/index.d.ts", | ||
"scripts": { | ||
"clean": "rimraf lib/* es6/* bin/*", | ||
"build": "npm run clean && tsc && tsc -p tsconfig.es6.json && npm run build:cli", | ||
"clean": "rimraf lib/* bin/*", | ||
"build": "npm run clean && tsc && npm run build:cli", | ||
"build:cli": "tsc -p tsconfig.cli.json", | ||
@@ -32,3 +31,3 @@ "test": "jest", | ||
"commander": "^3.0.1", | ||
"enonic-fp": "^0.0.16", | ||
"enonic-fp": "^0.1.0-RC1", | ||
"fp-ts": "^2.0.5", | ||
@@ -41,8 +40,8 @@ "xmldom": "^0.1.27", | ||
"@types/jest": "^24.0.18", | ||
"@types/node": "^12.7.4", | ||
"@types/node": "^12.7.7", | ||
"jest": "^24.9.0", | ||
"rimraf": "^3.0.0", | ||
"ts-jest": "^24.0.2", | ||
"typescript": "^3.6.2" | ||
"ts-jest": "^24.1.0", | ||
"typescript": "^3.6.3" | ||
} | ||
} |
27431
19
603
+ Addedenonic-fp@0.1.8(transitive)
- Removedenonic-fp@0.0.16(transitive)
Updatedenonic-fp@^0.1.0-RC1