@enonic-types/core 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/index.d.ts +508 -0
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -97,6 +97,7 @@ export interface Content<
97
97
  checks?: Record<string, 'PENDING' | 'REJECTED' | 'APPROVED'>;
98
98
  };
99
99
  inherit?: ('CONTENT' | 'PARENT' | 'NAME' | 'SORT')[];
100
+ variantOf?: string;
100
101
  }
101
102
 
102
103
  // Compliant with npm module ts-brand
@@ -109,6 +110,9 @@ type Brand<
109
110
 
110
111
  export type ByteSource = Brand<object, 'ByteSource'>;
111
112
 
113
+ //
114
+ // RESOURCES
115
+ //
112
116
  export interface Resource {
113
117
  getSize(): number;
114
118
 
@@ -118,3 +122,507 @@ export interface Resource {
118
122
 
119
123
  exists(): boolean;
120
124
  }
125
+
126
+ export interface ResourceKey {
127
+ getApplicationKey(): string;
128
+ getPath(): string;
129
+ getUri(): string;
130
+ isRoot(): boolean;
131
+ getName(): string;
132
+ getExtension(): string;
133
+ }
134
+
135
+ //
136
+ // DSL QUERIES
137
+ //
138
+ export type DslQueryType = 'dateTime' | 'time';
139
+
140
+ export type DslOperator = 'OR' | 'AND';
141
+
142
+ export interface TermDslExpression {
143
+ field: string;
144
+ value: unknown;
145
+ type?: DslQueryType;
146
+ boost?: number;
147
+ }
148
+
149
+ export interface InDslExpression {
150
+ field: string;
151
+ values: unknown[];
152
+ type?: DslQueryType;
153
+ boost?: number;
154
+ }
155
+
156
+ export interface LikeDslExpression {
157
+ field: string;
158
+ value: string;
159
+ type?: DslQueryType;
160
+ boost?: number;
161
+ }
162
+
163
+ export interface RangeDslExpression {
164
+ field: string;
165
+ type?: DslQueryType;
166
+ lt?: unknown;
167
+ lte?: unknown;
168
+ gt?: unknown;
169
+ gte?: unknown;
170
+ boost?: number;
171
+ }
172
+
173
+ export interface PathMatchDslExpression {
174
+ field: string;
175
+ path: string;
176
+ minimumMatch?: number;
177
+ boost?: number;
178
+ }
179
+
180
+ export interface MatchAllDslExpression {
181
+ boost?: number;
182
+ }
183
+
184
+ export interface FulltextDslExpression {
185
+ fields: string[];
186
+ query: string;
187
+ operator?: DslOperator;
188
+ boost?: number;
189
+ }
190
+
191
+ export interface NgramDslExpression {
192
+ fields: string[];
193
+ query: string;
194
+ operator?: DslOperator;
195
+ boost?: number;
196
+ }
197
+
198
+ export interface StemmedDslExpression {
199
+ fields: string[];
200
+ query: string;
201
+ language: string;
202
+ operator?: DslOperator;
203
+ boost?: number;
204
+ }
205
+
206
+ export interface ExistsDslExpression {
207
+ field: string;
208
+ boost?: number;
209
+ }
210
+
211
+ export interface BooleanDslExpression {
212
+ should?: QueryDsl | QueryDsl[];
213
+ must?: QueryDsl | QueryDsl[];
214
+ mustNot?: QueryDsl | QueryDsl[];
215
+ filter?: QueryDsl | QueryDsl[];
216
+ boost?: number;
217
+ }
218
+
219
+ export type QueryDsl = {
220
+ boolean: BooleanDslExpression;
221
+ } | {
222
+ ngram: NgramDslExpression;
223
+ } | {
224
+ stemmed: StemmedDslExpression;
225
+ } | {
226
+ fulltext: FulltextDslExpression;
227
+ } | {
228
+ matchAll: MatchAllDslExpression;
229
+ } | {
230
+ pathMatch: PathMatchDslExpression;
231
+ } | {
232
+ range: RangeDslExpression;
233
+ } | {
234
+ like: LikeDslExpression;
235
+ } | {
236
+ in: InDslExpression;
237
+ } | {
238
+ term: TermDslExpression;
239
+ } | {
240
+ exists: ExistsDslExpression;
241
+ };
242
+
243
+ type SortDirection = 'ASC' | 'DESC';
244
+
245
+ type DistanceUnit =
246
+ | 'm'
247
+ | 'meters'
248
+ | 'in'
249
+ | 'inch'
250
+ | 'yd'
251
+ | 'yards'
252
+ | 'ft'
253
+ | 'feet'
254
+ | 'km'
255
+ | 'kilometers'
256
+ | 'NM'
257
+ | 'nmi'
258
+ | 'nauticalmiles'
259
+ | 'mm'
260
+ | 'millimeters'
261
+ | 'cm'
262
+ | 'centimeters'
263
+ | 'mi'
264
+ | 'miles';
265
+
266
+ export interface FieldSortDsl {
267
+ field: string;
268
+ direction?: SortDirection;
269
+ }
270
+
271
+ export interface GeoDistanceSortDsl
272
+ extends FieldSortDsl {
273
+
274
+ unit?: DistanceUnit;
275
+ location?: {
276
+ lat: number;
277
+ lon: number;
278
+ }
279
+ }
280
+
281
+ export type SortDsl = FieldSortDsl | GeoDistanceSortDsl;
282
+
283
+ //
284
+ // START AGGREGATIONS, FILTERS
285
+ //
286
+ export type Bucket<SubAggregations extends Aggregations = Record<never, never>> = AggregationsToAggregationResults<SubAggregations> & {
287
+ key: string;
288
+ docCount: number;
289
+ };
290
+
291
+ export type NumericBucket<SubAggregations extends Aggregations = Record<never, never>> = Bucket<SubAggregations> & {
292
+ from?: number;
293
+ to?: number;
294
+ };
295
+
296
+ export type DateBucket<SubAggregations extends Aggregations = Record<never, never>> = Bucket<SubAggregations> & {
297
+ from?: string;
298
+ to?: string;
299
+ };
300
+
301
+ export interface BucketsAggregationResult<SubAggregations extends Aggregations = Record<never, never>> {
302
+ buckets: (DateBucket<SubAggregations> | NumericBucket<SubAggregations>)[];
303
+ }
304
+
305
+ export interface StatsAggregationResult {
306
+ count: number;
307
+ min: number;
308
+ max: number;
309
+ avg: number;
310
+ sum: number;
311
+ }
312
+
313
+ export interface SingleValueMetricAggregationResult {
314
+ value: number;
315
+ }
316
+
317
+ export type AggregationsResult<SubAggregations extends Aggregations = Record<never, never>> =
318
+ | BucketsAggregationResult<SubAggregations>
319
+ | StatsAggregationResult
320
+ | SingleValueMetricAggregationResult;
321
+
322
+ export type AggregationsToAggregationResults<AggregationInput extends Aggregations = never> = {
323
+ [Key in keyof AggregationInput]: AggregationToAggregationResult<AggregationInput[Key]>;
324
+ };
325
+
326
+ export type AggregationToAggregationResult<Type extends Aggregation> = Type extends BucketsAggregationsUnion
327
+ ? BucketsAggregationResult<Type['aggregations']>
328
+ : Type extends SingleValueMetricAggregationsUnion
329
+ ? SingleValueMetricAggregationResult
330
+ : Type extends StatsAggregation
331
+ ? StatsAggregationResult
332
+ : never;
333
+
334
+ export type BucketsAggregationsUnion =
335
+ | TermsAggregation
336
+ | GeoDistanceAggregation
337
+ | NumericRangeAggregation
338
+ | DateRangeAggregation
339
+ | HistogramAggregation
340
+ | DateHistogramAggregation;
341
+
342
+ export type SingleValueMetricAggregationsUnion =
343
+ | MinAggregation
344
+ | MaxAggregation
345
+ | ValueCountAggregation;
346
+
347
+ export type Aggregation =
348
+ | TermsAggregation
349
+ | HistogramAggregation
350
+ | DateHistogramAggregation
351
+ | NumericRangeAggregation
352
+ | DateRangeAggregation
353
+ | StatsAggregation
354
+ | GeoDistanceAggregation
355
+ | MinAggregation
356
+ | MaxAggregation
357
+ | ValueCountAggregation;
358
+
359
+ export type Aggregations = Record<string, Aggregation>;
360
+
361
+ export interface TermsAggregation {
362
+ terms: {
363
+ field: string;
364
+ order?: string;
365
+ size?: number;
366
+ minDocCount?: number;
367
+ };
368
+ aggregations?: Aggregations;
369
+ }
370
+
371
+ export interface HistogramAggregation {
372
+ histogram: {
373
+ field: string;
374
+ order?: string;
375
+ interval?: number;
376
+ extendedBoundMin?: number;
377
+ extendedBoundMax?: number;
378
+ minDocCount?: number;
379
+ };
380
+ aggregations?: Aggregations;
381
+ }
382
+
383
+ export interface DateHistogramAggregation {
384
+ dateHistogram: {
385
+ field: string;
386
+ interval?: string;
387
+ minDocCount?: number;
388
+ format: string;
389
+ };
390
+ aggregations?: Aggregations;
391
+ }
392
+
393
+ export interface NumericRange {
394
+ from?: number;
395
+ to?: number;
396
+ key?: string;
397
+ }
398
+
399
+ export interface NumericRangeAggregation {
400
+ range: {
401
+ field: string;
402
+ ranges?: NumericRange[];
403
+ };
404
+ aggregations?: Aggregations;
405
+ }
406
+
407
+ export interface DateRange {
408
+ from?: string;
409
+ to?: string;
410
+ key?: string;
411
+ }
412
+
413
+ export interface DateRangeAggregation {
414
+ dateRange: {
415
+ field: string;
416
+ format: string;
417
+ ranges: DateRange[];
418
+ };
419
+ aggregations?: Aggregations;
420
+ }
421
+
422
+ export interface StatsAggregation {
423
+ stats: {
424
+ field: string;
425
+ };
426
+ }
427
+
428
+ export interface GeoDistanceAggregation {
429
+ geoDistance: {
430
+ field: string;
431
+ unit?: string;
432
+ origin: {
433
+ lat: string;
434
+ lon: string;
435
+ };
436
+ ranges: NumericRange[];
437
+ };
438
+ }
439
+
440
+ export interface MinAggregation {
441
+ min: {
442
+ field: string;
443
+ };
444
+ }
445
+
446
+ export interface MaxAggregation {
447
+ max: {
448
+ field: string;
449
+ };
450
+ }
451
+
452
+ export interface ValueCountAggregation {
453
+ count: {
454
+ field: string;
455
+ };
456
+ }
457
+
458
+ export interface Highlight {
459
+ encoder?: 'default' | 'html';
460
+ tagsSchema?: 'styled';
461
+ fragmenter?: 'simple' | 'span';
462
+ fragmentSize?: number;
463
+ noMatchSize?: number;
464
+ numberOfFragments?: number;
465
+ order?: 'score' | 'none';
466
+ preTag?: string;
467
+ postTag?: string;
468
+ requireFieldMatch?: boolean;
469
+ properties?: Record<string, Highlight>;
470
+ }
471
+
472
+ export interface HighlightResult {
473
+ [highlightedFieldName: string]: string[];
474
+ }
475
+
476
+ export interface ExistsFilter {
477
+ exists: {
478
+ field: string;
479
+ };
480
+ }
481
+
482
+ export interface NotExistsFilter {
483
+ notExists: {
484
+ field: string;
485
+ };
486
+ }
487
+
488
+ export interface HasValueFilter {
489
+ hasValue: {
490
+ field: string;
491
+ values: unknown[];
492
+ };
493
+ }
494
+
495
+ export interface IdsFilter {
496
+ ids: {
497
+ values: string[];
498
+ };
499
+ }
500
+
501
+ export interface BooleanFilter {
502
+ boolean: {
503
+ must?: Filter[];
504
+ mustNot?: Filter[];
505
+ should?: Filter[];
506
+ };
507
+ }
508
+
509
+ export type Filter = ExistsFilter | NotExistsFilter | HasValueFilter | IdsFilter | BooleanFilter;
510
+
511
+ //
512
+ // FORM ITEMS
513
+ //
514
+ export type InputType =
515
+ | 'Time'
516
+ | 'DateTime'
517
+ | 'CheckBox'
518
+ | 'ComboBox'
519
+ | 'Long'
520
+ | 'Double'
521
+ | 'RadioButton'
522
+ | 'TextArea'
523
+ | 'ContentTypeFilter'
524
+ | 'GeoPoint'
525
+ | 'TextLine'
526
+ | 'Tag'
527
+ | 'CustomSelector'
528
+ | 'AttachmentUploader'
529
+ | 'ContentSelector'
530
+ | 'MediaSelector'
531
+ | 'ImageSelector'
532
+ | 'Date'
533
+ | 'MediaUploader'
534
+ | 'SiteConfigurator'
535
+ | 'HtmlArea';
536
+
537
+ export interface FormItemSet {
538
+ formItemType: 'ItemSet';
539
+ name: string;
540
+ label: string;
541
+ customText: string;
542
+ helpText: string;
543
+ maximize: boolean;
544
+ inputType: InputType;
545
+ occurrences: {
546
+ maximum: number;
547
+ minimum: number;
548
+ };
549
+ items: FormItem[];
550
+ }
551
+
552
+ export interface FormItemLayout {
553
+ formItemType: 'Layout';
554
+ name: string;
555
+ label: string;
556
+ items: FormItem[];
557
+ }
558
+
559
+ export type ValueType =
560
+ | 'BinaryReference'
561
+ | 'Boolean'
562
+ | 'DateTime'
563
+ | 'Double'
564
+ | 'GeoPoint'
565
+ | 'Link'
566
+ | 'LocalDateTime'
567
+ | 'LocalDate'
568
+ | 'LocalTime'
569
+ | 'Long'
570
+ | 'PropertySet'
571
+ | 'Reference'
572
+ | 'String'
573
+ | 'Xml';
574
+
575
+ export interface FormItemInput {
576
+ formItemType: 'Input';
577
+ name: string;
578
+ label: string;
579
+ customText: string;
580
+ helpText: string;
581
+ validationRegexp: string;
582
+ maximize: boolean;
583
+ inputType: InputType;
584
+ occurrences: {
585
+ maximum: number;
586
+ minimum: number;
587
+ };
588
+ default: {
589
+ value: string;
590
+ type: ValueType;
591
+ }
592
+ config: {
593
+ [configName: string]: {
594
+ [attributeKey: string]: string;
595
+ value: string;
596
+ }[]
597
+ }
598
+ }
599
+
600
+ export interface FormItemOptionSet {
601
+ formItemType: 'OptionSet';
602
+ name: string;
603
+ label: string;
604
+ expanded: boolean;
605
+ helpText: string;
606
+ occurrences: {
607
+ maximum: number;
608
+ minimum: number;
609
+ };
610
+ selection: {
611
+ maximum: number;
612
+ minimum: number;
613
+ };
614
+ options: {
615
+ name: string;
616
+ label: string;
617
+ helpText: string;
618
+ default: boolean;
619
+ items: FormItem[]
620
+ }[];
621
+ }
622
+
623
+ export interface FormItemInlineMixin {
624
+ formItemType: 'InlineMixin';
625
+ name: string;
626
+ }
627
+
628
+ export type FormItem = FormItemSet | FormItemLayout | FormItemOptionSet | FormItemInput | FormItemInlineMixin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enonic-types/core",
3
- "version": "7.11.3",
3
+ "version": "7.12.0-RC1",
4
4
  "description": "Shared type definition for core libraries.",
5
5
  "types": "index.d.ts",
6
6
  "files": [