enonic-types
Advanced tools
Comparing version 0.2.4 to 0.2.5
import { Region } from "./portal"; | ||
declare type EmptyObject = Record<string, never>; | ||
export declare type EmptyObject = Record<string, never>; | ||
export interface ContentLibrary { | ||
@@ -632,2 +632,1 @@ /** | ||
} | ||
export {}; |
import { RunContext } from "./context"; | ||
import { XOR } from "./types"; | ||
/** | ||
* @deprecated since 7.7.0 Please use {@link SchedulerLibrary}. | ||
* Since 7.7.0 you can use {@link SchedulerLibrary} to be safe for custers | ||
* https://discuss.enonic.com/t/scheduler-task-and-cron-what-to-use-where/2539/6 | ||
*/ | ||
@@ -6,0 +7,0 @@ export interface CronLibrary { |
@@ -18,4 +18,7 @@ import { Aggregation, AggregationsResponse, BasicFilters, BooleanFilter, ByteSource, Highlight, PermissionsParams } from "./content"; | ||
} | ||
export declare type SourceWithPrincipals = Omit<Source, "principals"> & { | ||
principals: Array<string>; | ||
}; | ||
export interface MultiRepoConnectParams { | ||
sources: Array<Source>; | ||
sources: Array<SourceWithPrincipals>; | ||
} | ||
@@ -26,2 +29,6 @@ export interface NodeQueryHit { | ||
} | ||
export interface MultiRepoNodeQueryHit extends NodeQueryHit { | ||
readonly repoId: string; | ||
readonly branch: string; | ||
} | ||
export interface NodeQueryResponse<AggregationKeys extends string = never> { | ||
@@ -33,2 +40,5 @@ readonly total: number; | ||
} | ||
export declare type MultiRepoNodeQueryResponse<AggregationKeys extends string = never> = Omit<NodeQueryResponse<AggregationKeys>, "hits"> & { | ||
hits: ReadonlyArray<MultiRepoNodeQueryHit>; | ||
}; | ||
export interface GetBinaryParams { | ||
@@ -44,3 +54,3 @@ /** | ||
} | ||
export interface NodeQueryParams<AggregationKeys extends string> { | ||
export interface NodeQueryParams<AggregationKeys extends string = never> { | ||
/** | ||
@@ -57,3 +67,3 @@ * Start index (used for paging). | ||
*/ | ||
readonly query: string; | ||
readonly query?: string; | ||
/** | ||
@@ -203,19 +213,6 @@ * Query filters | ||
} | ||
/** | ||
* Common interface for MultiRepoConnection and RepoConnection | ||
*/ | ||
export interface QueryableRepoConnection { | ||
/** | ||
* This command queries nodes. | ||
*/ | ||
query<AggregationKeys extends string = never>(params: NodeQueryParams<AggregationKeys>): NodeQueryResponse<AggregationKeys>; | ||
export interface MultiRepoConnection { | ||
query<AggregationKeys extends string>(params: NodeQueryParams<AggregationKeys>): MultiRepoNodeQueryResponse<AggregationKeys>; | ||
} | ||
/** | ||
* A MultiRepoConnection makes it possible to search across multiple repositories. The object has only one method: query. | ||
*/ | ||
export declare type MultiRepoConnection = QueryableRepoConnection; | ||
/** | ||
* A single repo connections with lots of methods to work on the repo | ||
*/ | ||
export interface RepoConnection extends QueryableRepoConnection { | ||
export interface RepoConnection { | ||
/** | ||
@@ -277,2 +274,6 @@ * Commits the active version of nodes. | ||
/** | ||
* This command queries nodes. | ||
*/ | ||
query<AggregationKeys extends string = never>(params: NodeQueryParams<AggregationKeys>): NodeQueryResponse<AggregationKeys>; | ||
/** | ||
* Refresh the index for the current repoConnection | ||
@@ -279,0 +280,0 @@ */ |
{ | ||
"name": "enonic-types", | ||
"sideEffects": false, | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "TypeScript types for Enonic XP", | ||
@@ -6,0 +6,0 @@ "typings": "index.d.ts", |
@@ -40,6 +40,8 @@ # TypeScript types for Enonic XP | ||
import { Article } from "../../site/content-types/article/article"; // 1 | ||
import contentLib from "/lib/xp/content"; // 2 | ||
import * as contentLib from "/lib/xp/content"; // 2 | ||
export function get(req: Request): Response { // 3 | ||
const content = contentLib.get<Article>({ key: req.params.id! }); | ||
const content = contentLib.get<Article>({ | ||
key: req.params.id! | ||
}); | ||
@@ -49,5 +51,10 @@ if (content !== null) { // 4 | ||
return { status: 200, body: article } | ||
return { | ||
status: 200, | ||
body: article | ||
} | ||
} else { | ||
return { status: 404 }; | ||
return { | ||
status: 404 | ||
}; | ||
} | ||
@@ -54,0 +61,0 @@ } |
147
repo.d.ts
@@ -1,26 +0,56 @@ | ||
import { PermissionsParams } from "./content"; | ||
import { ByteSource, EmptyObject, PermissionsParams } from "./content"; | ||
export interface RepoLibrary { | ||
create(params: CreateRepoParams): RepositoryConfig; | ||
createBranch(params: CreateBranchParams): RepositoryConfig; | ||
get(id: string): RepositoryConfig | null; | ||
list(): ReadonlyArray<RepositoryConfig>; | ||
/** | ||
* Creates a repository. | ||
*/ | ||
create(params: CreateRepoParams): RepositoryConfig<EmptyObject>; | ||
/** | ||
* Creates a branch | ||
*/ | ||
createBranch(params: CreateBranchParams): BranchConfig; | ||
/** | ||
* Retrieves a repository | ||
*/ | ||
get<Data = unknown>(id: string): RepositoryConfig<Data> | null; | ||
/** | ||
* Retrieves the list of repositories | ||
*/ | ||
list<Data>(): ReadonlyArray<RepositoryConfig<Data>>; | ||
/** | ||
* Deletes a repository | ||
*/ | ||
delete(id: string): boolean; | ||
deleteBranch(params: DeleteBranchParams): any; | ||
refresh(params: RefreshParams): ReadonlyArray<RepositoryConfig>; | ||
/** | ||
* Deletes a branch | ||
*/ | ||
deleteBranch(params: DeleteBranchParams): BranchConfig; | ||
/** | ||
* Refresh the data for the given index-type in the current repository | ||
*/ | ||
refresh(params: RefreshParams): ReadonlyArray<unknown>; | ||
/** | ||
* Updates a repository | ||
*/ | ||
modify<Data>(params: ModifyParams<Data>): RepositoryConfig<Data>; | ||
/** | ||
* This function returns a data-stream for the specified repository attachment. | ||
*/ | ||
getBinary(params: GetBinaryParams): ByteSource; | ||
} | ||
export interface IndexDefinition { | ||
settings: any; | ||
mapping: any; | ||
} | ||
export interface CreateRepoParams { | ||
id: string; | ||
rootPermissions?: ReadonlyArray<PermissionsParams>; | ||
settings?: { | ||
definitions?: { | ||
search?: IndexDefinition; | ||
version?: IndexDefinition; | ||
branch?: IndexDefinition; | ||
}; | ||
settings?: RepositorySettings; | ||
} | ||
export interface RepositorySettings { | ||
definitions?: { | ||
search?: IndexDefinition; | ||
version?: IndexDefinition; | ||
branch?: IndexDefinition; | ||
}; | ||
} | ||
export interface IndexDefinition { | ||
settings: ElasticSearchIndexSettings; | ||
mapping: any; | ||
} | ||
export interface CreateBranchParams { | ||
@@ -30,9 +60,13 @@ branchId: string; | ||
} | ||
export interface RepositoryConfig { | ||
export interface RepositoryConfig<Data> { | ||
readonly id: string; | ||
readonly branches: ReadonlyArray<string>; | ||
readonly settings: any; | ||
readonly settings: RepositorySettings; | ||
readonly data: Data; | ||
} | ||
export interface BranchConfig { | ||
readonly id: string; | ||
} | ||
export interface RefreshParams { | ||
mode?: string; | ||
mode?: "all" | "search" | "storage"; | ||
repo?: string; | ||
@@ -45,1 +79,74 @@ branch?: string; | ||
} | ||
export interface ModifyParams<Data> { | ||
id: string; | ||
scope: string; | ||
editor: (config: RepositoryConfig<Data>) => RepositoryConfig<Data>; | ||
} | ||
export interface GetBinaryParams { | ||
repoId: string; | ||
binaryReference: string; | ||
} | ||
export interface ElasticSearchIndexSettings { | ||
index?: { | ||
number_of_shards?: number; | ||
number_of_routing_shards?: number; | ||
check_on_startup?: boolean; | ||
codec?: unknown; | ||
routing_partition_size?: number; | ||
soft_deletes?: { | ||
enabled?: boolean; | ||
retention_lease?: { | ||
period?: string; | ||
}; | ||
}; | ||
load_fixed_bitset_filters_eagerly?: boolean; | ||
hidden?: boolean; | ||
number_of_replicas?: number; | ||
auto_expand_replicas?: string | false; | ||
search?: { | ||
idle?: { | ||
after?: string; | ||
}; | ||
}; | ||
refresh_interval?: string; | ||
max_result_window?: number; | ||
max_inner_result_window?: number; | ||
max_rescore_window?: number; | ||
max_docvalue_fields_search?: number; | ||
max_script_fields?: number; | ||
max_ngram_diff?: number; | ||
max_shingle_diff?: number; | ||
max_refresh_listeners?: number; | ||
analyze?: { | ||
max_token_count?: number; | ||
}; | ||
highlight?: { | ||
max_analyzed_offset?: number; | ||
}; | ||
max_terms_count?: number; | ||
max_regex_length?: number; | ||
query?: { | ||
default_field?: string; | ||
}; | ||
routing?: { | ||
allocation?: { | ||
enable?: "all" | "primaries" | "new_primaries" | "none"; | ||
}; | ||
rebalance?: { | ||
enable?: "all" | "primaries" | "new_primaries" | "none"; | ||
}; | ||
}; | ||
gc_deletes?: string; | ||
default_pipeline?: string; | ||
final_pipeline?: string; | ||
}; | ||
analysis?: { | ||
analyzer?: Record<string, { | ||
type?: "standard" | "simple" | "whitespace" | "stop" | "keyword" | "pattern" | "fingerprint" | "custom" | string; | ||
tokenizer?: string; | ||
char_filter?: Array<string>; | ||
filter?: Array<string>; | ||
position_increment_gap?: number; | ||
}>; | ||
}; | ||
} |
126344
4021
125