@enonic-types/lib-content 7.11.3 → 7.12.0-RC1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/content.d.ts +71 -352
  2. package/package.json +2 -2
package/content.d.ts CHANGED
@@ -13,8 +13,8 @@ declare global {
13
13
  interface XpXData {
14
14
  }
15
15
  }
16
- import type { ByteSource, Content, PublishInfo } from '@enonic-types/core';
17
- export type { Attachment, ByteSource, PublishInfo, Content, Component, Region, } from '@enonic-types/core';
16
+ import type { Aggregations, AggregationsResult, AggregationsToAggregationResults, ByteSource, Content, Filter, FormItem, Highlight, HighlightResult, PublishInfo, QueryDsl, SortDsl } from '@enonic-types/core';
17
+ export type { Aggregation, Aggregations, AggregationsResult, Attachment, BooleanDslExpression, BooleanFilter, BucketsAggregationResult, BucketsAggregationsUnion, ByteSource, Component, Content, DateBucket, DateHistogramAggregation, DateRange, DateRangeAggregation, ExistsDslExpression, ExistsFilter, Filter, FormItem, FormItemInlineMixin, FormItemInput, FormItemLayout, FormItemOptionSet, FormItemSet, FulltextDslExpression, GeoDistanceAggregation, HasValueFilter, Highlight, HighlightResult, HistogramAggregation, IdsFilter, InDslExpression, LikeDslExpression, MatchAllDslExpression, MaxAggregation, MinAggregation, NgramDslExpression, NotExistsFilter, NumericRange, NumericRangeAggregation, PathMatchDslExpression, PublishInfo, QueryDsl, RangeDslExpression, Region, SingleValueMetricAggregationResult, SingleValueMetricAggregationsUnion, StatsAggregation, StatsAggregationResult, StemmedDslExpression, TermDslExpression, TermsAggregation, ValueCountAggregation, } from '@enonic-types/core';
18
18
  declare type Attachments = Content['attachments'];
19
19
  declare type ContentInheritType = Content['inherit'];
20
20
  declare type Workflow = Content['workflow'];
@@ -25,346 +25,6 @@ export interface GetContentParams {
25
25
  key: string;
26
26
  versionId?: string | null;
27
27
  }
