enonic-types
Advanced tools
Comparing version 0.3.23 to 0.4.0
@@ -7,16 +7,16 @@ declare module "*/lib/xp/content" { | ||
*/ | ||
get<Data extends object, XData extends object = object>(params: GetContentParams): Content<Data, import("./types").EmptyObject, XData> | null; | ||
get<Data extends object, XData extends object = object>(params: GetContentParams): Content<Data, XData> | null; | ||
/** | ||
* This command queries content | ||
*/ | ||
query<Data extends object, AggregationKeys extends string = never>(params: QueryContentParams<AggregationKeys>): QueryResponse<Data, AggregationKeys, QueryResponseMetaDataScore>; | ||
query<Data extends object, AggregationKeys extends string = never>(params: QueryContentParamsWithSort<AggregationKeys>): QueryResponse<Data, AggregationKeys, QueryResponseMetaDataSort>; | ||
query<Data extends object, XData extends object, AggregationKeys extends string = never>(params: QueryContentParams<AggregationKeys>): QueryResponse<Data, XData, QueryResponseMetaDataScore, AggregationKeys>; | ||
query<Data extends object, XData extends object, AggregationKeys extends string = never>(params: QueryContentParamsWithSort<AggregationKeys>): QueryResponse<Data, XData, QueryResponseMetaDataSort, AggregationKeys>; | ||
/** | ||
* This function creates a content. | ||
*/ | ||
create<Data extends object>(params: CreateContentParams<Data>): Content<Data>; | ||
create<Data extends object, XData extends object = object>(params: CreateContentParams<Data, XData>): Content<Data, XData>; | ||
/** | ||
* Modifies properties of a content | ||
*/ | ||
modify<Data extends object, PageConfig extends object = object, XData extends object = object>(params: ModifyContentParams<Data, PageConfig, XData>): Content<Data, PageConfig, XData>; | ||
modify<Data extends object, XData extends object = object>(params: ModifyContentParams<Data, XData>): Content<Data, XData>; | ||
/** | ||
@@ -41,3 +41,3 @@ * This function deletes a content | ||
*/ | ||
getChildren<Data extends object>(params: GetChildrenParams): QueryResponse<Data>; | ||
getChildren<Data extends object, XData extends object>(params: GetChildrenParams): QueryResponse<Data, XData>; | ||
/** | ||
@@ -50,7 +50,7 @@ * This function returns the list of content items that are outbound dependencies of specified content. | ||
*/ | ||
move<Data extends object>(params: MoveParams): Content<Data>; | ||
move<Data extends object = object, XData extends object = object>(params: MoveParams): Content<Data, XData>; | ||
/** | ||
* This function returns the parent site of a content | ||
*/ | ||
getSite<Config extends object, PageConfig extends object = never>(params: GetSiteParams): Site<Config, PageConfig>; | ||
getSite<Config extends object, XData extends object = object>(params: GetSiteParams): Site<Config, XData>; | ||
/** | ||
@@ -114,3 +114,3 @@ * This function returns the site configuration for this app in the parent site of a content | ||
type WORKFLOW_STATES = "IN_PROGRESS" | "PENDING_APPROVAL" | "REJECTED" | "READY"; | ||
interface Content<Data extends object = object, PageConfig extends object = object, XData extends object = object> { | ||
interface Content<Data extends object = object, XData extends object = object> { | ||
readonly _id: string; | ||
@@ -131,4 +131,4 @@ readonly _name: string; | ||
data: Data; | ||
x: Record<string, Record<string, XData>>; | ||
page: Page<PageConfig>; | ||
page: import("/lib/xp/portal").Component; | ||
x: XData; | ||
attachments: Attachments; | ||
@@ -141,2 +141,6 @@ publish?: ScheduleParams; | ||
} | ||
type Site<Config extends object, XData extends object = object> = Content<SiteData<Config>, XData>; | ||
type SiteData<Config extends object> = { | ||
siteConfig: SiteConfig<Config> | Array<SiteConfig<Config>>; | ||
}; | ||
/** | ||
@@ -193,9 +197,2 @@ * Implements the "data" of type "base:shortcut" | ||
} | ||
interface Page<Config> { | ||
readonly type: string; | ||
readonly path: string; | ||
readonly descriptor: string; | ||
readonly config: Config; | ||
readonly regions: Record<string, import("/lib/xp/portal").Region>; | ||
} | ||
interface Attachment { | ||
@@ -251,5 +248,5 @@ name: string; | ||
}; | ||
interface QueryResponse<Data extends object, AggregationKeys extends string = never, QueryMetaData extends QueryResponseMetaDataSort | QueryResponseMetaDataScore | {} = {}> { | ||
interface QueryResponse<Data extends object, XData extends object, QueryMetaData extends QueryResponseMetaDataSort | QueryResponseMetaDataScore | {} = {}, AggregationKeys extends string = never> { | ||
readonly count: number; | ||
readonly hits: ReadonlyArray<Content<Data, import("./types").EmptyObject> & QueryMetaData>; | ||
readonly hits: ReadonlyArray<Content<Data, XData> & QueryMetaData>; | ||
readonly total: number; | ||
@@ -423,3 +420,3 @@ readonly aggregations: AggregationsResponse<AggregationKeys>; | ||
} | ||
interface CreateContentParams<Data> { | ||
interface CreateContentParams<Data extends object, XData extends object> { | ||
/** | ||
@@ -472,5 +469,5 @@ * Name of content | ||
*/ | ||
x?: Record<string, any>; | ||
x?: XData; | ||
} | ||
interface ModifyContentParams<Data extends object, PageConfig extends object = object, XData extends object = object> { | ||
interface ModifyContentParams<Data extends object, XData extends object = object> { | ||
/** | ||
@@ -483,3 +480,3 @@ * Path or id to the content | ||
*/ | ||
editor: (c: Content<Data, PageConfig, XData>) => Content<Data, PageConfig, XData>; | ||
editor: (c: Content<Data, XData>) => Content<Data, XData>; | ||
/** | ||
@@ -531,17 +528,2 @@ * The content has to be valid, according to the content type, to be updated. | ||
} | ||
interface Site<Config extends object, PageConfig extends object = never, XData extends object = object> { | ||
readonly _id: string; | ||
readonly _name: string; | ||
readonly _path: string; | ||
type: string; | ||
readonly hasChildren: boolean; | ||
readonly valid: boolean; | ||
data: { | ||
siteConfig: SiteConfig<Config> | Array<SiteConfig<Config>>; | ||
}; | ||
x: Record<string, Record<string, XData>>; | ||
page: Page<PageConfig>; | ||
attachments: Attachments; | ||
publish: ScheduleParams; | ||
} | ||
interface SiteConfig<Config> { | ||
@@ -548,0 +530,0 @@ applicationKey: string; |
@@ -49,11 +49,12 @@ declare module "*/lib/xp/event" { | ||
interface EnonicEventData { | ||
readonly nodes: ReadonlyArray<{ | ||
readonly id: string; | ||
readonly path: string; | ||
readonly branch: string; | ||
readonly repo: string; | ||
readonly newPath?: string; | ||
}>; | ||
readonly nodes: ReadonlyArray<EnonicEventDataNode>; | ||
readonly state?: string; | ||
} | ||
interface EnonicEventDataNode { | ||
readonly id: string; | ||
readonly path: string; | ||
readonly branch: string; | ||
readonly repo: string; | ||
readonly newPath?: string; | ||
} | ||
type EnonicEventTypes = "node.created" | "node.deleted" | "node.pushed" | "node.duplicated" | "node.updated" | "node.moved" | "node.renamed" | "node.sorted" | "node.stateUpdated" | "node.permissionsUpdated"; | ||
@@ -60,0 +61,0 @@ } |
@@ -15,3 +15,3 @@ declare module "*/lib/menu" { | ||
*/ | ||
getSubMenus(parentContent: import("/lib/xp/content").Content<any> | import("/lib/xp/content").Site<any>, levels?: number, params?: GetMenuParams): Array<MenuItem>; | ||
getSubMenus(parentContent: import("/lib/xp/content").Content, levels?: number, params?: GetMenuParams): Array<MenuItem>; | ||
} | ||
@@ -18,0 +18,0 @@ interface MenuTree { |
{ | ||
"name": "enonic-types", | ||
"sideEffects": false, | ||
"version": "0.3.23", | ||
"version": "0.4.0", | ||
"description": "TypeScript types for Enonic XP", | ||
@@ -36,6 +36,6 @@ "typings": "index.d.ts", | ||
"json-schema-to-typescript": "^10.1.5", | ||
"prettier": "^2.6.0", | ||
"prettier": "^2.6.1", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.6.2" | ||
"typescript": "^4.6.3" | ||
} | ||
} |
@@ -13,3 +13,3 @@ declare module "*/lib/xp/portal" { | ||
*/ | ||
getContent<Data extends object, PageConfig extends object = never>(): import("/lib/xp/content").Content<Data, PageConfig>; | ||
getContent<Data extends object = object, XData extends object = object>(): import("/lib/xp/content").Content<Data, XData>; | ||
/** | ||
@@ -106,3 +106,3 @@ * This function returns the id provider key corresponding to the current execution context. | ||
}; | ||
interface Component<Config> { | ||
interface Component<Config = unknown> { | ||
readonly path: string; | ||
@@ -115,3 +115,3 @@ readonly type: string; | ||
interface Region { | ||
components: Array<Component<unknown>>; | ||
components: Array<Component>; | ||
name: string; | ||
@@ -118,0 +118,0 @@ } |
@@ -14,3 +14,3 @@ declare module "*/lib/enonic/react4xp" { | ||
*/ | ||
entry: string | import("/lib/xp/portal").Component<unknown>, | ||
entry: string | import("/lib/xp/portal").Component, | ||
/** | ||
@@ -17,0 +17,0 @@ * Data model passed into the react component. |
269074
7288