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

enonic-types

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enonic-types - npm Package Compare versions

Comparing version 0.4.9 to 0.5.0-next.0

125

content.d.ts
declare module "*/lib/xp/content" {
global {
namespace XP {
interface ContentTypes {
"base:unstructured": Record<string, never>;
"base:folder": Record<string, never>;
"base:shortcut": contentLib.BaseShortcut;
"base:media": contentLib.BaseMedia;
"media:text": contentLib.BaseMedia;
"media:data": contentLib.BaseMedia;
"media:audio": contentLib.BaseMedia;
"media:video": contentLib.BaseMedia;
"media:image": contentLib.MediaImage;
"media:vector": contentLib.BaseMedia;
"media:archive": contentLib.BaseMedia;
"media:document": contentLib.BaseMedia;
"media:spreadsheet": contentLib.BaseMedia;
"media:presentation": contentLib.BaseMedia;
"media:code": contentLib.BaseMedia;
"media:executable": contentLib.BaseMedia;
"portal:site": contentLib.SiteData;
}
interface SiteConfig {
}
interface XData {
media?: {
imageInfo?: {
imageHeight: number;
imageWidth: number;
contentType: string;
pixelSize: number;
byteSize: number;
};
};
}
}
}
namespace contentLib {
type ContentTypeByName<ContentTypeName, FallbackType> = ContentTypeName extends keyof XP.ContentTypes ? XP.ContentTypes[ContentTypeName] : FallbackType;
type KeyOfContentType<Data> = import("./types").KeysOfType<XP.ContentTypes, Data>;
type LiteralContentTypeNames = import("./types").LiteralUnion<keyof XP.ContentTypes>;
interface ContentLibrary {

@@ -7,16 +46,16 @@ /**

*/
get<Data extends object, XData extends object = object>(params: GetContentParams): Content<Data, XData> | null;
get<Data>(params: GetContentParams): import("./types").WrapDataInContent<Data> | null;
/**
* This command queries content
*/
query<Data extends object = object, XData extends object = object>(params: QueryContentParams): QueryResponse<Data, XData, QueryResponseMetaDataScore>;
query<Data extends object = object, XData extends object = object>(params: QueryContentParamsWithSort): QueryResponse<Data, XData, QueryResponseMetaDataSort>;
query<Data, ContentTypeName extends LiteralContentTypeNames = KeyOfContentType<Data>>(params: QueryContentParams<ContentTypeName>): QueryResponse<ContentTypeByName<ContentTypeName, Data>>;
query<Data, ContentTypeName extends LiteralContentTypeNames = KeyOfContentType<Data>>(params: QueryContentParamsWithSort<ContentTypeName>): QueryResponseSorted<ContentTypeByName<ContentTypeName, Data>>;
/**
* This function creates a content.
*/
create<Data extends object, XData extends object = object>(params: CreateContentParams<Data, XData>): Content<Data, XData>;
create<Data, ContentTypeName extends LiteralContentTypeNames>(params: CreateContentParams<Data, ContentTypeName>): Content<ContentTypeByName<ContentTypeName, Data>>;
/**
* Modifies properties of a content
*/
modify<Data extends object, XData extends object = object>(params: ModifyContentParams<Data, XData>): Content<Data, XData>;
modify<Data>(params: ModifyContentParams<Data>): Content<Data>;
/**

@@ -41,3 +80,3 @@ * This function deletes a content

*/
getChildren<Data extends object, XData extends object>(params: GetChildrenParams): QueryResponse<Data, XData>;
getChildren<Data>(params: GetChildrenParams): QueryResponse<Data>;
/**

@@ -50,15 +89,16 @@ * This function returns the list of content items that are outbound dependencies of specified content.

*/
move<Data extends object = object, XData extends object = object>(params: MoveParams): Content<Data, XData>;
move<Data>(params: MoveParams): Content<Data>;
/**
* This function returns the parent site of a content
*/
getSite<Config extends object, XData extends object = object>(params: GetSiteParams): Site<Config, XData>;
getSite(params: GetSiteParams): Site;
/**
* This function returns the site configuration for this app in the parent site of a content
*/
getSiteConfig<Config extends object>(params: GetSiteConfigParams): Config;
getSiteConfig(params: GetSiteConfigParams): XP.SiteConfig;
/**
* Creates a media content
*/
createMedia<Data extends object>(params: CreateMediaParams): Content<Data>;
createMedia<Data = MediaImage>(params: CreateMediaImageParams): Content<Data>;
createMedia<Data>(params: CreateMediaParams): Content<Data>;
/**

@@ -114,3 +154,3 @@ * Adds an attachment to an existing content.

type WORKFLOW_STATES = "IN_PROGRESS" | "PENDING_APPROVAL" | "REJECTED" | "READY";
interface Content<Data extends object = object, XData extends object = object> {
interface Content<Data = unknown, Type extends KeyOfContentType<Data> = KeyOfContentType<Data>> {
readonly _id: string;

@@ -124,3 +164,3 @@ readonly _name: string;

owner: string;
type: string;
type: Type;
displayName: string;

@@ -131,5 +171,5 @@ readonly hasChildren: boolean;

childOrder: string;
data: Data;
data: Data extends XP.ContentTypes[Type] ? XP.ContentTypes[Type] : Data;
page: import("/lib/xp/portal").Component;
x: XData;
x: XP.XData;
attachments: Attachments;

@@ -142,10 +182,10 @@ publish?: ScheduleParams;

}
type Site<Config extends object, XData extends object = object> = Content<SiteData<Config>, XData>;
type SiteData<Config extends object> = {
type Site = Content<SiteData>;
type SiteData = {
description?: string;
siteConfig: SiteDataSiteConfig<Config> | Array<SiteDataSiteConfig<Config>>;
siteConfig: SiteDataSiteConfig | Array<SiteDataSiteConfig>;
};
interface SiteDataSiteConfig<Config> {
interface SiteDataSiteConfig {
applicationKey: string;
config: Config;
config: XP.SiteConfig;
}

@@ -245,3 +285,3 @@ /**

}
interface QueryContentParams {
interface QueryContentParams<ContentTypeName extends LiteralContentTypeNames> {
start?: number;

@@ -252,3 +292,3 @@ count: number;

aggregations?: Record<string, Aggregation>;
contentTypes?: Array<string>;
contentTypes?: Array<ContentTypeName>;
highlight?: Highlight;

@@ -405,3 +445,3 @@ }

type Direction = "ASC" | "DESC";
type QueryContentParamsWithSort = QueryContentParams & {
type QueryContentParamsWithSort<ContentTypeName extends LiteralContentTypeNames> = QueryContentParams<ContentTypeName> & {
sort: string | SortDSL;

@@ -427,5 +467,4 @@ };

}
interface QueryResponse<Data extends object, XData extends object, QueryMetaData extends QueryResponseMetaDataSort | QueryResponseMetaDataScore | {} = {}> {
interface BaseQueryResponse {
readonly count: number;
readonly hits: ReadonlyArray<Content<Data, XData> & QueryMetaData>;
readonly total: number;

@@ -435,9 +474,13 @@ readonly aggregations: Record<string, AggregationsResponseEntry>;

}
interface QueryResponseMetaDataSort {
readonly _score: null;
readonly _sort: Array<string>;
}
interface QueryResponseMetaDataScore {
readonly _score: number;
}
type QueryResponse<Data> = BaseQueryResponse & {
readonly hits: ReadonlyArray<import("./types").WrapDataInContent<Data, {
readonly _score: number;
}>>;
};
type QueryResponseSorted<Data> = BaseQueryResponse & {
readonly hits: ReadonlyArray<import("./types").WrapDataInContent<Data, {
readonly _score: null;
readonly _sort: Array<string>;
}>>;
};
type Aggregation = TermsAggregation | StatsAggregation | RangeAggregation | GeoDistanceAggregation | DateRangeAggregation | DateHistogramAggregation | MinAggregation | MaxAggregation | ValueCountAggregation;

@@ -600,3 +643,3 @@ interface TermsAggregation {

}
interface CreateContentParams<Data extends object, XData extends object> {
interface CreateContentParams<Data, ContentTypeName extends LiteralContentTypeNames> {
/**

@@ -633,3 +676,3 @@ * Name of content

*/
contentType: string;
contentType: ContentTypeName;
/**

@@ -646,9 +689,9 @@ * The language tag representing the content’s locale

*/
data: Data;
data: ContentTypeByName<ContentTypeName, Data>;
/**
* eXtra data to use
*/
x?: XData;
x?: XP.XData;
}
interface ModifyContentParams<Data extends object, XData extends object = object> {
interface ModifyContentParams<Data> {
/**

@@ -661,3 +704,3 @@ * Path or id to the content

*/
editor: (c: Content<Data, XData>) => Content<Data, XData>;
editor: (c: Content<Data>) => Content<Data>;
/**

@@ -727,8 +770,10 @@ * The content has to be valid, according to the content type, to be updated.

name: string;
parentPath: string;
parentPath?: string;
mimeType?: string;
focalX?: number;
focalY?: number;
data: ByteSource;
}
type CreateMediaImageParams = CreateMediaParams & {
focalX: number;
focalY: number;
};
interface AddAttachmentParams {

@@ -735,0 +780,0 @@ key: string;

{
"name": "enonic-types",
"sideEffects": false,
"version": "0.4.9",
"version": "0.5.0-next.0",
"description": "TypeScript types for Enonic XP",

@@ -32,10 +32,10 @@ "typings": "index.d.ts",

"copyfiles": "^2.4.1",
"eslint": "^8.17.0",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"json-schema-to-typescript": "^10.1.5",
"prettier": "^2.7.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"typescript": "^4.7.3"
"typescript": "^4.7.4"
}
}

@@ -8,3 +8,3 @@ declare module "*/lib/xp/portal" {

*/
getComponent<Config extends object = never>(): Component<Config>;
getComponent<Config = unknown>(): Component<Config>;
/**

@@ -14,3 +14,5 @@ * his function returns the content corresponding to the current execution context. It is meant to be called from a

*/
getContent<Data extends object = object, XData extends object = object>(): import("/lib/xp/content").Content<Data, XData>;
getContent<Data, PageConfig = unknown>(): import("./types").WrapDataInContent<Data, {
page: Component<PageConfig>;
}>;
/**

@@ -40,3 +42,3 @@ * This function returns the id provider key corresponding to the current execution context.

*/
getSite<Config extends object>(): import("/lib/xp/content").Site<Config>;
getSite(): import("/lib/xp/content").Site;
/**

@@ -46,3 +48,3 @@ * This function returns the site configuration for this app in the parent site of the content corresponding to the

*/
getSiteConfig<Config>(): Config;
getSiteConfig(): XP.SiteConfig;
/**

@@ -49,0 +51,0 @@ * This function generates a URL pointing to an ID provider.

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

import { Content, KeyOfContentType } from "*/lib/xp/content";
export declare type EmptyObject = Record<string, never>;

@@ -18,1 +19,6 @@ export declare type Without<T, U> = {

};
export declare type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
export declare type KeysOfType<O, T> = {
[K in keyof O]: Required<O[K]> extends Required<T> ? K : never;
}[keyof O];
export declare type WrapDataInContent<Data, Meta = {}> = Data extends any ? Content<Data, KeyOfContentType<Data>> & Meta : never;
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