28
- export interface Bucket {
29
- [subAggregationName: string]: AggregationsResult | string | number | undefined;
30
- key: string;
31
- docCount: number;
32
- }
33
- export interface NumericBucket extends Bucket {
34
- from?: number;
35
- to?: number;
36
- }
37
- export interface DateBucket extends Bucket {
38
- from?: string;
39
- to?: string;
40
- }
41
- export interface BucketsAggregationResult {
42
- buckets: (DateBucket | NumericBucket)[];
43
- }
44
- export interface StatsAggregationResult {
45
- count: number;
46
- min: number;
47
- max: number;
48
- avg: number;
49
- sum: number;
50
- }
51
- export interface SingleValueMetricAggregationResult {
52
- value: number;
53
- }
54
- export declare type AggregationsResult = BucketsAggregationResult | StatsAggregationResult | SingleValueMetricAggregationResult;
55
- export declare type Aggregation = TermsAggregation | HistogramAggregation | DateHistogramAggregation | NumericRangeAggregation | DateRangeAggregation | StatsAggregation | GeoDistanceAggregation | MinAggregation | MaxAggregation | ValueCountAggregation;
56
- export interface TermsAggregation {
57
- terms: {
58
- field: string;
59
- order?: string;
60
- size?: number;
61
- minDocCount?: number;
62
- };
63
- aggregations?: Record<string, Aggregation>;
64
- }
65
- export interface HistogramAggregation {
66
- histogram: {
67
- field: string;
68
- order?: string;
69
- interval?: number;
70
- extendedBoundMin?: number;
71
- extendedBoundMax?: number;
72
- minDocCount?: number;
73
- };
74
- aggregations?: Record<string, Aggregation>;
75
- }
76
- export interface DateHistogramAggregation {
77
- dateHistogram: {
78
- field: string;
79
- interval?: string;
80
- minDocCount?: number;
81
- format: string;
82
- };
83
- aggregations?: Record<string, Aggregation>;
84
- }
85
- export interface NumericRange {
86
- from?: number;
87
- to?: number;
88
- key?: string;
89
- }
90
- export interface NumericRangeAggregation {
91
- range: {
92
- field: string;
93
- ranges?: NumericRange[];
94
- };
95
- aggregations?: Record<string, Aggregation>;
96
- }
97
- export interface NumericRangeAggregation {
98
- range: {
99
- field: string;
100
- ranges?: NumericRange[];
101
- };
102
- aggregations?: Record<string, Aggregation>;
103
- }
104
- export interface DateRange {
105
- from?: string;
106
- to?: string;
107
- key?: string;
108
- }
109
- export interface DateRangeAggregation {
110
- dateRange: {
111
- field: string;
112
- format: string;
113
- ranges: DateRange[];
114
- };
115
- aggregations?: Record<string, Aggregation>;
116
- }
117
- export interface StatsAggregation {
118
- stats: {
119
- field: string;
120
- };
121
- }
122
- export interface GeoDistanceAggregation {
123
- geoDistance: {
124
- field: string;
125
- unit: string;
126
- origin?: {
127
- lat: string;
128
- lon: string;
129
- };
130
- ranges?: NumericRange[];
131
- };
132
- }
133
- export interface MinAggregation {
134
- min: {
135
- field: string;
136
- };
137
- }
138
- export interface MaxAggregation {
139
- max: {
140
- field: string;
141
- };
142
- }
143
- export interface ValueCountAggregation {
144
- count: {
145
- field: string;
146
- };
147
- }
148
- export interface Highlight {
149
- encoder?: 'default' | 'html';
150
- tagsSchema?: 'styled';
151
- fragmenter?: 'simple' | 'span';
152
- fragmentSize?: number;
153
- noMatchSize?: number;
154
- numberOfFragments?: number;
155
- order?: 'score' | 'none';
156
- preTag?: string;
157
- postTag?: string;
158
- requireFieldMatch?: boolean;
159
- properties?: Record<string, Highlight>;
160
- }
161
- export interface HighlightResult {
162
- [highlightedFieldName: string]: string[];
163
- }
164
- export interface ExistsFilter {
165
- exists: {
166
- field: string;
167
- };
168
- }
169
- export interface NotExistsFilter {
170
- notExists: {
171
- field: string;
172
- };
173
- }
174
- export interface HasValueFilter {
175
- hasValue: {
176
- field: string;
177
- values: unknown[];
178
- };
179
- }
180
- export interface IdsFilter {
181
- ids: {
182
- values: string[];
183
- };
184
- }
185
- export interface BooleanFilter {
186
- boolean: {
187
- must?: Filter[];
188
- mustNot?: Filter[];
189
- should?: Filter[];
190
- };
191
- }
192
- export declare type Filter = ExistsFilter | NotExistsFilter | HasValueFilter | IdsFilter | BooleanFilter;
193
- export declare type FormItemType = 'Input' | 'ItemSet' | 'Layout' | 'OptionSet';
194
- export declare type InputType = 'Time' | 'DateTime' | 'CheckBox' | 'ComboBox' | 'Long' | 'Double' | 'RadioButton' | 'TextArea' | 'ContentTypeFilter' | 'GeoPoint' | 'TextLine' | 'Tag' | 'CustomSelector' | 'AttachmentUploader' | 'ContentSelector' | 'MediaSelector' | 'ImageSelector' | 'Date' | 'MediaUploader' | 'SiteConfigurator' | 'HtmlArea';
195
- export interface FormItemSet {
196
- formItemType: string | FormItemType;
197
- name: string;
198
- label: string;
199
- customText: string;
200
- helpText: string;
201
- maximize: boolean;
202
- inputType: InputType;
203
- occurrences: {
204
- maximum: number;
205
- minimum: number;
206
- };
207
- items: FormItem[];
208
- }
209
- export interface FormItemLayout {
210
- formItemType: string | FormItemType;
211
- name: string;
212
- label: string;
213
- items: FormItem[];
214
- }
215
- export declare type ValueType = 'BinaryReference' | 'Boolean' | 'DateTime' | 'Double' | 'GeoPoint' | 'Link' | 'LocalDateTime' | 'LocalDate' | 'LocalTime' | 'Long' | 'PropertySet' | 'Reference' | 'String' | 'Xml';
216
- export interface FormItemInput {
217
- formItemType: string | FormItemType;
218
- name: string;
219
- label: string;
220
- customText: string;
221
- helpText: string;
222
- validationRegexp: string;
223
- maximize: boolean;
224
- inputType: InputType;
225
- occurrences: {
226
- maximum: number;
227
- minimum: number;
228
- };
229
- default: {
230
- value: string;
231
- type: ValueType;
232
- };
233
- config: {
234
- [configName: string]: {
235
- [attributeKey: string]: string;
236
- value: string;
237
- }[];
238
- };
239
- }
240
- export interface FormItemOptionSet {
241
- formItemType: string | FormItemType;
242
- name: string;
243
- label: string;
244
- expanded: boolean;
245
- helpText: string;
246
- occurrences: {
247
- maximum: number;
248
- minimum: number;
249
- };
250
- selection: {
251
- maximum: number;
252
- minimum: number;
253
- };
254
- options: {
255
- name: string;
256
- label: string;
257
- helpText: string;
258
- default: boolean;
259
- items: FormItem[];
260
- }[];
261
- }
262
- export declare type FormItem = FormItemSet | FormItemLayout | FormItemOptionSet | FormItemInput;
263
- export declare type DslQueryType = 'dateTime' | 'time';
264
- export declare type DslOperator = 'OR' | 'AND';
265
- export interface TermDslExpression {
266
- field: string;
267
- value: unknown;
268
- type?: DslQueryType;
269
- boost?: number;
270
- }
271
- export interface InDslExpression {
272
- field: string;
273
- values: unknown[];
274
- type?: DslQueryType;
275
- boost?: number;
276
- }
277
- export interface LikeDslExpression {
278
- field: string;
279
- value: string;
280
- type?: DslQueryType;
281
- boost?: number;
282
- }
283
- export interface RangeDslExpression {
284
- field: string;
285
- type?: DslQueryType;
286
- lt?: unknown;
287
- lte?: unknown;
288
- gt?: unknown;
289
- gte?: unknown;
290
- boost?: number;
291
- }
292
- export interface PathMatchDslExpression {
293
- field: string;
294
- path: string;
295
- minimumMatch?: number;
296
- boost?: number;
297
- }
298
- export interface MatchAllDslExpression {
299
- boost?: number;
300
- }
301
- export interface FulltextDslExpression {
302
- fields: string[];
303
- query: string;
304
- operator?: DslOperator;
305
- boost?: number;
306
- }
307
- export interface NgramDslExpression {
308
- fields: string[];
309
- query: string;
310
- operator?: DslOperator;
311
- boost?: number;
312
- }
313
- export interface StemmedDslExpression {
314
- fields: string[];
315
- query: string;
316
- language: string;
317
- operator?: DslOperator;
318
- boost?: number;
319
- }
320
- export interface ExistsDslExpression {
321
- field: string;
322
- boost?: number;
323
- }
324
- export interface BooleanDslExpression {
325
- should?: QueryDsl | QueryDsl[];
326
- must?: QueryDsl | QueryDsl[];
327
- mustNot?: QueryDsl | QueryDsl[];
328
- filter?: QueryDsl | QueryDsl[];
329
- boost?: number;
330
- }
331
- export declare type QueryDsl = {
332
- boolean: BooleanDslExpression;
333
- } | {
334
- ngram: NgramDslExpression;
335
- } | {
336
- stemmed: StemmedDslExpression;
337
- } | {
338
- fulltext: FulltextDslExpression;
339
- } | {
340
- matchAll: MatchAllDslExpression;
341
- } | {
342
- pathMatch: PathMatchDslExpression;
343
- } | {
344
- range: RangeDslExpression;
345
- } | {
346
- like: LikeDslExpression;
347
- } | {
348
- in: InDslExpression;
349
- } | {
350
- term: TermDslExpression;
351
- } | {
352
- exists: ExistsDslExpression;
353
- };
354
- export declare type SortDirection = 'ASC' | 'DESC';
355
- export declare type DistanceUnit = 'm' | 'meters' | 'in' | 'inch' | 'yd' | 'yards' | 'ft' | 'feet' | 'km' | 'kilometers' | 'NM' | 'nmi' | 'nauticalmiles' | 'mm' | 'millimeters' | 'cm' | 'centimeters' | 'mi' | 'miles';
356
- export interface FieldSortDsl {
357
- field: string;
358
- direction?: SortDirection;
359
- }
360
- export interface GeoDistanceSortDsl extends FieldSortDsl {
361
- unit?: DistanceUnit;
362
- location?: {
363
- lat: number;
364
- lon: number;
365
- };
366
- }
367
- export declare type SortDsl = FieldSortDsl | GeoDistanceSortDsl;
368
28
  /**
369
29
  * This function fetches a content.
370
30
  *
@@ -490,11 +150,11 @@ export interface DeleteContentParams {
490
150
  */
