enonic-types
Advanced tools
Comparing version 0.5.0-next.0 to 0.5.0-next.1
@@ -5,18 +5,19 @@ declare module "*/lib/xp/content" { | ||
interface ContentTypes { | ||
"base:unstructured": Record<string, never>; | ||
"base:folder": Record<string, never>; | ||
"base:unstructured": contentLib.BaseUnstructured; | ||
"base:structured": contentLib.BaseStructured; | ||
"base:folder": contentLib.BaseFolder; | ||
"base:shortcut": contentLib.BaseShortcut; | ||
"base:media": contentLib.BaseMedia; | ||
"media:text": contentLib.BaseMedia; | ||
"media:data": contentLib.BaseMedia; | ||
"media:audio": contentLib.BaseMedia; | ||
"media:video": contentLib.BaseMedia; | ||
"base:media": contentLib.BaseMedia<"base_Media_Data">; | ||
"media:audio": contentLib.BaseMedia<"media_Audio_Data">; | ||
"media:text": contentLib.BaseMedia<"media_Text_Data">; | ||
"media:data": contentLib.BaseMedia<"media_Data_Data">; | ||
"media:video": contentLib.BaseMedia<"media_Video_Data">; | ||
"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; | ||
"media:vector": contentLib.BaseMedia<"media_Vector_Data">; | ||
"media:archive": contentLib.BaseMedia<"media_Archive_Data">; | ||
"media:document": contentLib.BaseMedia<"media_Document_Data">; | ||
"media:spreadsheet": contentLib.BaseMedia<"media_Spreadsheet_Data">; | ||
"media:presentation": contentLib.BaseMedia<"media_Presentation_Data">; | ||
"media:code": contentLib.BaseMedia<"media_Code_Data">; | ||
"media:executable": contentLib.BaseMedia<"media_Executable_Data">; | ||
"portal:site": contentLib.SiteData; | ||
@@ -41,3 +42,4 @@ } | ||
type ContentTypeByName<ContentTypeName, FallbackType> = ContentTypeName extends keyof XP.ContentTypes ? XP.ContentTypes[ContentTypeName] : FallbackType; | ||
type KeyOfContentType<Data> = import("./types").KeysOfType<XP.ContentTypes, Data>; | ||
type KeysOfType<O, T> = import("./types").KeysOfType<O, T>; | ||
type KeyOfContentType<Data> = KeysOfType<XP.ContentTypes, Data> extends never ? string : KeysOfType<XP.ContentTypes, Data>; | ||
type LiteralContentTypeNames = import("./types").LiteralUnion<keyof XP.ContentTypes>; | ||
@@ -153,3 +155,3 @@ interface ContentLibrary { | ||
type WORKFLOW_STATES = "IN_PROGRESS" | "PENDING_APPROVAL" | "REJECTED" | "READY"; | ||
interface Content<Data = unknown, Type extends KeyOfContentType<Data> = KeyOfContentType<Data>> { | ||
interface Content<Data = unknown, Type extends string = KeyOfContentType<Data>> { | ||
readonly _id: string; | ||
@@ -169,3 +171,3 @@ readonly _name: string; | ||
childOrder: string; | ||
data: Data extends XP.ContentTypes[Type] ? XP.ContentTypes[Type] : Data; | ||
data: Type extends keyof XP.ContentTypes ? Data extends XP.ContentTypes[Type] ? XP.ContentTypes[Type] : Data : Data; | ||
page: import("/lib/xp/portal").Component; | ||
@@ -182,2 +184,3 @@ x: XP.XData; | ||
type SiteData = { | ||
__typename?: "portal_Site_Data"; | ||
description?: string; | ||
@@ -194,2 +197,3 @@ siteConfig: SiteDataSiteConfig | Array<SiteDataSiteConfig>; | ||
interface BaseShortcut { | ||
__typename?: "base_Shortcut_Data"; | ||
target: string; | ||
@@ -203,5 +207,24 @@ parameters?: Array<BaseShortcutParameter> | BaseShortcutParameter; | ||
/** | ||
* Implements the "data" of type "base:unstructured" | ||
*/ | ||
interface BaseUnstructured { | ||
__typename?: "base_Unstructured_Data"; | ||
} | ||
/** | ||
* Implements the "data" of type "base:structured" | ||
*/ | ||
interface BaseStructured { | ||
__typename?: "base_Structured_Data"; | ||
} | ||
/** | ||
* Implements the "data" of type "base:folder" | ||
*/ | ||
interface BaseFolder { | ||
__typename?: "base_Folder_Data"; | ||
} | ||
/** | ||
* Implements the "data" of type "base:media" | ||
*/ | ||
interface BaseMedia<Media extends object = BaseMediaConfig> { | ||
interface BaseMedia<TypeName extends string, Media extends object = BaseMediaConfig> { | ||
__typename?: TypeName; | ||
media: Media; | ||
@@ -219,3 +242,3 @@ caption?: string; | ||
*/ | ||
interface MediaImage extends BaseMedia<ImageConfig> { | ||
interface MediaImage extends BaseMedia<"media_Image_Data", ImageConfig> { | ||
altText?: string; | ||
@@ -222,0 +245,0 @@ } |
@@ -17,2 +17,3 @@ /// <reference path="admin.d.ts" /> | ||
/// <reference path="graphql.d.ts" /> | ||
/// <reference path="grid.d.ts" /> | ||
/// <reference path="guillotine.d.ts" /> | ||
@@ -19,0 +20,0 @@ /// <reference path="http.d.ts" /> |
@@ -25,2 +25,3 @@ export interface EnonicLibraryMap { | ||
"/lib/graphql-playground": typeof import("/lib/graphql-playground"); | ||
"/lib/xp/grid": typeof import("/lib/xp/grid"); | ||
"/lib/guillotine": typeof import("/lib/guillotine"); | ||
@@ -27,0 +28,0 @@ "/lib/http-client": typeof import("/lib/http-client"); |
{ | ||
"name": "enonic-types", | ||
"sideEffects": false, | ||
"version": "0.5.0-next.0", | ||
"version": "0.5.0-next.1", | ||
"description": "TypeScript types for Enonic XP", | ||
@@ -29,13 +29,14 @@ "typings": "index.d.ts", | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.28.0", | ||
"@typescript-eslint/parser": "^5.28.0", | ||
"@typescript-eslint/eslint-plugin": "^5.30.0", | ||
"@typescript-eslint/parser": "^5.30.0", | ||
"copyfiles": "^2.4.1", | ||
"eslint": "^8.18.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"json-schema-to-typescript": "^10.1.5", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"json-schema-to-typescript": "^11.0.0", | ||
"prettier": "^2.7.1", | ||
"rimraf": "^3.0.2", | ||
"tsd": "^0.22.0", | ||
"typescript": "^4.7.4" | ||
} | ||
} |
@@ -142,2 +142,3 @@ # TypeScript types for Enonic XP | ||
* [GraphQLLibrary](./src/graphql.ts) | ||
* [GridLibrary](./src/grid.ts) | ||
* [GuillotineLibrary](./src/guillotine.ts) | ||
@@ -144,0 +145,0 @@ * [HttpLibrary](./src/http.ts) |
@@ -21,4 +21,4 @@ import { Content, KeyOfContentType } from "*/lib/xp/content"; | ||
export declare type KeysOfType<O, T> = { | ||
[K in keyof O]: Required<O[K]> extends Required<T> ? K : never; | ||
[K in keyof O]: O[K] extends T ? K : never; | ||
}[keyof O]; | ||
export declare type WrapDataInContent<Data, Meta = {}> = Data extends any ? Content<Data, KeyOfContentType<Data>> & Meta : never; |
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
283964
65
7710
171
11