Comparing version 0.1.8 to 0.2.0
import { IOEither } from "fp-ts/lib/IOEither"; | ||
import { EnonicError } from "./common"; | ||
export interface Content<A> { | ||
readonly _id: string; | ||
readonly _name: string; | ||
readonly _path: string; | ||
readonly creator: string; | ||
readonly modifier: string; | ||
readonly createdTime: string; | ||
readonly modifiedTime: string; | ||
readonly owner: string; | ||
readonly type: string; | ||
readonly displayName: string; | ||
readonly hasChildren: boolean; | ||
readonly language: string; | ||
readonly valid: boolean; | ||
readonly childOrder: string; | ||
readonly data: A; | ||
readonly x: { | ||
readonly [key: string]: string; | ||
}; | ||
readonly page: any; | ||
readonly attachments: Attachments; | ||
readonly publish: any; | ||
} | ||
export interface Attachment { | ||
readonly name: string; | ||
readonly label?: string; | ||
readonly size: number; | ||
readonly mimeType: string; | ||
} | ||
export interface Attachments { | ||
readonly [key: string]: Attachment; | ||
} | ||
export interface QueryContentParams { | ||
readonly start?: number; | ||
readonly count: number; | ||
readonly query: string; | ||
readonly filters?: object; | ||
readonly sort?: string; | ||
readonly aggregations?: string; | ||
readonly contentTypes?: ReadonlyArray<string>; | ||
} | ||
export interface QueryResponse<A> { | ||
readonly aggregations: object; | ||
readonly count: number; | ||
readonly hits: ReadonlyArray<Content<A>>; | ||
readonly total: number; | ||
} | ||
export interface GetContentParams { | ||
readonly key: string; | ||
} | ||
export interface DeleteContentParams { | ||
readonly key: string; | ||
} | ||
export interface CreateContentParams<A> { | ||
readonly name: string; | ||
readonly parentPath: string; | ||
readonly displayName?: string; | ||
readonly requireValid?: boolean; | ||
readonly refresh?: boolean; | ||
readonly contentType: string; | ||
readonly language?: string; | ||
readonly childOrder?: string; | ||
readonly data: A; | ||
readonly x?: string; | ||
} | ||
export interface ModifyContentParams<A> { | ||
readonly key: string; | ||
readonly editor: (c: Content<A>) => Content<A>; | ||
readonly requireValid?: boolean; | ||
} | ||
export interface PublishContentParams { | ||
readonly keys: ReadonlyArray<string>; | ||
readonly sourceBranch: string; | ||
readonly targetBranch: string; | ||
readonly schedule?: ScheduleParams; | ||
readonly excludeChildrenIds?: ReadonlyArray<string>; | ||
readonly includeDependencies?: boolean; | ||
} | ||
export interface ScheduleParams { | ||
readonly from: string; | ||
readonly to: string; | ||
} | ||
export interface PublishResponse { | ||
readonly pushedContents: ReadonlyArray<string>; | ||
readonly deletedContents: ReadonlyArray<string>; | ||
readonly failedContents: ReadonlyArray<string>; | ||
} | ||
export interface UnpublishContentParams { | ||
readonly keys: ReadonlyArray<string>; | ||
} | ||
export interface GetChildrenParams { | ||
readonly key: string; | ||
readonly start?: number; | ||
readonly count?: number; | ||
readonly sort?: string; | ||
} | ||
export interface MoveParams { | ||
readonly source: string; | ||
readonly target: string; | ||
} | ||
export interface GetSiteParams { | ||
readonly key: string; | ||
} | ||
export interface Site<A> { | ||
readonly _id: string; | ||
readonly _name: string; | ||
readonly _path: string; | ||
readonly type: string; | ||
readonly hasChildren: boolean; | ||
readonly valid: boolean; | ||
readonly data: { | ||
readonly siteConfig: SiteConfig<A>; | ||
}; | ||
readonly x: { | ||
readonly [key: string]: string; | ||
}; | ||
readonly page: any; | ||
readonly attachments: object; | ||
readonly publish: any; | ||
} | ||
export interface SiteConfig<A> { | ||
readonly applicationKey: string; | ||
readonly config: A; | ||
} | ||
export interface GetSiteConfigParams { | ||
readonly key: string; | ||
readonly applicationKey: string; | ||
} | ||
export interface AttachmentStreamParams { | ||
readonly key: string; | ||
readonly name: string; | ||
} | ||
export interface RemoveAttachmentParams { | ||
readonly key: string; | ||
readonly name: string | ReadonlyArray<string>; | ||
} | ||
export interface ByteSource { | ||
isEmpty(): boolean; | ||
size(): number; | ||
} | ||
export interface CreateMediaParams { | ||
readonly name?: string; | ||
readonly parentPath?: string; | ||
readonly mimeType?: string; | ||
readonly focalX?: number; | ||
readonly focalY?: number; | ||
readonly data: ByteSource; | ||
} | ||
export interface GetPermissionsParams { | ||
readonly key: string; | ||
} | ||
export interface GetPermissionsResult { | ||
readonly inheritsPermissions: boolean; | ||
readonly permissions: ReadonlyArray<PermissionsParams>; | ||
} | ||
export interface PermissionsParams { | ||
readonly principal: string; | ||
readonly allow: ReadonlyArray<string>; | ||
readonly deny: ReadonlyArray<string>; | ||
} | ||
export interface SetPermissionsParams { | ||
readonly key: string; | ||
readonly inheritPermissions: boolean; | ||
readonly overwriteChildPermissions: boolean; | ||
readonly permissions: ReadonlyArray<PermissionsParams>; | ||
} | ||
export interface IconType { | ||
readonly data?: ByteSource; | ||
readonly mimeType?: string; | ||
readonly modifiedTime?: string; | ||
} | ||
export interface ContentType { | ||
readonly name: string; | ||
readonly displayName: string; | ||
readonly description: string; | ||
readonly superType: string; | ||
readonly abstract: boolean; | ||
readonly final: boolean; | ||
readonly allowChildContent: boolean; | ||
readonly displayNameExpression: string; | ||
readonly icon: ReadonlyArray<IconType>; | ||
readonly form: ReadonlyArray<any>; | ||
} | ||
import { Attachments, AttachmentStreamParams, ByteSource, Content, ContentType, CreateContentParams, CreateMediaParams, DeleteContentParams, GetChildrenParams, GetContentParams, GetPermissionsParams, GetPermissionsResult, GetSiteConfigParams, GetSiteParams, ModifyContentParams, MoveParams, PublishContentParams, PublishResponse, QueryContentParams, QueryResponse, RemoveAttachmentParams, SetPermissionsParams, Site, UnpublishContentParams } from "enonic-types/lib/content"; | ||
export declare function get<A>(params: GetContentParams): IOEither<EnonicError, Content<A>>; | ||
@@ -187,0 +5,0 @@ export declare function query<A>(params: QueryContentParams): IOEither<EnonicError, QueryResponse<A>>; |
@@ -7,21 +7,21 @@ "use strict"; | ||
var utils_2 = require("./utils"); | ||
var content = __non_webpack_require__("/lib/xp/content"); | ||
var contentLib = __non_webpack_require__("/lib/xp/content"); | ||
function get(params) { | ||
return pipeable_1.pipe(utils_2.catchEnonicError(function () { return content.get(params); }), IOEither_1.chain(utils_1.fromNullable({ errorKey: "NotFoundError" }))); | ||
return pipeable_1.pipe(utils_2.catchEnonicError(function () { return contentLib.get(params); }), IOEither_1.chain(utils_1.fromNullable({ errorKey: "NotFoundError" }))); | ||
} | ||
exports.get = get; | ||
function query(params) { | ||
return utils_2.catchEnonicError(function () { return content.query(params); }); | ||
return utils_2.catchEnonicError(function () { return contentLib.query(params); }); | ||
} | ||
exports.query = query; | ||
function create(params) { | ||
return utils_2.catchEnonicError(function () { return content.create(params); }); | ||
return utils_2.catchEnonicError(function () { return contentLib.create(params); }); | ||
} | ||
exports.create = create; | ||
function modify(params) { | ||
return utils_2.catchEnonicError(function () { return content.modify(params); }); | ||
return utils_2.catchEnonicError(function () { return contentLib.modify(params); }); | ||
} | ||
exports.modify = modify; | ||
function remove(params) { | ||
return pipeable_1.pipe(utils_2.catchEnonicError(function () { return content.delete(params); }), IOEither_1.chain(function (success) { | ||
return pipeable_1.pipe(utils_2.catchEnonicError(function () { return contentLib.delete(params); }), IOEither_1.chain(function (success) { | ||
return success | ||
@@ -36,31 +36,31 @@ ? IOEither_1.right(undefined) | ||
function publish(params) { | ||
return utils_2.catchEnonicError(function () { return content.publish(params); }, "PublishError"); | ||
return utils_2.catchEnonicError(function () { return contentLib.publish(params); }, "PublishError"); | ||
} | ||
exports.publish = publish; | ||
function unpublish(params) { | ||
return utils_2.catchEnonicError(function () { return content.unpublish(params); }, "PublishError"); | ||
return utils_2.catchEnonicError(function () { return contentLib.unpublish(params); }, "PublishError"); | ||
} | ||
exports.unpublish = unpublish; | ||
function getChildren(params) { | ||
return utils_2.catchEnonicError(function () { return content.getChildren(params); }); | ||
return utils_2.catchEnonicError(function () { return contentLib.getChildren(params); }); | ||
} | ||
exports.getChildren = getChildren; | ||
function move(params) { | ||
return utils_2.catchEnonicError(function () { return content.move(params); }); | ||
return utils_2.catchEnonicError(function () { return contentLib.move(params); }); | ||
} | ||
exports.move = move; | ||
function getSite(params) { | ||
return utils_2.catchEnonicError(function () { return content.getSite(params); }); | ||
return utils_2.catchEnonicError(function () { return contentLib.getSite(params); }); | ||
} | ||
exports.getSite = getSite; | ||
function getSiteConfig(params) { | ||
return utils_2.catchEnonicError(function () { return content.getSiteConfig(params); }); | ||
return utils_2.catchEnonicError(function () { return contentLib.getSiteConfig(params); }); | ||
} | ||
exports.getSiteConfig = getSiteConfig; | ||
function createMedia(params) { | ||
return utils_2.catchEnonicError(function () { return content.createMedia(params); }); | ||
return utils_2.catchEnonicError(function () { return contentLib.createMedia(params); }); | ||
} | ||
exports.createMedia = createMedia; | ||
function getAttachments(key) { | ||
return pipeable_1.pipe(utils_2.catchEnonicError(function () { return content.getAttachments(key); }), IOEither_1.chain(utils_1.fromNullable({ errorKey: "NotFoundError" }))); | ||
return pipeable_1.pipe(utils_2.catchEnonicError(function () { return contentLib.getAttachments(key); }), IOEither_1.chain(utils_1.fromNullable({ errorKey: "NotFoundError" }))); | ||
} | ||
@@ -70,24 +70,24 @@ exports.getAttachments = getAttachments; | ||
function getAttachmentStream(params) { | ||
return pipeable_1.pipe(utils_2.catchEnonicError(function () { return content.getAttachmentStream(params); }), IOEither_1.chain(utils_1.fromNullable({ errorKey: "NotFoundError" }))); | ||
return pipeable_1.pipe(utils_2.catchEnonicError(function () { return contentLib.getAttachmentStream(params); }), IOEither_1.chain(utils_1.fromNullable({ errorKey: "NotFoundError" }))); | ||
} | ||
exports.getAttachmentStream = getAttachmentStream; | ||
function removeAttachment(params) { | ||
return utils_2.catchEnonicError(function () { return content.removeAttachment(params); }); | ||
return utils_2.catchEnonicError(function () { return contentLib.removeAttachment(params); }); | ||
} | ||
exports.removeAttachment = removeAttachment; | ||
function getPermissions(params) { | ||
return utils_2.catchEnonicError(function () { return content.getPermissions(params); }); | ||
return utils_2.catchEnonicError(function () { return contentLib.getPermissions(params); }); | ||
} | ||
exports.getPermissions = getPermissions; | ||
function setPermissions(params) { | ||
return utils_2.catchEnonicError(function () { return content.setPermissions(params); }); | ||
return utils_2.catchEnonicError(function () { return contentLib.setPermissions(params); }); | ||
} | ||
exports.setPermissions = setPermissions; | ||
function getType(name) { | ||
return utils_2.catchEnonicError(function () { return content.getType(name); }); | ||
return pipeable_1.pipe(utils_2.catchEnonicError(function () { return contentLib.getType(name); }), IOEither_1.chain(utils_1.fromNullable({ errorKey: "NotFoundError" }))); | ||
} | ||
exports.getType = getType; | ||
function getTypes() { | ||
return utils_2.catchEnonicError(function () { return content.getTypes(); }); | ||
return utils_2.catchEnonicError(function () { return contentLib.getTypes(); }); | ||
} | ||
exports.getTypes = getTypes; |
import { IO } from "fp-ts/lib/IO"; | ||
import { IOEither } from "fp-ts/lib/IOEither"; | ||
import { EnonicError } from "./common"; | ||
export interface Context { | ||
readonly repository: string; | ||
readonly branch: string; | ||
readonly authInfo: AuthInfo; | ||
} | ||
interface AuthInfo { | ||
readonly user: User; | ||
} | ||
interface User { | ||
readonly type: string; | ||
readonly key: string; | ||
readonly displayName: string; | ||
readonly disabled: boolean; | ||
readonly email: string; | ||
readonly login: string; | ||
readonly idProvider: string; | ||
} | ||
interface RunContext { | ||
readonly repository?: string; | ||
readonly branch?: string; | ||
readonly user?: { | ||
readonly login: string; | ||
readonly idProvider?: string; | ||
}; | ||
readonly principals?: ReadonlyArray<string>; | ||
readonly attributes?: { | ||
readonly [key: string]: string | boolean | number; | ||
}; | ||
} | ||
import { Context, RunContext } from "enonic-types/lib/context"; | ||
export declare function get(): IOEither<EnonicError, Context>; | ||
export declare function runUnsafe<A>(runContext: RunContext, f: () => A): A; | ||
export declare function run<A>(runContext: RunContext): (a: IO<A>) => IO<A>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utils_1 = require("./utils"); | ||
var context = __non_webpack_require__("/lib/xp/context"); | ||
var contextLib = __non_webpack_require__("/lib/xp/context"); | ||
function get() { | ||
return utils_1.catchEnonicError(function () { return context.get(); }); | ||
return utils_1.catchEnonicError(function () { return contextLib.get(); }); | ||
} | ||
exports.get = get; | ||
function runUnsafe(runContext, f) { | ||
return context.run(runContext, f); | ||
return contextLib.run(runContext, f); | ||
} | ||
@@ -12,0 +12,0 @@ exports.runUnsafe = runUnsafe; |
import { IOEither } from "fp-ts/lib/IOEither"; | ||
import { EnonicError } from "./common"; | ||
import { ByteSource } from "./content"; | ||
interface HttpRequestParamsProxy { | ||
/** Proxy host name to use. */ | ||
readonly host?: string; | ||
/** Proxy port to use. */ | ||
readonly port?: number; | ||
/** User name for proxy authentication. */ | ||
readonly user?: string; | ||
/** Password for proxy authentication. */ | ||
readonly password?: string; | ||
} | ||
interface HttpRequestParamsAuth { | ||
/** User name for basic authentication. */ | ||
readonly user?: string; | ||
/** Password for basic authentication. */ | ||
readonly password?: string; | ||
} | ||
export interface HttpRequestParams { | ||
/** URL to which the request is sent. */ | ||
readonly url: string; | ||
/** The HTTP method to use for the request (e.g. "POST", "GET", "HEAD", "PUT", "DELETE"). */ | ||
readonly method?: string; | ||
/** Query or form parameters to be sent with the request. */ | ||
readonly params?: { | ||
readonly [key: string]: string; | ||
}; | ||
/** HTTP headers, an object where the keys are header names and the values the header values. */ | ||
readonly headers?: { | ||
readonly [key: string]: string; | ||
}; | ||
/** The timeout on establishing the connection, in milliseconds. */ | ||
readonly connectionTimeout?: number; | ||
/** The timeout on waiting to receive data, in milliseconds. */ | ||
readonly readTimeout?: number; | ||
/** Body content to send with the request, usually for POST or PUT requests. It can be of type string or stream. */ | ||
readonly body?: string | ByteSource; | ||
/** Content type of the request. */ | ||
readonly contentType?: string; | ||
/** | ||
* Multipart form data to send with the request, an array of part objects. Each part object contains | ||
* 'name', 'value', and optionally 'fileName' and 'contentType' properties. Where 'value' can be either a string or a | ||
* Stream object. | ||
*/ | ||
readonly multipart?: ReadonlyArray<object>; | ||
/** Settings for basic authentication. */ | ||
readonly auth?: HttpRequestParamsAuth; | ||
/** Proxy settings. */ | ||
readonly proxy?: HttpRequestParamsProxy; | ||
/** | ||
* If set to false redirect responses (status=3xx) will not trigger a new internal request, and the function will | ||
* return directly with the 3xx status. | ||
*/ | ||
readonly followRedirects?: boolean; | ||
} | ||
export interface HttpResponse { | ||
/** HTTP status code returned. */ | ||
readonly status: number; | ||
/** HTTP status message returned. */ | ||
readonly message: string; | ||
/** HTTP headers of the response. */ | ||
readonly headers: { | ||
readonly [key: string]: string | undefined; | ||
}; | ||
/** Content type of the response. */ | ||
readonly contentType: string; | ||
/** Body of the response as string. Null if the response content-type is not of type text. */ | ||
readonly body: string | null; | ||
/** Body of the response as a stream object. */ | ||
readonly bodyStream: ByteSource; | ||
} | ||
import { HttpRequestParams, HttpResponse } from "enonic-types/lib/http"; | ||
/** | ||
@@ -78,2 +9,1 @@ * Sends an HTTP request and returns the response received from the remote server. | ||
export declare function request(params: HttpRequestParams): IOEither<EnonicError, HttpResponse>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utils_1 = require("./utils"); | ||
var httpClient = __non_webpack_require__("/lib/http-client"); | ||
var httpLib = __non_webpack_require__("/lib/http-client"); | ||
/** | ||
@@ -10,4 +10,4 @@ * Sends an HTTP request and returns the response received from the remote server. | ||
function request(params) { | ||
return utils_1.catchEnonicError(function () { return httpClient.request(params); }, "BadGatewayError"); | ||
return utils_1.catchEnonicError(function () { return httpLib.request(params); }, "BadGatewayError"); | ||
} | ||
exports.request = request; |
import { Option } from "fp-ts/lib/Option"; | ||
export interface LocalizeParams { | ||
readonly key: string; | ||
readonly locale?: string | ReadonlyArray<string>; | ||
readonly values?: ReadonlyArray<string>; | ||
readonly bundles?: ReadonlyArray<string>; | ||
readonly application?: string; | ||
} | ||
import { LocalizeParams } from "enonic-types/lib/i18n"; | ||
export declare function getPhrases(locale: string | ReadonlyArray<string>, bundles: ReadonlyArray<string>): { | ||
@@ -10,0 +4,0 @@ [key: string]: string; |
@@ -5,14 +5,14 @@ "use strict"; | ||
var pipeable_1 = require("fp-ts/lib/pipeable"); | ||
var i18n = __non_webpack_require__("/lib/xp/i18n"); | ||
var i18nLib = __non_webpack_require__("/lib/xp/i18n"); | ||
var NOT_TRANSLATED_MESSAGE = "NOT_TRANSLATED"; | ||
function getPhrases(locale, bundles) { | ||
return i18n.getPhrases(locale, bundles); | ||
return i18nLib.getPhrases(locale, bundles); | ||
} | ||
exports.getPhrases = getPhrases; | ||
function getSupportedLocales(bundles) { | ||
return i18n.getSupportedLocales(bundles); | ||
return i18nLib.getSupportedLocales(bundles); | ||
} | ||
exports.getSupportedLocales = getSupportedLocales; | ||
function localize(params) { | ||
return pipeable_1.pipe(Option_1.fromNullable(i18n.localize(params)), Option_1.map(function (result) { | ||
return pipeable_1.pipe(Option_1.fromNullable(i18nLib.localize(params)), Option_1.map(function (result) { | ||
return result === NOT_TRANSLATED_MESSAGE ? params.key : result; | ||
@@ -19,0 +19,0 @@ })); |
import { IOEither } from "fp-ts/lib/IOEither"; | ||
import { EnonicError } from "./common"; | ||
import { ByteSource } from "./content"; | ||
export interface EmailAttachment { | ||
readonly fileName: string; | ||
readonly data: ByteSource; | ||
readonly mimeType: string; | ||
readonly headers: { | ||
[key: string]: string; | ||
}; | ||
} | ||
export interface EmailParams { | ||
readonly from: string; | ||
readonly to: string | ReadonlyArray<string>; | ||
readonly cc?: string | ReadonlyArray<string>; | ||
readonly bcc?: string | ReadonlyArray<string>; | ||
readonly replyTo?: string; | ||
readonly subject: string; | ||
readonly body: string; | ||
readonly contentType?: string; | ||
readonly headers?: string; | ||
readonly attachments?: ReadonlyArray<EmailAttachment>; | ||
} | ||
import { EmailParams } from "enonic-types/lib/mail"; | ||
export declare function send(params: EmailParams): IOEither<EnonicError, void>; |
@@ -6,5 +6,5 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
var email = __non_webpack_require__("/lib/xp/mail"); | ||
var mailLib = __non_webpack_require__("/lib/xp/mail"); | ||
function send(params) { | ||
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return email.send(params); }), IOEither_1.chain(function (success) { | ||
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return mailLib.send(params); }), IOEither_1.chain(function (success) { | ||
return success | ||
@@ -11,0 +11,0 @@ ? IOEither_1.right(undefined) |
import { IOEither } from "fp-ts/lib/IOEither"; | ||
import { EnonicError } from "./common"; | ||
import { PermissionsParams } from "./content"; | ||
export interface Source { | ||
readonly repoId: string; | ||
readonly branch: string; | ||
readonly user?: { | ||
readonly login: string; | ||
readonly idProvider?: string; | ||
}; | ||
readonly principals?: ReadonlyArray<string>; | ||
} | ||
export interface NodeQueryHit { | ||
readonly id: string; | ||
readonly score: number; | ||
} | ||
export interface NodeQueryResponse { | ||
readonly total: number; | ||
readonly count: number; | ||
readonly hits: ReadonlyArray<NodeQueryHit>; | ||
} | ||
export interface NodeQueryParams { | ||
/** | ||
* Start index (used for paging). | ||
*/ | ||
readonly start?: number; | ||
/** | ||
* Number of contents to fetch. | ||
*/ | ||
readonly count?: number; | ||
/** | ||
* Query expression. | ||
*/ | ||
readonly query: string; | ||
/** | ||
* Query filters | ||
*/ | ||
readonly filters?: any; | ||
/** | ||
* Sorting expression. | ||
*/ | ||
readonly sort?: string; | ||
/** | ||
* Aggregations expression. | ||
*/ | ||
readonly aggregations?: string; | ||
/** | ||
* Return score calculation explanation. | ||
*/ | ||
readonly explain?: boolean; | ||
} | ||
export interface IndexConfigEntry { | ||
/** | ||
* If true, indexing is done based on valueType, according to the table above. I.e. numeric values are indexed as | ||
* both string and numeric. | ||
*/ | ||
readonly decideByType: boolean; | ||
/** | ||
* If false, indexing will be disabled for the affected properties | ||
*/ | ||
readonly enabled: boolean; | ||
/** | ||
* Values are stored as 'ngram' | ||
*/ | ||
readonly nGram: boolean; | ||
/** | ||
* Values are stored as 'ngram', 'analyzed' and also added to the _allText system property | ||
*/ | ||
readonly fulltext: boolean; | ||
/** | ||
* Affected values will be added to the _allText property | ||
*/ | ||
readonly includeInAllText: boolean; | ||
/** | ||
* Values are stored as 'path' type and applicable for the pathMatch-function | ||
*/ | ||
readonly path: boolean; | ||
readonly indexValueProcessors: ReadonlyArray<any>; | ||
readonly languages: ReadonlyArray<any>; | ||
} | ||
export declare type IndexConfigTemplates = "none" | "byType" | "fulltext" | "path" | "minimal"; | ||
export interface IndexConfig { | ||
readonly default: IndexConfigEntry | IndexConfigTemplates; | ||
readonly configs?: ReadonlyArray<{ | ||
readonly path: string; | ||
readonly config: IndexConfigEntry | IndexConfigTemplates; | ||
}>; | ||
} | ||
export interface NodeCreateParams { | ||
/** | ||
* Name of content. | ||
*/ | ||
readonly _name?: string; | ||
/** | ||
* Path to place content under. | ||
*/ | ||
readonly _parentPath?: string; | ||
/** | ||
* How the document should be indexed. A default value "byType" will be set if no value specified. | ||
*/ | ||
readonly _indexConfig?: IndexConfig; | ||
/** | ||
* The access control list for the node. By default the creator will have full access | ||
*/ | ||
readonly _permissions?: ReadonlyArray<PermissionsParams>; | ||
/** | ||
* true if the permissions should be inherited from the node parent. Default is false. | ||
*/ | ||
readonly _inheritsPermissions?: boolean; | ||
/** | ||
* Value used to order document when ordering by parent and child-order is set to manual | ||
*/ | ||
readonly _manualOrderValue?: number; | ||
/** | ||
* Default ordering of children when doing getChildren if no order is given in query | ||
*/ | ||
readonly _childOrder?: string; | ||
} | ||
export interface RepoNode { | ||
readonly _id: string; | ||
readonly _childOrder: string; | ||
readonly _indexConfig: IndexConfig; | ||
readonly _inheritsPermissions: boolean; | ||
readonly _permissions: ReadonlyArray<PermissionsParams>; | ||
readonly _state: string; | ||
readonly _nodeType: string; | ||
} | ||
export interface RepoConnection { | ||
create<A>(a: A & NodeCreateParams): A & RepoNode; | ||
delete(keys: ReadonlyArray<string> | string): boolean; | ||
get<A>(keys: string | ReadonlyArray<string>): ReadonlyArray<A & RepoNode>; | ||
query<A>(params: NodeQueryParams): NodeQueryResponse; | ||
} | ||
import { NodeCreateParams, NodeQueryParams, NodeQueryResponse, RepoConnection, RepoNode, Source } from "enonic-types/lib/node"; | ||
/** | ||
@@ -135,0 +5,0 @@ * Creates a connection to a repository with a given branch and authentication info. |
@@ -6,3 +6,3 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
var node = __non_webpack_require__("/lib/xp/node"); | ||
var nodeLib = __non_webpack_require__("/lib/xp/node"); | ||
/** | ||
@@ -12,3 +12,3 @@ * Creates a connection to a repository with a given branch and authentication info. | ||
function connect(params) { | ||
return utils_1.catchEnonicError(function () { return node.connect(params); }); | ||
return utils_1.catchEnonicError(function () { return nodeLib.connect(params); }); | ||
} | ||
@@ -15,0 +15,0 @@ exports.connect = connect; |
import { IOEither } from "fp-ts/lib/IOEither"; | ||
import { EnonicError } from "./common"; | ||
import { ByteSource, Content, Site } from "./content"; | ||
export interface IdProviderUrlParams { | ||
readonly idProvider?: string; | ||
readonly contextPath?: string; | ||
readonly type?: "server" | "absolute"; | ||
readonly params?: { | ||
readonly [key: string]: string; | ||
}; | ||
} | ||
export interface ImagePlaceHolderParams { | ||
readonly width: number; | ||
readonly height: number; | ||
} | ||
export interface AssetUrlParams { | ||
readonly path: string; | ||
readonly application?: string; | ||
readonly type?: "server" | "absolute"; | ||
readonly params?: { | ||
readonly [key: string]: string; | ||
}; | ||
} | ||
export interface AttachmentUrlParams { | ||
readonly id?: string; | ||
readonly path?: string; | ||
readonly name?: string; | ||
readonly label?: string; | ||
readonly download?: boolean; | ||
readonly params?: { | ||
readonly [key: string]: string; | ||
}; | ||
readonly type?: "server" | "absolute"; | ||
} | ||
export interface ComponentUrlParams { | ||
readonly id?: string; | ||
readonly path?: string; | ||
readonly component?: string; | ||
readonly type?: "server" | "absolute"; | ||
readonly params?: { | ||
readonly [key: string]: string; | ||
}; | ||
} | ||
export interface ImageUrlParams { | ||
readonly id?: string; | ||
readonly path?: string; | ||
readonly scale: string; | ||
readonly quality?: number; | ||
readonly background?: string; | ||
readonly format?: string; | ||
readonly filter?: string; | ||
readonly type?: "server" | "absolute"; | ||
readonly params?: { | ||
readonly [key: string]: string; | ||
}; | ||
} | ||
export interface PageUrlParams { | ||
readonly id?: string; | ||
readonly path?: string; | ||
readonly type?: "server" | "absolute"; | ||
readonly params?: { | ||
readonly [key: string]: string; | ||
}; | ||
} | ||
export interface LoginUrlParams { | ||
readonly idProvider?: string; | ||
readonly redirect?: string; | ||
readonly contextPath?: string; | ||
readonly type?: "server" | "absolute"; | ||
readonly params?: { | ||
readonly [key: string]: string; | ||
}; | ||
} | ||
export interface LogoutUrlParams { | ||
readonly redirect?: string; | ||
readonly contextPath?: string; | ||
readonly type?: "server" | "absolute"; | ||
readonly params?: { | ||
readonly [key: string]: string; | ||
}; | ||
} | ||
export interface ServiceUrlParams { | ||
readonly service: string; | ||
readonly application?: string; | ||
readonly type?: "server" | "absolute"; | ||
readonly params?: { | ||
readonly [key: string]: string; | ||
}; | ||
} | ||
export interface UrlParams { | ||
readonly path?: string; | ||
readonly type?: "server" | "absolute"; | ||
readonly params?: { | ||
readonly [key: string]: string; | ||
}; | ||
} | ||
export interface ProcessHtmlParams { | ||
readonly value: string; | ||
readonly type?: "server" | "absolute"; | ||
} | ||
import { ByteSource, Content, Site } from "enonic-types/lib/content"; | ||
import { AssetUrlParams, AttachmentUrlParams, ComponentUrlParams, IdProviderUrlParams, ImagePlaceHolderParams, ImageUrlParams, LoginUrlParams, LogoutUrlParams, MultipartItem, PageUrlParams, ProcessHtmlParams, ServiceUrlParams, UrlParams } from "enonic-types/lib/portal"; | ||
export declare function getContent<A>(): IOEither<EnonicError, Content<A>>; | ||
export declare function getIdProviderKey(): IOEither<EnonicError, string>; | ||
export interface MultipartItem { | ||
readonly name: string; | ||
readonly fileName: string; | ||
readonly contentType: string; | ||
readonly size: number; | ||
} | ||
/** | ||
* This function returns a JSON containing multipart items. If not a multipart request, then this function returns `undefined`. | ||
* This function returns a JSON containing multipart items. | ||
* If not a multipart request, then this function returns `BadRequestError`. | ||
*/ | ||
export declare function getMultipartForm(): IOEither<EnonicError, ReadonlyArray<MultipartItem | ReadonlyArray<MultipartItem>>>; | ||
/** | ||
* This function returns a JSON containing a named multipart item. If the item does not exists, it returns `undefined`. | ||
* This function returns a JSON containing a named multipart item. | ||
* If the item does not exist it returns `BadRequestError`. | ||
*/ | ||
@@ -119,2 +19,3 @@ export declare function getMultipartItem(name: string, index?: number, errorMessage?: string): IOEither<EnonicError, MultipartItem>; | ||
* This function returns a data-stream for a named multipart item. | ||
* If the item does not exist it returns `BadRequestError`. | ||
*/ | ||
@@ -124,2 +25,3 @@ export declare function getMultipartStream(name: string, index?: number, errorMessage?: string): IOEither<EnonicError, ByteSource>; | ||
* This function returns the multipart item data as text. | ||
* If the item does not exist it returns `BadRequestError`. | ||
*/ | ||
@@ -126,0 +28,0 @@ export declare function getMultipartText(name: string, index?: number, errorMessage?: string): IOEither<EnonicError, string>; |
@@ -6,5 +6,5 @@ "use strict"; | ||
var IOEither_1 = require("fp-ts/es6/IOEither"); | ||
var portal = __non_webpack_require__("/lib/xp/portal"); | ||
var portalLib = __non_webpack_require__("/lib/xp/portal"); | ||
function getContent() { | ||
return utils_1.catchEnonicError(function () { return portal.getContent(); }); | ||
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return portalLib.getContent(); }), IOEither_1.chain(utils_1.fromNullable({ errorKey: "NotFoundError" }))); | ||
} | ||
@@ -16,14 +16,16 @@ exports.getContent = getContent; | ||
errorKey: "InternalServerError" | ||
})(portal.getIdProviderKey()); | ||
})(portalLib.getIdProviderKey()); | ||
} | ||
exports.getIdProviderKey = getIdProviderKey; | ||
/** | ||
* This function returns a JSON containing multipart items. If not a multipart request, then this function returns `undefined`. | ||
* This function returns a JSON containing multipart items. | ||
* If not a multipart request, then this function returns `BadRequestError`. | ||
*/ | ||
function getMultipartForm() { | ||
return utils_1.catchEnonicError(function () { return portal.getMultipartForm(); }); | ||
return utils_1.catchEnonicError(function () { return portalLib.getMultipartForm(); }); | ||
} | ||
exports.getMultipartForm = getMultipartForm; | ||
/** | ||
* This function returns a JSON containing a named multipart item. If the item does not exists, it returns `undefined`. | ||
* This function returns a JSON containing a named multipart item. | ||
* If the item does not exist it returns `BadRequestError`. | ||
*/ | ||
@@ -34,3 +36,3 @@ function getMultipartItem(name, index, errorMessage) { | ||
if (errorMessage === void 0) { errorMessage = "portal.error.multipartItem"; } | ||
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return portal.getMultipartItem(name, index); }), IOEither_1.chain(utils_1.fromNullable({ | ||
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return portalLib.getMultipartItem(name, index); }), IOEither_1.chain(utils_1.fromNullable({ | ||
errorKey: "BadRequestError", | ||
@@ -45,2 +47,3 @@ errors: (_a = {}, | ||
* This function returns a data-stream for a named multipart item. | ||
* If the item does not exist it returns `BadRequestError`. | ||
*/ | ||
@@ -51,3 +54,3 @@ function getMultipartStream(name, index, errorMessage) { | ||
if (errorMessage === void 0) { errorMessage = "portal.error.multipartItem"; } | ||
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return portal.getMultipartStream(name, index); }), IOEither_1.chain(utils_1.fromNullable({ | ||
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return portalLib.getMultipartStream(name, index); }), IOEither_1.chain(utils_1.fromNullable({ | ||
errorKey: "BadRequestError", | ||
@@ -62,2 +65,3 @@ errors: (_a = {}, | ||
* This function returns the multipart item data as text. | ||
* If the item does not exist it returns `BadRequestError`. | ||
*/ | ||
@@ -68,3 +72,3 @@ function getMultipartText(name, index, errorMessage) { | ||
if (errorMessage === void 0) { errorMessage = "portal.error.multipartItem"; } | ||
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return portal.getMultipartText(name, index); }), IOEither_1.chain(utils_1.fromNullable({ | ||
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return portalLib.getMultipartText(name, index); }), IOEither_1.chain(utils_1.fromNullable({ | ||
errorKey: "BadRequestError", | ||
@@ -78,60 +82,60 @@ errors: (_a = {}, | ||
function getSite() { | ||
return utils_1.catchEnonicError(function () { return portal.getSite(); }); | ||
return utils_1.catchEnonicError(function () { return portalLib.getSite(); }); | ||
} | ||
exports.getSite = getSite; | ||
function getSiteConfig() { | ||
return utils_1.catchEnonicError(function () { return portal.getSiteConfig(); }); | ||
return utils_1.catchEnonicError(function () { return portalLib.getSiteConfig(); }); | ||
} | ||
exports.getSiteConfig = getSiteConfig; | ||
function idProviderUrl(params) { | ||
return portal.idProviderUrl(params); | ||
return portalLib.idProviderUrl(params); | ||
} | ||
exports.idProviderUrl = idProviderUrl; | ||
function imagePlaceholder(params) { | ||
return portal.imagePlaceholder(params); | ||
return portalLib.imagePlaceholder(params); | ||
} | ||
exports.imagePlaceholder = imagePlaceholder; | ||
function assetUrl(params) { | ||
return portal.assetUrl(params); | ||
return portalLib.assetUrl(params); | ||
} | ||
exports.assetUrl = assetUrl; | ||
function attachmentUrl(params) { | ||
return portal.attachmentUrl(params); | ||
return portalLib.attachmentUrl(params); | ||
} | ||
exports.attachmentUrl = attachmentUrl; | ||
function componentUrl(params) { | ||
return portal.componentUrl(params); | ||
return portalLib.componentUrl(params); | ||
} | ||
exports.componentUrl = componentUrl; | ||
function serviceUrl(params) { | ||
return portal.serviceUrl(params); | ||
return portalLib.serviceUrl(params); | ||
} | ||
exports.serviceUrl = serviceUrl; | ||
function imageUrl(params) { | ||
return portal.imageUrl(params); | ||
return portalLib.imageUrl(params); | ||
} | ||
exports.imageUrl = imageUrl; | ||
function loginUrl(params) { | ||
return portal.loginUrl(params); | ||
return portalLib.loginUrl(params); | ||
} | ||
exports.loginUrl = loginUrl; | ||
function logoutUrl(params) { | ||
return portal.imageUrl(params); | ||
return portalLib.logoutUrl(params); | ||
} | ||
exports.logoutUrl = logoutUrl; | ||
function pageUrl(params) { | ||
return portal.pageUrl(params); | ||
return portalLib.pageUrl(params); | ||
} | ||
exports.pageUrl = pageUrl; | ||
function url(params) { | ||
return portal.url(params); | ||
return portalLib.url(params); | ||
} | ||
exports.url = url; | ||
function processHtml(params) { | ||
return portal.processHtml(params); | ||
return portalLib.processHtml(params); | ||
} | ||
exports.processHtml = processHtml; | ||
function sanitizeHtml(html) { | ||
return portal.processHtml(html); | ||
return portalLib.sanitizeHtml(html); | ||
} | ||
exports.sanitizeHtml = sanitizeHtml; |
import { IOEither } from "fp-ts/lib/IOEither"; | ||
import { EnonicError } from "./common"; | ||
import { PermissionsParams } from "./content"; | ||
export interface IndexDefinition { | ||
readonly settings: any; | ||
readonly mapping: any; | ||
} | ||
export interface CreateRepoParams { | ||
readonly id: string; | ||
readonly rootPermissions?: ReadonlyArray<PermissionsParams>; | ||
readonly settings?: { | ||
readonly definitions?: { | ||
readonly search?: IndexDefinition; | ||
readonly version?: IndexDefinition; | ||
readonly branch?: IndexDefinition; | ||
}; | ||
}; | ||
} | ||
export interface CreateBranchParams { | ||
readonly branchId: string; | ||
readonly repoId: string; | ||
} | ||
export interface RepositoryConfig { | ||
readonly id: string; | ||
readonly branches: ReadonlyArray<string>; | ||
readonly settings: any; | ||
} | ||
export interface RefreshParams { | ||
readonly mode?: string; | ||
readonly repo?: string; | ||
readonly branch?: string; | ||
} | ||
export interface DeleteBranchParams { | ||
readonly branchId: string; | ||
readonly repoId: string; | ||
} | ||
import { CreateBranchParams, CreateRepoParams, DeleteBranchParams, RefreshParams, RepositoryConfig } from "enonic-types/lib/repo"; | ||
export declare function create(params: CreateRepoParams): IOEither<EnonicError, RepositoryConfig>; | ||
@@ -38,0 +5,0 @@ export declare function createBranch(params: CreateBranchParams): IOEither<EnonicError, RepositoryConfig>; |
@@ -6,31 +6,30 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
var repo = __non_webpack_require__("/lib/xp/repo"); | ||
var repoLib = __non_webpack_require__("/lib/xp/repo"); | ||
function create(params) { | ||
return utils_1.catchEnonicError(function () { return repo.create(params); }); | ||
return utils_1.catchEnonicError(function () { return repoLib.create(params); }); | ||
} | ||
exports.create = create; | ||
function createBranch(params) { | ||
return utils_1.catchEnonicError(function () { return repo.createBranch(params); }); | ||
return utils_1.catchEnonicError(function () { return repoLib.createBranch(params); }); | ||
} | ||
exports.createBranch = createBranch; | ||
function get(id) { | ||
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return repo.get(id); }), IOEither_1.chain(utils_1.fromNullable({ errorKey: "NotFoundError" }))); | ||
return pipeable_1.pipe(utils_1.catchEnonicError(function () { return repoLib.get(id); }), IOEither_1.chain(utils_1.fromNullable({ errorKey: "NotFoundError" }))); | ||
} | ||
exports.get = get; | ||
function list() { | ||
return utils_1.catchEnonicError(function () { return repo.list(); }); | ||
return utils_1.catchEnonicError(function () { return repoLib.list(); }); | ||
} | ||
exports.list = list; | ||
function remove(id) { | ||
return utils_1.catchEnonicError(function () { return repo.delete(id); }); | ||
return utils_1.catchEnonicError(function () { return repoLib.delete(id); }); | ||
} | ||
exports.remove = remove; | ||
function deleteBranch(params) { | ||
// TODO Figure out the shape here for "any" | ||
return utils_1.catchEnonicError(function () { return repo.deleteBranch(params); }); | ||
return utils_1.catchEnonicError(function () { return repoLib.deleteBranch(params); }); | ||
} | ||
exports.deleteBranch = deleteBranch; | ||
function refresh(params) { | ||
return utils_1.catchEnonicError(function () { return repo.refresh(params); }); | ||
return utils_1.catchEnonicError(function () { return repoLib.refresh(params); }); | ||
} | ||
exports.refresh = refresh; |
import { IOEither } from "fp-ts/lib/IOEither"; | ||
import { EnonicError } from "./common"; | ||
export interface ThymeleafRenderOptions { | ||
readonly mode: "HTML" | "XML" | "TEXT" | "JAVASCRIPT" | "CSS" | "RAW"; | ||
} | ||
import { ThymeleafRenderOptions } from "enonic-types/lib/thymeleaf"; | ||
export declare function renderUnsafe<A>(view: any, model?: A, options?: ThymeleafRenderOptions): string; | ||
@@ -7,0 +5,0 @@ export declare function render<A>(view: any, model?: A, options?: ThymeleafRenderOptions): IOEither<EnonicError, string>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utils_1 = require("./utils"); | ||
var thymeleaf = __non_webpack_require__("/lib/thymeleaf"); | ||
var thymeleafLib = __non_webpack_require__("/lib/thymeleaf"); | ||
function renderUnsafe(view, model, options) { | ||
return thymeleaf.render(view, model, options); | ||
return thymeleafLib.render(view, model, options); | ||
} | ||
@@ -8,0 +8,0 @@ exports.renderUnsafe = renderUnsafe; |
{ | ||
"name": "enonic-fp", | ||
"version": "0.1.8", | ||
"version": "0.2.0", | ||
"description": "Functional programming helpers for Enonic XP", | ||
@@ -27,2 +27,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"enonic-types": "^0.0.5", | ||
"fp-ts": "^2.1.1" | ||
@@ -29,0 +30,0 @@ }, |
@@ -38,4 +38,5 @@ # Enonic FP | ||
import { fold } from "fp-ts/lib/Either"; | ||
import { EnonicError, Request, Response } from "enonic-fp/lib/common"; | ||
import { Content, get as getContent } from 'enonic-fp/lib/content'; | ||
import { EnonicError, Request, Response } from "enonic-types/lib/common"; | ||
import { Content } from 'enonic-types/lib/content'; | ||
import { get as getContent } from 'enonic-fp/lib/content'; | ||
@@ -80,7 +81,8 @@ | ||
```typescript | ||
import {IO, io} from "fp-ts/lib/IO"; | ||
import {chain, fold, IOEither} from "fp-ts/lib/IOEither"; | ||
import { IO, io } from "fp-ts/lib/IO"; | ||
import { chain, fold, IOEither } from "fp-ts/lib/IOEither"; | ||
import { pipe } from "fp-ts/lib/pipeable"; | ||
import { EnonicError, Request, Response } from "enonic-fp/lib/common"; | ||
import {publish, PublishResponse, remove} from "enonic-fp/lib/context"; | ||
import { EnonicError, Request, Response } from "enonic-types/lib/common"; | ||
import { PublishResponse } from "enonic-types/lib/context"; | ||
import { publish, remove } from "enonic-fp/lib/context"; | ||
import { run } from "enonic-fp/lib/context"; | ||
@@ -154,4 +156,5 @@ | ||
import { pipe } from "fp-ts/lib/pipeable"; | ||
import { EnonicError, Request, Response } from "enonic-fp/lib/common"; | ||
import { get as getContent, query, QueryResponse } from "enonic-fp/lib/content"; | ||
import { EnonicError, Request, Response } from "enonic-types/lib/common"; | ||
import { QueryResponse } from "enonic-types/lib/content"; | ||
import { get as getContent, query } from "enonic-fp/lib/content"; | ||
import { request } from "enonic-fp/lib/http"; | ||
@@ -158,0 +161,0 @@ |
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
240
44271
2
832
+ Addedenonic-types@^0.0.5
+ Addedenonic-types@0.0.5(transitive)