491
151
  declare function _delete(params: DeleteContentParams): boolean;
492
152
  export { _delete as delete, };
493
- export interface ContentsResult<Hit extends Content<unknown>> {
153
+ export interface ContentsResult<Hit extends Content<unknown>, AggregationOutput extends Record<string, AggregationsResult>> {
494
154
  total: number;
495
155
  count: number;
496
156
  hits: Hit[];
497
- aggregations?: Record<string, AggregationsResult>;
157
+ aggregations: AggregationOutput;
498
158
  highlight?: Record<string, HighlightResult>;
499
159
  }
500
160
  export interface GetChildContentParams {
@@ -516,7 +176,7 @@ export interface GetChildContentParams {
516
176
  *
517
177
  * @returns {Object} Result (of content) fetched from the repository.
518
178
  */
519
- export declare function getChildren<Hit extends Content<unknown> = Content>(params: GetChildContentParams): ContentsResult<Hit>;
179
+ export declare function getChildren<Hit extends Content<unknown> = Content, AggregationOutput extends Record<string, AggregationsResult> = never>(params: GetChildContentParams): ContentsResult<Hit, AggregationOutput>;
520
180
  export declare type IdGeneratorSupplier = (value: string) => string;
521
181
  export interface CreateContentParams<Data, Type extends string> {
522
182
  name?: string;
@@ -527,7 +187,7 @@ export interface CreateContentParams<Data, Type extends string> {
527
187
  contentType: Type;
528
188
  language?: string;
529
189
  childOrder?: string;
530
- data?: Data;
190
+ data: Data;
531
191
  x?: XpXData;
532
192
  idGenerator?: IdGeneratorSupplier;
533
193
  workflow?: Workflow;
@@ -560,13 +220,13 @@ export interface CreateContentParams<Data, Type extends string> {
560
220
  * @returns {object} Content created as JSON.
561
221
  */
562
222
  export declare function create<Data = Record<string, unknown>, Type extends string = string>(params: CreateContentParams<Data, Type>): Content<Data, Type>;
563
- export interface QueryContentParams {
223
+ export interface QueryContentParams<AggregationInput extends Aggregations> {
564
224
  start?: number;
565
225
  count?: number;
566
226
  query?: QueryDsl | string;
567
227
  sort?: string | SortDsl | SortDsl[];
568
228
  filters?: Filter | Filter[];
569
- aggregations?: Record<string, Aggregation>;
229
+ aggregations?: AggregationInput;
570
230
  contentTypes?: string[];
571
231
  highlight?: Highlight;
572
232
  }
@@ -586,7 +246,7 @@ export interface QueryContentParams {
586
246
  *
587
247
  * @returns {object} Result of query.
588
248
  */
589
- export declare function query<Hit extends Content<unknown> = Content>(params: QueryContentParams): ContentsResult<Hit>;
249
+ export declare function query<Hit extends Content<unknown> = Content, AggregationInput extends Aggregations = never>(params: QueryContentParams<AggregationInput>): ContentsResult<Hit, AggregationsToAggregationResults<AggregationInput>>;
590
250
  export interface ModifyContentParams<Data, Type extends string> {
591
251
  key: string;
592
252
  editor: (v: Content<Data, Type>) => Content<Data, Type>;
@@ -621,14 +281,12 @@ export interface PublishContentResult {
621
281
  failedContents: string[];
622
282
  }
623
283
  /**
624
- * This function publishes content to a branch.
284
+ * This function publishes content from the draft branch to the master branch.
625
285
  *
626
286
  * @example-ref examples/content/publish.js
627
287
  *
628
288
  * @param {object} params JSON with the parameters.
629
289
  * @param {string[]} params.keys List of all content keys(path or id) that should be published.
630
- * @param {string} params.sourceBranch The branch where the content to be published is stored.
631
- * @param {string} params.targetBranch The branch to which the content should be published. Technically, publishing is just a move from one branch
632
290
  * to another, and publishing user content from master to draft is therefore also valid usage of this function, which may be practical if user input to a web-page is stored on master.
633
291
  * @param {object} [params.schedule] Schedule the publish.
634
292
  * @param {string} [params.schedule.from] Time from which the content is considered published. Defaults to the time of the publish
@@ -865,3 +523,64 @@ export interface ResetInheritanceHandler {
865
523
  * @param {string[]} params.inherit flags to be reset.
866
524
  */
867
525
  export declare function resetInheritance(params: ResetInheritanceParams): void;
526
+ export interface ModifyMediaParams {
527
+ key: string;
528
+ name: string;
529
+ data: ByteSource;
530
+ artist?: string | string[];
531
+ caption?: string;
532
+ copyright?: string;
533
+ focalX?: number;
534
+ focalY?: number;
535
+ mimeType?: string;
536
+ tags?: string | string[];
537
+ workflow?: Workflow;
538
+ }
539
+ /** This function modifies a media content.
540
+ *
541
+ * @example-ref examples/content/modifyMedia.js
542
+ *
543
+ * @param {object} params JSON with the parameters.
544
+ * @param {string} params.key Path or id to the content.
545
+ * @param {string} params.name Name to the content.
546
+ * @param {function} params.data Data (as stream) to use.
547
+ * @param {string} [params.mimeType] Mime-type of the data.
548
+ * @param {string|string[]} [params.artist] Artist to the content.
549
+ * @param {string} [params.caption] Caption to the content.
550
+ * @param {string} [params.copyright] Copyright to the content.
551
+ * @param {string|string[]} [params.tags] Tags to the content.
552
+ * @param {object} [params.workflow] Workflow information to use. Default has state READY and empty check list.
553
+ * @param {number} [params.focalX=0.5] Focal point for X axis (if it's an image).
554
+ * @param {number} [params.focalY=0.5] Focal point for Y axis (if it's an image).
555
+ *
556
+ * @returns {object} Modified content as JSON.
557
+ */
558
+ export declare function modifyMedia<Data = Record<string, unknown>, Type extends string = string>(params: ModifyMediaParams): Content<Data, Type> | null;
559
+ export interface DuplicateContentParams {
560
+ contentId: string;
561
+ workflow?: Workflow;
562
+ includeChildren?: boolean;
563
+ variant?: boolean;
564
+ parent?: string;
565
+ name?: string;
566
+ }
567
+ export interface DuplicateContentsResult {
568
+ contentName: string;
569
+ sourceContentPath: string;
570
+ duplicatedContents: string[];
571
+ }
572
+ /** This function duplicates a content.
573
+ *
574
+ * @example-ref examples/content/duplicate.js
575
+ *
576
+ * @param {object} params JSON with the parameters.
577
+ * @param {string} params.contentId Id to the content.
578
+ * @param {object} [params.workflow] Workflow information to use. Default has state READY and empty check list.
579
+ * @param {boolean} [params.includeChildren=true] Indicates that children contents must be duplicated, too. Default value `true`. Ignored if `variant=true`.
580
+ * @param {boolean} [params.variant=false] Indicates that duplicated content is a variant. Default value `false`.
581
+ * @param {string} [params.parent] Destination parent path. By default, a duplicated content will be added as a sibling of the source content.
582
+ * @param {string} [params.name] New content name.
583
+ *
584
+ * @returns {object} summary about duplicated content.
585
+ */
586
+ export declare function duplicate(params: DuplicateContentParams): DuplicateContentsResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enonic-types/lib-content",
3
- "version": "7.11.3",
3
+ "version": "7.12.0-RC1",
4
4
  "description": "Type definitions for lib-content.",
5
5
  "types": "content.d.ts",
6
6
  "files": [
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/enonic/xp/tree/master#readme",
29
29
  "dependencies": {
30
- "@enonic-types/core": "7.11.3"
30
+ "@enonic-types/core": "7.12.0-RC1"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"