@enonic-types/lib-node 0.1.0 → 7.11.0-B1

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/node.d.ts +887 -873
  2. package/package.json +32 -32
package/node.d.ts CHANGED
@@ -1,873 +1,887 @@
1
- /**
2
- * Functions to get, query and manipulate nodes.
3
- *
4
- * @example
5
- * var nodeLib = require('/lib/xp/node');
6
- *
7
- * @module node
8
- */
9
- declare global {
10
- interface XpLibraries {
11
- '/lib/xp/node': typeof import('./node');
12
- }
13
- }
14
- export interface Bucket {
15
- [subAggregationName: string]: BucketsAggregation | StatsAggregation | SingleValueMetricAggregation | string | number | undefined;
16
- key: string;
17
- docCount: number;
18
- }
19
- export interface NumericBucket extends Bucket {
20
- from?: number;
21
- to?: number;
22
- }
23
- export interface DateBucket extends Bucket {
24
- from?: string;
25
- to?: string;
26
- }
27
- export interface BucketsAggregation {
28
- buckets: (DateBucket | NumericBucket)[];
29
- }
30
- export interface StatsAggregation {
31
- count: number;
32
- min: number;
33
- max: number;
34
- avg: number;
35
- sum: number;
36
- }
37
- export interface SingleValueMetricAggregation {
38
- value: number;
39
- }
40
- export declare type AggregationsResult = BucketsAggregation | StatsAggregation | SingleValueMetricAggregation;
41
- export declare type Aggregation = TermsAggregation | HistogramAggregation | DateHistogramAggregation | NumericRangeAggregation | DateRangeAggregation | StatsAggregation | GeoDistanceAggregation | MinAggregation | MaxAggregation | ValueCountAggregation;
42
- export interface TermsAggregation {
43
- terms: {
44
- field: string;
45
- order?: string;
46
- size?: number;
47
- minDocCount?: number;
48
- };
49
- aggregations?: {
50
- [subAggregations: string]: Aggregation;
51
- };
52
- }
53
- export interface HistogramAggregation {
54
- histogram: {
55
- field: string;
56
- order?: string;
57
- interval?: number;
58
- extendedBoundMin?: number;
59
- extendedBoundMax?: number;
60
- minDocCount?: number;
61
- };
62
- aggregations?: {
63
- [subAggregations: string]: Aggregation;
64
- };
65
- }
66
- export interface DateHistogramAggregation {
67
- dateHistogram: {
68
- field: string;
69
- interval?: string;
70
- minDocCount?: number;
71
- format: string;
72
- };
73
- aggregations?: {
74
- [subAggregations: string]: Aggregation;
75
- };
76
- }
77
- export interface NumericRange {
78
- from?: number;
79
- to?: number;
80
- key?: string;
81
- }
82
- export interface NumericRangeAggregation {
83
- range: {
84
- field: string;
85
- ranges?: NumericRange[];
86
- };
87
- aggregations?: {
88
- [subAggregations: string]: Aggregation;
89
- };
90
- }
91
- export interface NumericRangeAggregation {
92
- range: {
93
- field: string;
94
- ranges?: NumericRange[];
95
- };
96
- aggregations?: {
97
- [subAggregations: string]: Aggregation;
98
- };
99
- }
100
- export interface DateRange {
101
- from?: string;
102
- to?: string;
103
- key?: string;
104
- }
105
- export interface DateRangeAggregation {
106
- dateRange: {
107
- field: string;
108
- format: string;
109
- ranges: DateRange[];
110
- };
111
- aggregations?: {
112
- [subAggregations: string]: Aggregation;
113
- };
114
- }
115
- export interface StatsAggregation {
116
- stats: {
117
- field: string;
118
- };
119
- }
120
- export interface GeoDistanceAggregation {
121
- geoDistance: {
122
- field: string;
123
- unit: string;
124
- origin?: {
125
- lat: string;
126
- lon: string;
127
- };
128
- ranges?: NumericRange[];
129
- };
130
- }
131
- export interface MinAggregation {
132
- min: {
133
- field: string;
134
- };
135
- }
136
- export interface MaxAggregation {
137
- max: {
138
- field: string;
139
- };
140
- }
141
- export interface ValueCountAggregation {
142
- count: {
143
- field: string;
144
- };
145
- }
146
- export interface Highlight {
147
- encoder?: 'default' | 'html';
148
- tagsSchema?: 'styled';
149
- fragmenter?: 'simple' | 'span';
150
- fragmentSize?: number;
151
- noMatchSize?: number;
152
- numberOfFragments?: number;
153
- order?: 'score' | 'none';
154
- preTag?: string;
155
- postTag?: string;
156
- requireFieldMatch?: boolean;
157
- properties?: Record<string, Highlight>;
158
- }
159
- export interface HighlightResult {
160
- [highlightedFieldName: string]: string[];
161
- }
162
- export interface ExistsFilter {
163
- exists: {
164
- field: string;
165
- };
166
- }
167
- export interface NotExistsFilter {
168
- notExists: {
169
- field: string;
170
- };
171
- }
172
- export interface HasValueFilter {
173
- hasValue: {
174
- field: string;
175
- values: unknown[];
176
- };
177
- }
178
- export interface IdsFilter {
179
- ids: {
180
- values: string[];
181
- };
182
- }
183
- export interface BooleanFilter {
184
- boolean: {
185
- must?: Filter[];
186
- mustNot?: Filter[];
187
- should?: Filter[];
188
- };
189
- }
190
- export declare type Filter = ExistsFilter | NotExistsFilter | HasValueFilter | IdsFilter | BooleanFilter;
191
- export declare type Suggestion = TermSuggestion;
192
- export interface TermSuggestion {
193
- text: string;
194
- term: TermSuggestionOptions;
195
- }
196
- export interface TermSuggestionOptions {
197
- field: string;
198
- analyzer?: string;
199
- sort?: 'score' | 'frequency';
200
- suggestMode?: 'missing' | 'popular' | 'always';
201
- stringDistance?: 'internal' | 'damerau_levenshtein' | 'levenshtein' | 'jarowinkler' | 'ngram';
202
- size?: number | null;
203
- maxEdits?: number | null;
204
- prefixLength?: number | null;
205
- minWordLength?: number | null;
206
- maxInspections?: number | null;
207
- minDocFreq?: number | null;
208
- maxTermFreq?: number | null;
209
- }
210
- declare type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
211
- export declare type DslQueryType = LiteralUnion<'dateTime' | 'time'> | number | boolean;
212
- export declare type DslOperator = 'OR' | 'AND';
213
- export interface TermDslExpression {
214
- field: string;
215
- value: unknown;
216
- type?: DslQueryType;
217
- boost?: number;
218
- }
219
- export interface InDslExpression {
220
- field: string;
221
- values: unknown[];
222
- type?: DslQueryType;
223
- boost?: number;
224
- }
225
- export interface LikeDslExpression {
226
- field: string;
227
- value: string;
228
- type?: DslQueryType;
229
- boost?: number;
230
- }
231
- export interface RangeDslExpression {
232
- field: string;
233
- type?: DslQueryType;
234
- lt?: unknown;
235
- lte?: unknown;
236
- gt?: unknown;
237
- gte?: unknown;
238
- boost?: number;
239
- }
240
- export interface PathMatchDslExpression {
241
- field: string;
242
- path: string;
243
- minimumMatch?: number;
244
- boost?: number;
245
- }
246
- export interface MatchAllDslExpression {
247
- boost?: number;
248
- }
249
- export interface FulltextDslExpression {
250
- fields: string[];
251
- query: string;
252
- operator?: DslOperator;
253
- }
254
- export interface NgramDslExpression {
255
- fields: string[];
256
- query: string;
257
- operator?: DslOperator;
258
- }
259
- export interface StemmedDslExpression {
260
- fields: string[];
261
- query: string;
262
- language: string;
263
- }
264
- export interface BooleanDslExpression {
265
- should?: DslExpression | DslExpression[];
266
- must?: DslExpression | DslExpression[];
267
- mustNot?: DslExpression | DslExpression[];
268
- filter?: DslExpression | DslExpression[];
269
- }
270
- export declare type DslExpression = TermDslExpression | InDslExpression | LikeDslExpression | RangeDslExpression | PathMatchDslExpression | MatchAllDslExpression | FulltextDslExpression | NgramDslExpression | BooleanDslExpression | StemmedDslExpression;
271
- export declare type QueryDsl = {
272
- boolean: BooleanDslExpression;
273
- } | {
274
- ngram: NgramDslExpression;
275
- } | {
276
- fulltext: FulltextDslExpression;
277
- } | {
278
- matchAll: MatchAllDslExpression;
279
- } | {
280
- pathMatch: PathMatchDslExpression;
281
- } | {
282
- range: RangeDslExpression;
283
- } | {
284
- like: LikeDslExpression;
285
- } | {
286
- in: InDslExpression;
287
- } | {
288
- term: TermDslExpression;
289
- };
290
- export interface Explanation {
291
- value: number;
292
- description: string;
293
- details: Explanation[];
294
- }
295
- export interface NodeQueryResult {
296
- total: number;
297
- count: number;
298
- hits: {
299
- id: string;
300
- score: number;
301
- explanation?: Explanation;
302
- highlight?: HighlightResult;
303
- }[];
304
- aggregations?: AggregationsResult;
305
- suggestions?: {
306
- [suggestionName: string]: {
307
- text: string;
308
- length: number;
309
- offset: number;
310
- options: {
311
- text: string;
312
- score: number;
313
- freq?: number;
314
- }[];
315
- }[];
316
- }[];
317
- }
318
- export interface NodeMultiRepoQueryResult {
319
- total: number;
320
- count: number;
321
- hits: {
322
- id: string;
323
- score: number;
324
- repoId: string;
325
- branch: string;
326
- explanation?: Explanation;
327
- highlight?: HighlightResult;
328
- }[];
329
- aggregations?: AggregationsResult;
330
- }
331
- interface MultiRepoNodeHandler {
332
- query(params: QueryNodeHandlerParams): NodeMultiRepoQueryResult;
333
- }
334
- interface NodeHandler {
335
- create(node: ScriptValue): Node;
336
- modify(editor: ScriptValue, key: string): Node;
337
- setChildOrder(key: string, childOrder: string): Node;
338
- get(params: GetNodeHandlerParams): Node | Node[];
339
- delete(keys: string[]): boolean;
340
- push(params: PushNodeHandlerParams): PushNodesResult;
341
- diff(params: DiffBranchesHandlerParams): object;
342
- move(source: string, target: string): boolean;
343
- query(params: QueryNodeHandlerParams): NodeQueryResult;
344
- exist(key: string): boolean;
345
- findVersions(params: FindVersionsHandlerParams): NodeVersionsQueryResult;
346
- getActiveVersion(key: string): NodeVersion;
347
- setActiveVersion(key: string, versionId: string): boolean;
348
- findChildren(params: FindChildrenHandlerParams): FindNodesByParentResult;
349
- commit(keys: string[], message?: string | null): object;
350
- getCommit(commitId: string): NodeCommit;
351
- setRootPermissions(v: ScriptValue): object;
352
- getBinary(key: string, binaryReference?: string | null): object;
353
- refresh(mode: RefreshMode): object;
354
- }
355
- export interface CreateNodeParams {
356
- _name?: string;
357
- _parentPath?: string;
358
- _indexConfig?: NodeConfigEntry;
359
- _permissions?: AccessControlEntry[];
360
- _inheritsPermissions?: boolean;
361
- _manualOrderValue?: number;
362
- _childOrder?: string;
363
- }
364
- export interface ModifyNodeParams {
365
- key: string;
366
- editor: (node: Node) => Node;
367
- }
368
- export interface GetNodeParams {
369
- key: string;
370
- versionId?: string;
371
- }
372
- interface GetNodeHandlerParams {
373
- add(key: string): void;
374
- add(key: string, versionId?: string | null): void;
375
- }
376
- export interface PushNodeParams {
377
- key?: string | null;
378
- keys?: string[] | null;
379
- target: string;
380
- includeChildren?: boolean;
381
- resolve?: boolean;
382
- exclude?: string[] | null;
383
- }
384
- export interface PushNodesResult {
385
- success: string[];
386
- failed: {
387
- id: string;
388
- reason: string;
389
- }[];
390
- deleted: string[];
391
- }
392
- interface PushNodeHandlerParams {
393
- setKey(value?: string | null): void;
394
- setKeys(value?: string[] | null): void;
395
- setTargetBranch(value: string): void;
396
- setIncludeChildren(value: boolean): void;
397
- setExclude(value?: string[] | null): void;
398
- setResolve(value: boolean): void;
399
- }
400
- export interface DiffBranchesParams {
401
- key: string;
402
- target: string;
403
- includeChildren: boolean;
404
- }
405
- interface DiffBranchesHandlerParams {
406
- setKey(value: string): void;
407
- setTargetBranch(value: string): void;
408
- setIncludeChildren(value: boolean): void;
409
- }
410
- export interface GetBinaryParams {
411
- key: string;
412
- binaryReference?: string | null;
413
- }
414
- export interface MoveNodeParams {
415
- source: string;
416
- target: string;
417
- }
418
- export interface SetChildOrderParams {
419
- key: string;
420
- childOrder: string;
421
- }
422
- export interface QueryNodeParams {
423
- start?: number | null;
424
- count?: number | null;
425
- query: QueryDsl | object;
426
- sort?: string;
427
- aggregations?: Record<string, Aggregation>;
428
- suggestions?: Record<string, Suggestion>;
429
- highlight: Highlight;
430
- filters?: Filter | Filter[];
431
- explain: boolean;
432
- }
433
- interface QueryNodeHandlerParams {
434
- setStart(value?: number | null): void;
435
- setCount(value?: number | null): void;
436
- setQuery(value: ScriptValue): void;
437
- setSort(value: ScriptValue): void;
438
- setAggregations(value: ScriptValue): void;
439
- setSuggestions(value: ScriptValue): void;
440
- setHighlight(value: ScriptValue): void;
441
- setFilters(value: ScriptValue): void;
442
- setExplain(value: boolean): void;
443
- }
444
- export interface FindVersionsParams {
445
- key: string;
446
- start?: number | null;
447
- count?: number | null;
448
- }
449
- interface FindVersionsHandlerParams {
450
- setKey(key: string): void;
451
- setStart(start?: number | null): void;
452
- setCount(count?: number | null): void;
453
- }
454
- export interface NodeVersion {
455
- versionId: string;
456
- nodeId: string;
457
- nodePath: string;
458
- timestamp: string;
459
- commitId: string;
460
- }
461
- export interface NodeVersionsQueryResult {
462
- total: number;
463
- count: number;
464
- hits: NodeVersion[];
465
- }
466
- export interface GetActiveVersionParams {
467
- key: string;
468
- }
469
- export interface SetActiveVersionParams {
470
- key: string;
471
- versionId: string;
472
- }
473
- export interface FindChildrenParams {
474
- parentKey: string;
475
- start?: number | null;
476
- count?: number | null;
477
- childOrder: string;
478
- countOnly: boolean;
479
- recursive: boolean;
480
- }
481
- interface FindChildrenHandlerParams {
482
- setParentKey(parentKey: string): void;
483
- setStart(start?: number | null): void;
484
- setCount(count?: number | null): void;
485
- setChildOrder(childOrder: string): void;
486
- setCountOnly(countOnly: boolean): void;
487
- setRecursive(recursive: boolean): void;
488
- }
489
- export interface FindNodesByParentResult {
490
- total: number;
491
- count: number;
492
- hits: {
493
- id: string;
494
- }[];
495
- }
496
- export declare type RefreshMode = 'SEARCH' | 'STORAGE' | 'ALL';
497
- export interface GetCommitParams {
498
- id: string;
499
- }
500
- export interface NodeCommit {
501
- id: string;
502
- message: string;
503
- committer: string;
504
- timestamp: string;
505
- }
506
- export interface CommitParams {
507
- keys: string | string[];
508
- message?: string;
509
- }
510
- export interface SetRootPermissionsParams {
511
- _permissions: AccessControlEntry[];
512
- _inheritsPermissions: boolean;
513
- }
514
- export declare type Permission = 'READ' | 'CREATE' | 'MODIFY' | 'DELETE' | 'PUBLISH' | 'READ_PERMISSIONS' | 'WRITE_PERMISSIONS';
515
- export interface AccessControlEntry {
516
- principal: string;
517
- allow?: Permission[];
518
- deny?: Permission[];
519
- }
520
- export interface NodeIndexConfig {
521
- analyzer: string;
522
- default?: NodeConfigEntry;
523
- configs: {
524
- path: string;
525
- config: NodeConfigEntry;
526
- }[];
527
- }
528
- export interface NodeConfigEntry {
529
- decideByType: boolean;
530
- enabled: boolean;
531
- nGram: boolean;
532
- fulltext: boolean;
533
- includeInAllText: boolean;
534
- path: boolean;
535
- indexValueProcessors: string[];
536
- languages: string[];
537
- }
538
- export interface Node {
539
- [key: string]: unknown;
540
- _id: string;
541
- _name: string;
542
- _path: string;
543
- _childOrder: string;
544
- _state: string;
545
- _nodeType: string;
546
- _versionKey: string;
547
- _manualOrderValue: number;
548
- _ts: string;
549
- _parentPath: string;
550
- _indexConfig: NodeIndexConfig;
551
- _inheritsPermissions: boolean;
552
- _permissions?: AccessControlEntry[];
553
- }
554
- /**
555
- * Creates a new repo-connection.
556
- *
557
- * @returns {*} native Native repo-connection object.
558
- * @constructor
559
- */
560
- export declare class RepoConnection {
561
- private nodeHandler;
562
- constructor(nodeHandler: NodeHandler);
563
- /**
564
- * This function creates a node.
565
- *
566
- *
567
- * To create a content where the name is not important and there could be multiple instances under the same parent content,
568
- * skip the `name` parameter and specify a `displayName`.
569
- *
570
- * @example-ref examples/node/create-1.js
571
- * @example-ref examples/node/create-2.js
572
- *
573
- * @param {object} params JSON with the parameters.
574
- * @param {string} [params._name] Name of content.
575
- * @param {string} [params._parentPath] Path to place content under.
576
- * @param {object} [params._indexConfig] How the document should be indexed. A default value "byType" will be set if no value specified.
577
- * @param {object} [params._permissions] The access control list for the node. By default the creator will have full access
578
- * @param {boolean} [params._inheritsPermissions] true if the permissions should be inherited from the node parent. Default is false.
579
- * @param {number} [params._manualOrderValue] Value used to order document when ordering by parent and child-order is set to manual
580
- * @param {string} [params._childOrder] Default ordering of children when doing getChildren if no order is given in query
581
- *
582
- * @returns {object} Node created as JSON.
583
- */
584
- create(params: CreateNodeParams): Node;
585
- /**
586
- * This function modifies a node.
587
- *
588
- * @example-ref examples/node/modify.js
589
- *
590
- * @param {object} params JSON with the parameters.
591
- * @param {string} params.key Path or id to the node.
592
- * @param {function} params.editor Editor callback function.
593
- *
594
- * @returns {object} Modified node as JSON.
595
- */
596
- modify(params: ModifyNodeParams): Node;
597
- /**
598
- * This function fetches nodes.
599
- *
600
- * @example-ref examples/node/get-1.js
601
- * @example-ref examples/node/get-2.js
602
- * @example-ref examples/node/get-3.js
603
- *
604
- * @param {...(string|string[]|object|object[])} keys to fetch. Each argument could be an id, a path, an object with key and versionId properties or an array of them.
605
- *
606
- * @returns {object} The node or node array (as JSON) fetched from the repository.
607
- */
608
- get(...keys: (string | string[] | GetNodeParams | GetNodeParams[])[]): Node | Node[];
609
- /**
610
- * This function deletes a node or nodes.
611
- *
612
- * @example-ref examples/node/delete.js
613
- *
614
- * @param {...(string|string[])} keys Keys to delete. Each argument could be an id, a path or an array of the two.
615
- *
616
- * @returns {boolean} True if deleted, false otherwise.
617
- */
618
- delete(...keys: (string | string[])[]): boolean;
619
- /**
620
- * This function push a node to a given branch.
621
- *
622
- * @example-ref examples/node/push-1.js
623
- * @example-ref examples/node/push-2.js
624
- * @example-ref examples/node/push-3.js
625
- *
626
- * @param {object} params JSON with the parameters.
627
- * @param {string} params.key Id or path to the nodes
628
- * @param {string[]} params.keys Array of ids or paths to the nodes
629
- * @param {string} params.target Branch to push nodes to.
630
- * @param {boolean} [params.includeChildren=false] Also push children of given nodes
631
- * @param {boolean} [params.resolve=true] Resolve dependencies before pushing, meaning that references will also be pushed
632
- * @param {string[]} [params.exclude] Array of ids or paths to nodes not to be pushed (nodes needed to maintain data integrity (e.g parents must be present in target) will be pushed anyway)
633
- *
634
- * @returns {object} PushNodesResult
635
- */
636
- push(params: PushNodeParams): PushNodesResult;
637
- /**
638
- * This function resolves the differences for node between current and given branch
639
- *
640
- * @example-ref examples/node/diff-1.js
641
- *
642
- * @param {object} params JSON with the parameters.
643
- * @param {string} params.key Path or id to resolve diff for
644
- * @param {string} params.target Branch to diff against.
645
- * @param {boolean} [params.includeChildren=false] also resolve dependencies for children
646
- *
647
- * @returns {object} DiffNodesResult
648
- */
649
- diff(params: DiffBranchesParams): object;
650
- /**
651
- * This function returns a binary stream.
652
- *
653
- * @example-ref examples/node/getBinary.js
654
- * @param {string} params.key Path or id to the node.
655
- * @param {string} params.binaryReference to the binary.
656
- *
657
- * @returns {*} Stream of the binary.
658
- */
659
- getBinary(params: GetBinaryParams): object;
660
- /**
661
- * Rename a node or move it to a new path.
662
- *
663
- * @example-ref examples/node/move-1.js
664
- * @example-ref examples/node/move-2.js
665
- * @example-ref examples/node/move-3.js
666
- *
667
- * @param {object} params JSON with the parameters.
668
- * @param {string} params.source Path or id of the node to be moved or renamed.
669
- * @param {string} params.target New path or name for the node. If the target ends in slash '/', it specifies the parent path where to be moved. Otherwise it means the new desired path or name for the node.
670
- *
671
- * @returns {boolean} True if the node was successfully moved or renamed, false otherwise.
672
- */
673
- move(params: MoveNodeParams): boolean;
674
- /**
675
- * Set node's children order
676
- *
677
- * @example-ref examples/node/setChildOrder.js
678
- *
679
- * @param {object} params JSON with the parameters.
680
- * @param {string} params.key node's path or id
681
- * @param {string} params.childOrder children order
682
- * @returns {object} updated node
683
- */
684
- setChildOrder(params: SetChildOrderParams): Node;
685
- /**
686
- * This command queries nodes.
687
- *
688
- * @example-ref examples/node/query.js
689
- *
690
- * @param {object} params JSON with the parameters.
691
- * @param {number} [params.start=0] Start index (used for paging).
692
- * @param {number} [params.count=10] Number of contents to fetch.
693
- * @param {string|object} [params.query] Query expression.
694
- * @param {object} [params.filters] Query filters
695
- * @param {string|object|object[]} [params.sort='_score DESC'] Sorting expression.
696
- * @param {string} [params.aggregations] Aggregations expression.
697
- * @param {string} [params.highlight] Highlighting parameters.
698
- * @param {boolean} [params.explain=false] Return score calculation explanation.
699
- * @returns {object} Result of query.
700
- */
701
- query(params: QueryNodeParams): object;
702
- /**
703
- * Check if node exists.
704
- *
705
- * @example-ref examples/node/exists.js
706
- *
707
- * @param {string} [key] node path or id.
708
- *
709
- * @returns {boolean} True if exist, false otherwise.
710
- */
711
- exists(key: string): boolean;
712
- /**
713
- * This function returns node versions.
714
- *
715
- * @example-ref examples/node/findVersions.js
716
- * @param {object} params JSON parameters.
717
- * @param {string} params.key Path or ID of the node.
718
- * @param {number} [params.start=0] Start index (used for paging).
719
- * @param {number} [params.count=10] Number of node versions to fetch.
720
- *
721
- * @returns {object[]} Node versions.
722
- */
723
- findVersions(params: FindVersionsParams): NodeVersionsQueryResult;
724
- /**
725
- * This function returns the active version of a node.
726
- *
727
- * @example-ref examples/node/getActiveVersion.js
728
- * @param {object} params JSON parameters.
729
- * @param {string} params.key Path or ID of the node.
730
- *
731
- * @returns {object} Active content versions per branch.
732
- */
733
- getActiveVersion(params: GetActiveVersionParams): NodeVersion;
734
- /**
735
- * This function sets the active version of a node.
736
- *
737
- * @example-ref examples/node/setActiveVersion.js
738
- * @param {object} params JSON parameters.
739
- * @param {string} params.key Path or ID of the node.
740
- * @param {string} params.versionId Version to set as active.
741
- *
742
- * @returns {boolean} True if deleted, false otherwise.
743
- */
744
- setActiveVersion(params: SetActiveVersionParams): boolean;
745
- /**
746
- * Get children for given node.
747
- *
748
- * @example-ref examples/node/findChildren.js
749
- *
750
- * @param {object} params JSON with the parameters.
751
- * @param {number} params.parentKey path or id of parent to get children of
752
- * @param {number} [params.start=0] Start index (used for paging).
753
- * @param {number} [params.count=10] Number of contents to fetch.
754
- * @param {string} [params.childOrder] How to order the children (defaults to value stored on parent)
755
- * @param {boolean} [params.countOnly=false] Optimize for count children only ( no children returned )
756
- * @param {boolean} [params.recursive=false] Do recursive fetching of all children of children
757
- * @returns {object} Result of getChildren.
758
- */
759
- findChildren(params: FindChildrenParams): FindNodesByParentResult;
760
- /**
761
- * Refresh the index for the current repoConnection
762
- *
763
- * @example-ref examples/node/refresh.js
764
- *
765
- * @param {string} [mode]=ALL Refresh all (ALL) data, or just the search-index (SEARCH) or the storage-index (STORAGE)
766
- */
767
- refresh(mode: RefreshMode): void;
768
- /**
769
- * Set the root node permissions and inherit.
770
- *
771
- * @example-ref examples/node/modifyRootPermissions.js
772
- *
773
- * @param {object} params JSON with the parameters.
774
- * @param {object} params._permissions the permission json
775
- * @param {object} [params._inheritsPermissions]= true if the permissions should be inherited to children
776
- *
777
- * @returns {object} Updated root-node as JSON.
778
- */
779
- setRootPermissions(params: SetRootPermissionsParams): object;
780
- /**
781
- * This function commits the active version of nodes.
782
- *
783
- * @example-ref examples/node/commit.js
784
- *
785
- * @param {...(string|string[])} params.keys Node keys to commit. Each argument could be an id, a path or an array of the two. Prefer the usage of ID rather than paths.
786
- * @param {string} [params.message] Commit message.
787
- *
788
- * @returns {object} Commit object.
789
- */
790
- commit(params: CommitParams): object;
791
- /**
792
- * This function fetches commit by id.
793
- *
794
- * @example-ref examples/node/commit.js
795
- *
796
- * @param {string} params.id existing commit id.
797
- *
798
- * @returns {object} Commit object.
799
- */
800
- getCommit(params: GetCommitParams): NodeCommit;
801
- }
802
- /**
803
- * Creates a new multirepo-connection.
804
- *
805
- * @returns {*} native Native multirepo-connection object.
806
- * @constructor
807
- */
808
- export declare class MultiRepoConnection {
809
- private multiRepoConnection;
810
- constructor(multiRepoConnection: MultiRepoNodeHandler);
811
- /**
812
- * This command queries nodes in a multi-repo connection.
813
- *
814
- * @example-ref examples/node/multiRepoQuery.js
815
- *
816
- * @param {object} params JSON with the parameters.
817
- * @param {number} [params.start=0] Start index (used for paging).
818
- * @param {number} [params.count=10] Number of contents to fetch.
819
- * @param {string|object} [params.query] Query expression.
820
- * @param {object} [params.filters] Query filters
821
- * @param {string|object|object[]} [params.sort='_score DESC'] Sorting expression.
822
- * @param {string} [params.aggregations] Aggregations expression.
823
- * @param {string} [params.highlight] Highlighting parameters.
824
- * @param {boolean} [params.explain=false] Return score calculation explanation.
825
- * @returns {object} Result of query.
826
- */
827
- query(params: QueryNodeParams): object;
828
- }
829
- export interface ConnectParams {
830
- repoId: string;
831
- branch: string;
832
- principals: string[];
833
- user: {
834
- login: string;
835
- idProvider: string;
836
- };
837
- }
838
- /**
839
- * Creates a connection to a repository with a given branch and authentication info.
840
- *
841
- * @example-ref examples/node/connect.js
842
- *
843
- * @param {object} params JSON with the parameters.
844
- * @param {object} params.repoId repository id
845
- * @param {object} params.branch branch id
846
- * @param {object} [params.user] User to execute the callback with. Default is the current user.
847
- * @param {string} params.user.login Login of the user.
848
- * @param {string} [params.user.idProvider] Id provider containing the user. By default, all the id providers will be used.
849
- * @param {string[]} [params.principals] Additional principals to execute the callback with.
850
- * @returns {RepoConnection} Returns a new repo-connection.
851
- */
852
- export declare function connect(params: ConnectParams): RepoConnection;
853
- /**
854
- * Creates a connection to several repositories with a given branch and authentication info.
855
- *
856
- * @example-ref examples/node/multiRepoConnect.js
857
- *
858
- * @param {object} params JSON with the parameters.
859
- * @param {object[]} params.sources array of sources to connect to
860
- * @param {object} params.sources.repoId repository id
861
- * @param {object} params.sources.branch branch id
862
- * @param {object} [params.sources.user] User to execute the callback with. Default is the current user.
863
- * @param {string} params.sources.user.login Login of the user.
864
- * @param {string} [params.sources.user.idProvider] Id provider containing the user. By default, all the id providers will be used.
865
- * @param {string[]} [params.sources.principals] Additional principals to execute the callback with.
866
- *
867
- * @returns {MultiRepoConnection} Returns a new multirepo-connection.
868
- */
869
- export interface MultiRepoConnectParams {
870
- sources: ConnectParams[];
871
- }
872
- export declare function multiRepoConnect(params: MultiRepoConnectParams): MultiRepoConnection;
873
- export {};
1
+ /**
2
+ * Functions to get, query and manipulate nodes.
3
+ *
4
+ * @example
5
+ * var nodeLib = require('/lib/xp/node');
6
+ *
7
+ * @module node
8
+ */
9
+ declare global {
10
+ interface XpLibraries {
11
+ '/lib/xp/node': typeof import('./node');
12
+ }
13
+ }
14
+ export interface Bucket {
15
+ [subAggregationName: string]: BucketsAggregation | StatsAggregation | SingleValueMetricAggregation | string | number | undefined;
16
+ key: string;
17
+ docCount: number;
18
+ }
19
+ export interface NumericBucket extends Bucket {
20
+ from?: number;
21
+ to?: number;
22
+ }
23
+ export interface DateBucket extends Bucket {
24
+ from?: string;
25
+ to?: string;
26
+ }
27
+ export interface BucketsAggregation {
28
+ buckets: (DateBucket | NumericBucket)[];
29
+ }
30
+ export interface StatsAggregation {
31
+ count: number;
32
+ min: number;
33
+ max: number;
34
+ avg: number;
35
+ sum: number;
36
+ }
37
+ export interface SingleValueMetricAggregation {
38
+ value: number;
39
+ }
40
+ export declare type AggregationsResult = BucketsAggregation | StatsAggregation | SingleValueMetricAggregation;
41
+ export declare type Aggregation = TermsAggregation | HistogramAggregation | DateHistogramAggregation | NumericRangeAggregation | DateRangeAggregation | StatsAggregation | GeoDistanceAggregation | MinAggregation | MaxAggregation | ValueCountAggregation;
42
+ export interface TermsAggregation {
43
+ terms: {
44
+ field: string;
45
+ order?: string;
46
+ size?: number;
47
+ minDocCount?: number;
48
+ };
49
+ aggregations?: {
50
+ [subAggregations: string]: Aggregation;
51
+ };
52
+ }
53
+ export interface HistogramAggregation {
54
+ histogram: {
55
+ field: string;
56
+ order?: string;
57
+ interval?: number;
58
+ extendedBoundMin?: number;
59
+ extendedBoundMax?: number;
60
+ minDocCount?: number;
61
+ };
62
+ aggregations?: {
63
+ [subAggregations: string]: Aggregation;
64
+ };
65
+ }
66
+ export interface DateHistogramAggregation {
67
+ dateHistogram: {
68
+ field: string;
69
+ interval?: string;
70
+ minDocCount?: number;
71
+ format: string;
72
+ };
73
+ aggregations?: {
74
+ [subAggregations: string]: Aggregation;
75
+ };
76
+ }
77
+ export interface NumericRange {
78
+ from?: number;
79
+ to?: number;
80
+ key?: string;
81
+ }
82
+ export interface NumericRangeAggregation {
83
+ range: {
84
+ field: string;
85
+ ranges?: NumericRange[];
86
+ };
87
+ aggregations?: {
88
+ [subAggregations: string]: Aggregation;
89
+ };
90
+ }
91
+ export interface NumericRangeAggregation {
92
+ range: {
93
+ field: string;
94
+ ranges?: NumericRange[];
95
+ };
96
+ aggregations?: {
97
+ [subAggregations: string]: Aggregation;
98
+ };
99
+ }
100
+ export interface DateRange {
101
+ from?: string;
102
+ to?: string;
103
+ key?: string;
104
+ }
105
+ export interface DateRangeAggregation {
106
+ dateRange: {
107
+ field: string;
108
+ format: string;
109
+ ranges: DateRange[];
110
+ };
111
+ aggregations?: {
112
+ [subAggregations: string]: Aggregation;
113
+ };
114
+ }
115
+ export interface StatsAggregation {
116
+ stats: {
117
+ field: string;
118
+ };
119
+ }
120
+ export interface GeoDistanceAggregation {
121
+ geoDistance: {
122
+ field: string;
123
+ unit: string;
124
+ origin?: {
125
+ lat: string;
126
+ lon: string;
127
+ };
128
+ ranges?: NumericRange[];
129
+ };
130
+ }
131
+ export interface MinAggregation {
132
+ min: {
133
+ field: string;
134
+ };
135
+ }
136
+ export interface MaxAggregation {
137
+ max: {
138
+ field: string;
139
+ };
140
+ }
141
+ export interface ValueCountAggregation {
142
+ count: {
143
+ field: string;
144
+ };
145
+ }
146
+ export interface Highlight {
147
+ encoder?: 'default' | 'html';
148
+ tagsSchema?: 'styled';
149
+ fragmenter?: 'simple' | 'span';
150
+ fragmentSize?: number;
151
+ noMatchSize?: number;
152
+ numberOfFragments?: number;
153
+ order?: 'score' | 'none';
154
+ preTag?: string;
155
+ postTag?: string;
156
+ requireFieldMatch?: boolean;
157
+ properties?: Record<string, Highlight>;
158
+ }
159
+ export interface HighlightResult {
160
+ [highlightedFieldName: string]: string[];
161
+ }
162
+ export interface ExistsFilter {
163
+ exists: {
164
+ field: string;
165
+ };
166
+ }
167
+ export interface NotExistsFilter {
168
+ notExists: {
169
+ field: string;
170
+ };
171
+ }
172
+ export interface HasValueFilter {
173
+ hasValue: {
174
+ field: string;
175
+ values: unknown[];
176
+ };
177
+ }
178
+ export interface IdsFilter {
179
+ ids: {
180
+ values: string[];
181
+ };
182
+ }
183
+ export interface BooleanFilter {
184
+ boolean: {
185
+ must?: Filter[];
186
+ mustNot?: Filter[];
187
+ should?: Filter[];
188
+ };
189
+ }
190
+ export declare type Filter = ExistsFilter | NotExistsFilter | HasValueFilter | IdsFilter | BooleanFilter;
191
+ export declare type Suggestion = TermSuggestion;
192
+ export interface TermSuggestion {
193
+ text: string;
194
+ term: TermSuggestionOptions;
195
+ }
196
+ export interface TermSuggestionOptions {
197
+ field: string;
198
+ analyzer?: string;
199
+ sort?: 'score' | 'frequency';
200
+ suggestMode?: 'missing' | 'popular' | 'always';
201
+ stringDistance?: 'internal' | 'damerau_levenshtein' | 'levenshtein' | 'jarowinkler' | 'ngram';
202
+ size?: number | null;
203
+ maxEdits?: number | null;
204
+ prefixLength?: number | null;
205
+ minWordLength?: number | null;
206
+ maxInspections?: number | null;
207
+ minDocFreq?: number | null;
208
+ maxTermFreq?: number | null;
209
+ }
210
+ declare type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
211
+ export declare type DslQueryType = LiteralUnion<'dateTime' | 'time'> | number | boolean;
212
+ export declare type DslOperator = 'OR' | 'AND';
213
+ export interface TermDslExpression {
214
+ field: string;
215
+ value: unknown;
216
+ type?: DslQueryType;
217
+ boost?: number;
218
+ }
219
+ export interface InDslExpression {
220
+ field: string;
221
+ values: unknown[];
222
+ type?: DslQueryType;
223
+ boost?: number;
224
+ }
225
+ export interface LikeDslExpression {
226
+ field: string;
227
+ value: string;
228
+ type?: DslQueryType;
229
+ boost?: number;
230
+ }
231
+ export interface RangeDslExpression {
232
+ field: string;
233
+ type?: DslQueryType;
234
+ lt?: unknown;
235
+ lte?: unknown;
236
+ gt?: unknown;
237
+ gte?: unknown;
238
+ boost?: number;
239
+ }
240
+ export interface PathMatchDslExpression {
241
+ field: string;
242
+ path: string;
243
+ minimumMatch?: number;
244
+ boost?: number;
245
+ }
246
+ export interface MatchAllDslExpression {
247
+ boost?: number;
248
+ }
249
+ export interface FulltextDslExpression {
250
+ fields: string[];
251
+ query: string;
252
+ operator?: DslOperator;
253
+ }
254
+ export interface NgramDslExpression {
255
+ fields: string[];
256
+ query: string;
257
+ operator?: DslOperator;
258
+ }
259
+ export interface StemmedDslExpression {
260
+ fields: string[];
261
+ query: string;
262
+ language: string;
263
+ }
264
+ export interface BooleanDslExpression {
265
+ should?: DslExpression | DslExpression[];
266
+ must?: DslExpression | DslExpression[];
267
+ mustNot?: DslExpression | DslExpression[];
268
+ filter?: DslExpression | DslExpression[];
269
+ }
270
+ export declare type DslExpression = TermDslExpression | InDslExpression | LikeDslExpression | RangeDslExpression | PathMatchDslExpression | MatchAllDslExpression | FulltextDslExpression | NgramDslExpression | BooleanDslExpression | StemmedDslExpression;
271
+ export declare type QueryDsl = {
272
+ boolean: BooleanDslExpression;
273
+ } | {
274
+ ngram: NgramDslExpression;
275
+ } | {
276
+ fulltext: FulltextDslExpression;
277
+ } | {
278
+ matchAll: MatchAllDslExpression;
279
+ } | {
280
+ pathMatch: PathMatchDslExpression;
281
+ } | {
282
+ range: RangeDslExpression;
283
+ } | {
284
+ like: LikeDslExpression;
285
+ } | {
286
+ in: InDslExpression;
287
+ } | {
288
+ term: TermDslExpression;
289
+ };
290
+ export declare type SortDirection = 'ASC' | 'DESC';
291
+ export declare type DistanceUnit = 'm' | 'meters' | 'in' | 'inch' | 'yd' | 'yards' | 'ft' | 'feet' | 'km' | 'kilometers' | 'NM' | 'nmi' | 'nauticalmiles' | 'mm' | 'millimeters' | 'cm' | 'centimeters' | 'mi' | 'miles';
292
+ export interface FieldSortDsl {
293
+ field: string;
294
+ direction?: SortDirection;
295
+ }
296
+ export interface GeoDistanceSortDsl extends FieldSortDsl {
297
+ unit?: DistanceUnit;
298
+ location?: {
299
+ lat: number;
300
+ lon: number;
301
+ };
302
+ }
303
+ export declare type SortDsl = FieldSortDsl | GeoDistanceSortDsl;
304
+ export interface Explanation {
305
+ value: number;
306
+ description: string;
307
+ details: Explanation[];
308
+ }
309
+ export interface NodeQueryResult {
310
+ total: number;
311
+ count: number;
312
+ hits: {
313
+ id: string;
314
+ score: number;
315
+ explanation?: Explanation;
316
+ highlight?: HighlightResult;
317
+ }[];
318
+ aggregations?: AggregationsResult;
319
+ suggestions?: {
320
+ [suggestionName: string]: {
321
+ text: string;
322
+ length: number;
323
+ offset: number;
324
+ options: {
325
+ text: string;
326
+ score: number;
327
+ freq?: number;
328
+ }[];
329
+ }[];
330
+ }[];
331
+ }
332
+ export interface NodeMultiRepoQueryResult {
333
+ total: number;
334
+ count: number;
335
+ hits: {
336
+ id: string;
337
+ score: number;
338
+ repoId: string;
339
+ branch: string;
340
+ explanation?: Explanation;
341
+ highlight?: HighlightResult;
342
+ }[];
343
+ aggregations?: AggregationsResult;
344
+ }
345
+ interface MultiRepoNodeHandler {
346
+ query(params: QueryNodeHandlerParams): NodeMultiRepoQueryResult;
347
+ }
348
+ interface NodeHandler {
349
+ create(node: ScriptValue): Node;
350
+ modify(editor: ScriptValue, key: string): Node;
351
+ setChildOrder(key: string, childOrder: string): Node;
352
+ get(params: GetNodeHandlerParams): Node | Node[] | null;
353
+ delete(keys: string[]): boolean;
354
+ push(params: PushNodeHandlerParams): PushNodesResult;
355
+ diff(params: DiffBranchesHandlerParams): object;
356
+ move(source: string, target: string): boolean;
357
+ query(params: QueryNodeHandlerParams): NodeQueryResult;
358
+ exist(key: string): boolean;
359
+ findVersions(params: FindVersionsHandlerParams): NodeVersionsQueryResult;
360
+ getActiveVersion(key: string): NodeVersion | null;
361
+ setActiveVersion(key: string, versionId: string): boolean;
362
+ findChildren(params: FindChildrenHandlerParams): FindNodesByParentResult;
363
+ commit(keys: string[], message?: string | null): object;
364
+ getCommit(commitId: string): NodeCommit | null;
365
+ setRootPermissions(v: ScriptValue): object;
366
+ getBinary(key: string, binaryReference?: string | null): object;
367
+ refresh(mode: RefreshMode): object;
368
+ }
369
+ export interface CreateNodeParams {
370
+ _name?: string;
371
+ _parentPath?: string;
372
+ _indexConfig?: NodeConfigEntry;
373
+ _permissions?: AccessControlEntry[];
374
+ _inheritsPermissions?: boolean;
375
+ _manualOrderValue?: number;
376
+ _childOrder?: string;
377
+ }
378
+ export interface ModifyNodeParams {
379
+ key: string;
380
+ editor: (node: Node) => Node;
381
+ }
382
+ export interface GetNodeParams {
383
+ key: string;
384
+ versionId?: string;
385
+ }
386
+ interface GetNodeHandlerParams {
387
+ add(key: string): void;
388
+ add(key: string, versionId?: string | null): void;
389
+ }
390
+ export interface PushNodeParams {
391
+ key?: string | null;
392
+ keys?: string[] | null;
393
+ target: string;
394
+ includeChildren?: boolean;
395
+ resolve?: boolean;
396
+ exclude?: string[] | null;
397
+ }
398
+ export interface PushNodesResult {
399
+ success: string[];
400
+ failed: {
401
+ id: string;
402
+ reason: string;
403
+ }[];
404
+ deleted: string[];
405
+ }
406
+ interface PushNodeHandlerParams {
407
+ setKey(value?: string | null): void;
408
+ setKeys(value?: string[] | null): void;
409
+ setTargetBranch(value: string): void;
410
+ setIncludeChildren(value: boolean): void;
411
+ setExclude(value?: string[] | null): void;
412
+ setResolve(value: boolean): void;
413
+ }
414
+ export interface DiffBranchesParams {
415
+ key: string;
416
+ target: string;
417
+ includeChildren: boolean;
418
+ }
419
+ interface DiffBranchesHandlerParams {
420
+ setKey(value: string): void;
421
+ setTargetBranch(value: string): void;
422
+ setIncludeChildren(value: boolean): void;
423
+ }
424
+ export interface GetBinaryParams {
425
+ key: string;
426
+ binaryReference?: string | null;
427
+ }
428
+ export interface MoveNodeParams {
429
+ source: string;
430
+ target: string;
431
+ }
432
+ export interface SetChildOrderParams {
433
+ key: string;
434
+ childOrder: string;
435
+ }
436
+ export interface QueryNodeParams {
437
+ start?: number;
438
+ count?: number;
439
+ query: QueryDsl | string;
440
+ sort?: string | SortDsl | SortDsl[];
441
+ filters?: Filter | Filter[];
442
+ aggregations?: Record<string, Aggregation>;
443
+ suggestions?: Record<string, Suggestion>;
444
+ highlight: Highlight;
445
+ explain: boolean;
446
+ }
447
+ interface QueryNodeHandlerParams {
448
+ setStart(value?: number | null): void;
449
+ setCount(value?: number | null): void;
450
+ setQuery(value: ScriptValue): void;
451
+ setSort(value: ScriptValue): void;
452
+ setAggregations(value: ScriptValue): void;
453
+ setSuggestions(value: ScriptValue): void;
454
+ setHighlight(value: ScriptValue): void;
455
+ setFilters(value: ScriptValue): void;
456
+ setExplain(value: boolean): void;
457
+ }
458
+ export interface FindVersionsParams {
459
+ key: string;
460
+ start?: number | null;
461
+ count?: number | null;
462
+ }
463
+ interface FindVersionsHandlerParams {
464
+ setKey(key: string): void;
465
+ setStart(start?: number | null): void;
466
+ setCount(count?: number | null): void;
467
+ }
468
+ export interface NodeVersion {
469
+ versionId: string;
470
+ nodeId: string;
471
+ nodePath: string;
472
+ timestamp: string;
473
+ commitId: string;
474
+ }
475
+ export interface NodeVersionsQueryResult {
476
+ total: number;
477
+ count: number;
478
+ hits: NodeVersion[];
479
+ }
480
+ export interface GetActiveVersionParams {
481
+ key: string;
482
+ }
483
+ export interface SetActiveVersionParams {
484
+ key: string;
485
+ versionId: string;
486
+ }
487
+ export interface FindChildrenParams {
488
+ parentKey: string;
489
+ start?: number | null;
490
+ count?: number | null;
491
+ childOrder: string;
492
+ countOnly: boolean;
493
+ recursive: boolean;
494
+ }
495
+ interface FindChildrenHandlerParams {
496
+ setParentKey(parentKey: string): void;
497
+ setStart(start?: number | null): void;
498
+ setCount(count?: number | null): void;
499
+ setChildOrder(childOrder: string): void;
500
+ setCountOnly(countOnly: boolean): void;
501
+ setRecursive(recursive: boolean): void;
502
+ }
503
+ export interface FindNodesByParentResult {
504
+ total: number;
505
+ count: number;
506
+ hits: {
507
+ id: string;
508
+ }[];
509
+ }
510
+ export declare type RefreshMode = 'SEARCH' | 'STORAGE' | 'ALL';
511
+ export interface GetCommitParams {
512
+ id: string;
513
+ }
514
+ export interface NodeCommit {
515
+ id: string;
516
+ message: string;
517
+ committer: string;
518
+ timestamp: string;
519
+ }
520
+ export interface CommitParams {
521
+ keys: string | string[];
522
+ message?: string;
523
+ }
524
+ export interface SetRootPermissionsParams {
525
+ _permissions: AccessControlEntry[];
526
+ _inheritsPermissions: boolean;
527
+ }
528
+ export declare type Permission = 'READ' | 'CREATE' | 'MODIFY' | 'DELETE' | 'PUBLISH' | 'READ_PERMISSIONS' | 'WRITE_PERMISSIONS';
529
+ export interface AccessControlEntry {
530
+ principal: string;
531
+ allow?: Permission[];
532
+ deny?: Permission[];
533
+ }
534
+ export interface NodeIndexConfig {
535
+ analyzer: string;
536
+ default?: NodeConfigEntry;
537
+ configs: {
538
+ path: string;
539
+ config: NodeConfigEntry;
540
+ }[];
541
+ }
542
+ export interface NodeConfigEntry {
543
+ decideByType: boolean;
544
+ enabled: boolean;
545
+ nGram: boolean;
546
+ fulltext: boolean;
547
+ includeInAllText: boolean;
548
+ path: boolean;
549
+ indexValueProcessors: string[];
550
+ languages: string[];
551
+ }
552
+ export interface Node {
553
+ [key: string]: unknown;
554
+ _id: string;
555
+ _name: string;
556
+ _path: string;
557
+ _childOrder: string;
558
+ _state: string;
559
+ _nodeType: string;
560
+ _versionKey: string;
561
+ _manualOrderValue: number;
562
+ _ts: string;
563
+ _parentPath: string;
564
+ _indexConfig: NodeIndexConfig;
565
+ _inheritsPermissions: boolean;
566
+ _permissions?: AccessControlEntry[];
567
+ }
568
+ /**
569
+ * Creates a new repo-connection.
570
+ *
571
+ * @returns {*} native Native repo-connection object.
572
+ * @constructor
573
+ */
574
+ export declare class RepoConnection {
575
+ private nodeHandler;
576
+ constructor(nodeHandler: NodeHandler);
577
+ /**
578
+ * This function creates a node.
579
+ *
580
+ *
581
+ * To create a content where the name is not important and there could be multiple instances under the same parent content,
582
+ * skip the `name` parameter and specify a `displayName`.
583
+ *
584
+ * @example-ref examples/node/create-1.js
585
+ * @example-ref examples/node/create-2.js
586
+ *
587
+ * @param {object} params JSON with the parameters.
588
+ * @param {string} [params._name] Name of content.
589
+ * @param {string} [params._parentPath] Path to place content under.
590
+ * @param {object} [params._indexConfig] How the document should be indexed. A default value "byType" will be set if no value specified.
591
+ * @param {object} [params._permissions] The access control list for the node. By default the creator will have full access
592
+ * @param {boolean} [params._inheritsPermissions] true if the permissions should be inherited from the node parent. Default is false.
593
+ * @param {number} [params._manualOrderValue] Value used to order document when ordering by parent and child-order is set to manual
594
+ * @param {string} [params._childOrder] Default ordering of children when doing getChildren if no order is given in query
595
+ *
596
+ * @returns {object} Node created as JSON.
597
+ */
598
+ create(params: CreateNodeParams): Node;
599
+ /**
600
+ * This function modifies a node.
601
+ *
602
+ * @example-ref examples/node/modify.js
603
+ *
604
+ * @param {object} params JSON with the parameters.
605
+ * @param {string} params.key Path or id to the node.
606
+ * @param {function} params.editor Editor callback function.
607
+ *
608
+ * @returns {object} Modified node as JSON.
609
+ */
610
+ modify(params: ModifyNodeParams): Node;
611
+ /**
612
+ * This function fetches nodes.
613
+ *
614
+ * @example-ref examples/node/get-1.js
615
+ * @example-ref examples/node/get-2.js
616
+ * @example-ref examples/node/get-3.js
617
+ *
618
+ * @param {...(string|string[]|object|object[])} keys to fetch. Each argument could be an id, a path, an object with key and versionId properties or an array of them.
619
+ *
620
+ * @returns {object} The node or node array (as JSON) fetched from the repository.
621
+ */
622
+ get(...keys: (string | string[] | GetNodeParams | GetNodeParams[])[]): Node | Node[] | null;
623
+ /**
624
+ * This function deletes a node or nodes.
625
+ *
626
+ * @example-ref examples/node/delete.js
627
+ *
628
+ * @param {...(string|string[])} keys Keys to delete. Each argument could be an id, a path or an array of the two.
629
+ *
630
+ * @returns {boolean} True if deleted, false otherwise.
631
+ */
632
+ delete(...keys: (string | string[])[]): boolean;
633
+ /**
634
+ * This function push a node to a given branch.
635
+ *
636
+ * @example-ref examples/node/push-1.js
637
+ * @example-ref examples/node/push-2.js
638
+ * @example-ref examples/node/push-3.js
639
+ *
640
+ * @param {object} params JSON with the parameters.
641
+ * @param {string} params.key Id or path to the nodes
642
+ * @param {string[]} params.keys Array of ids or paths to the nodes
643
+ * @param {string} params.target Branch to push nodes to.
644
+ * @param {boolean} [params.includeChildren=false] Also push children of given nodes
645
+ * @param {boolean} [params.resolve=true] Resolve dependencies before pushing, meaning that references will also be pushed
646
+ * @param {string[]} [params.exclude] Array of ids or paths to nodes not to be pushed (nodes needed to maintain data integrity (e.g parents must be present in target) will be pushed anyway)
647
+ *
648
+ * @returns {object} PushNodesResult
649
+ */
650
+ push(params: PushNodeParams): PushNodesResult;
651
+ /**
652
+ * This function resolves the differences for node between current and given branch
653
+ *
654
+ * @example-ref examples/node/diff-1.js
655
+ *
656
+ * @param {object} params JSON with the parameters.
657
+ * @param {string} params.key Path or id to resolve diff for
658
+ * @param {string} params.target Branch to diff against.
659
+ * @param {boolean} [params.includeChildren=false] also resolve dependencies for children
660
+ *
661
+ * @returns {object} DiffNodesResult
662
+ */
663
+ diff(params: DiffBranchesParams): object;
664
+ /**
665
+ * This function returns a binary stream.
666
+ *
667
+ * @example-ref examples/node/getBinary.js
668
+ * @param {string} params.key Path or id to the node.
669
+ * @param {string} params.binaryReference to the binary.
670
+ *
671
+ * @returns {*} Stream of the binary.
672
+ */
673
+ getBinary(params: GetBinaryParams): object;
674
+ /**
675
+ * Rename a node or move it to a new path.
676
+ *
677
+ * @example-ref examples/node/move-1.js
678
+ * @example-ref examples/node/move-2.js
679
+ * @example-ref examples/node/move-3.js
680
+ *
681
+ * @param {object} params JSON with the parameters.
682
+ * @param {string} params.source Path or id of the node to be moved or renamed.
683
+ * @param {string} params.target New path or name for the node. If the target ends in slash '/', it specifies the parent path where to be moved. Otherwise it means the new desired path or name for the node.
684
+ *
685
+ * @returns {boolean} True if the node was successfully moved or renamed, false otherwise.
686
+ */
687
+ move(params: MoveNodeParams): boolean;
688
+ /**
689
+ * Set node's children order
690
+ *
691
+ * @example-ref examples/node/setChildOrder.js
692
+ *
693
+ * @param {object} params JSON with the parameters.
694
+ * @param {string} params.key node's path or id
695
+ * @param {string} params.childOrder children order
696
+ * @returns {object} updated node
697
+ */
698
+ setChildOrder(params: SetChildOrderParams): Node;
699
+ /**
700
+ * This command queries nodes.
701
+ *
702
+ * @example-ref examples/node/query.js
703
+ *
704
+ * @param {object} params JSON with the parameters.
705
+ * @param {number} [params.start=0] Start index (used for paging).
706
+ * @param {number} [params.count=10] Number of contents to fetch.
707
+ * @param {string|object} [params.query] Query expression.
708
+ * @param {object} [params.filters] Query filters
709
+ * @param {string|object|object[]} [params.sort='_score DESC'] Sorting expression.
710
+ * @param {string} [params.aggregations] Aggregations expression.
711
+ * @param {string} [params.highlight] Highlighting parameters.
712
+ * @param {boolean} [params.explain=false] Return score calculation explanation.
713
+ * @returns {object} Result of query.
714
+ */
715
+ query(params: QueryNodeParams): object;
716
+ /**
717
+ * Check if node exists.
718
+ *
719
+ * @example-ref examples/node/exists.js
720
+ *
721
+ * @param {string} [key] node path or id.
722
+ *
723
+ * @returns {boolean} True if exist, false otherwise.
724
+ */
725
+ exists(key: string): boolean;
726
+ /**
727
+ * This function returns node versions.
728
+ *
729
+ * @example-ref examples/node/findVersions.js
730
+ * @param {object} params JSON parameters.
731
+ * @param {string} params.key Path or ID of the node.
732
+ * @param {number} [params.start=0] Start index (used for paging).
733
+ * @param {number} [params.count=10] Number of node versions to fetch.
734
+ *
735
+ * @returns {object[]} Node versions.
736
+ */
737
+ findVersions(params: FindVersionsParams): NodeVersionsQueryResult;
738
+ /**
739
+ * This function returns the active version of a node.
740
+ *
741
+ * @example-ref examples/node/getActiveVersion.js
742
+ * @param {object} params JSON parameters.
743
+ * @param {string} params.key Path or ID of the node.
744
+ *
745
+ * @returns {object} Active content versions per branch.
746
+ */
747
+ getActiveVersion(params: GetActiveVersionParams): NodeVersion | null;
748
+ /**
749
+ * This function sets the active version of a node.
750
+ *
751
+ * @example-ref examples/node/setActiveVersion.js
752
+ * @param {object} params JSON parameters.
753
+ * @param {string} params.key Path or ID of the node.
754
+ * @param {string} params.versionId Version to set as active.
755
+ *
756
+ * @returns {boolean} True if deleted, false otherwise.
757
+ */
758
+ setActiveVersion(params: SetActiveVersionParams): boolean;
759
+ /**
760
+ * Get children for given node.
761
+ *
762
+ * @example-ref examples/node/findChildren.js
763
+ *
764
+ * @param {object} params JSON with the parameters.
765
+ * @param {number} params.parentKey path or id of parent to get children of
766
+ * @param {number} [params.start=0] Start index (used for paging).
767
+ * @param {number} [params.count=10] Number of contents to fetch.
768
+ * @param {string} [params.childOrder] How to order the children (defaults to value stored on parent)
769
+ * @param {boolean} [params.countOnly=false] Optimize for count children only ( no children returned )
770
+ * @param {boolean} [params.recursive=false] Do recursive fetching of all children of children
771
+ * @returns {object} Result of getChildren.
772
+ */
773
+ findChildren(params: FindChildrenParams): FindNodesByParentResult;
774
+ /**
775
+ * Refresh the index for the current repoConnection
776
+ *
777
+ * @example-ref examples/node/refresh.js
778
+ *
779
+ * @param {string} [mode]=ALL Refresh all (ALL) data, or just the search-index (SEARCH) or the storage-index (STORAGE)
780
+ */
781
+ refresh(mode: RefreshMode): void;
782
+ /**
783
+ * Set the root node permissions and inherit.
784
+ *
785
+ * @example-ref examples/node/modifyRootPermissions.js
786
+ *
787
+ * @param {object} params JSON with the parameters.
788
+ * @param {object} params._permissions the permission json
789
+ * @param {object} [params._inheritsPermissions]= true if the permissions should be inherited to children
790
+ *
791
+ * @returns {object} Updated root-node as JSON.
792
+ */
793
+ setRootPermissions(params: SetRootPermissionsParams): object;
794
+ /**
795
+ * This function commits the active version of nodes.
796
+ *
797
+ * @example-ref examples/node/commit.js
798
+ *
799
+ * @param {...(string|string[])} params.keys Node keys to commit. Each argument could be an id, a path or an array of the two. Prefer the usage of ID rather than paths.
800
+ * @param {string} [params.message] Commit message.
801
+ *
802
+ * @returns {object} Commit object.
803
+ */
804
+ commit(params: CommitParams): object;
805
+ /**
806
+ * This function fetches commit by id.
807
+ *
808
+ * @example-ref examples/node/commit.js
809
+ *
810
+ * @param {string} params.id existing commit id.
811
+ *
812
+ * @returns {object} Commit object.
813
+ */
814
+ getCommit(params: GetCommitParams): NodeCommit | null;
815
+ }
816
+ /**
817
+ * Creates a new multirepo-connection.
818
+ *
819
+ * @returns {*} native Native multirepo-connection object.
820
+ * @constructor
821
+ */
822
+ export declare class MultiRepoConnection {
823
+ private multiRepoConnection;
824
+ constructor(multiRepoConnection: MultiRepoNodeHandler);
825
+ /**
826
+ * This command queries nodes in a multi-repo connection.
827
+ *
828
+ * @example-ref examples/node/multiRepoQuery.js
829
+ *
830
+ * @param {object} params JSON with the parameters.
831
+ * @param {number} [params.start=0] Start index (used for paging).
832
+ * @param {number} [params.count=10] Number of contents to fetch.
833
+ * @param {string|object} [params.query] Query expression.
834
+ * @param {object} [params.filters] Query filters
835
+ * @param {string|object|object[]} [params.sort='_score DESC'] Sorting expression.
836
+ * @param {string} [params.aggregations] Aggregations expression.
837
+ * @param {string} [params.highlight] Highlighting parameters.
838
+ * @param {boolean} [params.explain=false] Return score calculation explanation.
839
+ * @returns {object} Result of query.
840
+ */
841
+ query(params: QueryNodeParams): object;
842
+ }
843
+ export interface ConnectParams {
844
+ repoId: string;
845
+ branch: string;
846
+ principals: string[];
847
+ user: {
848
+ login: string;
849
+ idProvider: string;
850
+ };
851
+ }
852
+ /**
853
+ * Creates a connection to a repository with a given branch and authentication info.
854
+ *
855
+ * @example-ref examples/node/connect.js
856
+ *
857
+ * @param {object} params JSON with the parameters.
858
+ * @param {object} params.repoId repository id
859
+ * @param {object} params.branch branch id
860
+ * @param {object} [params.user] User to execute the callback with. Default is the current user.
861
+ * @param {string} params.user.login Login of the user.
862
+ * @param {string} [params.user.idProvider] Id provider containing the user. By default, all the id providers will be used.
863
+ * @param {string[]} [params.principals] Additional principals to execute the callback with.
864
+ * @returns {RepoConnection} Returns a new repo-connection.
865
+ */
866
+ export declare function connect(params: ConnectParams): RepoConnection;
867
+ /**
868
+ * Creates a connection to several repositories with a given branch and authentication info.
869
+ *
870
+ * @example-ref examples/node/multiRepoConnect.js
871
+ *
872
+ * @param {object} params JSON with the parameters.
873
+ * @param {object[]} params.sources array of sources to connect to
874
+ * @param {object} params.sources.repoId repository id
875
+ * @param {object} params.sources.branch branch id
876
+ * @param {object} [params.sources.user] User to execute the callback with. Default is the current user.
877
+ * @param {string} params.sources.user.login Login of the user.
878
+ * @param {string} [params.sources.user.idProvider] Id provider containing the user. By default, all the id providers will be used.
879
+ * @param {string[]} [params.sources.principals] Additional principals to execute the callback with.
880
+ *
881
+ * @returns {MultiRepoConnection} Returns a new multirepo-connection.
882
+ */
883
+ export interface MultiRepoConnectParams {
884
+ sources: ConnectParams[];
885
+ }
886
+ export declare function multiRepoConnect(params: MultiRepoConnectParams): MultiRepoConnection;
887
+ export {};