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

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 (3) hide show
  1. package/README.md +11 -29
  2. package/node.d.ts +55 -378
  3. package/package.json +4 -1
package/README.md CHANGED
@@ -5,38 +5,23 @@
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- npm i --save-dev @enonic/lib-node
8
+ npm i --save-dev @enonic-types/lib-node
9
9
  ```
10
10
 
11
11
  ## Use
12
12
 
13
- Add the corresponding types to your `tsconfig.json` file that is used for application's server-side TypeScript code.
14
-
15
- `tsconfig.json`
16
-
17
- ```json
18
- {
19
- "compilerOptions": {
20
- "types": [
21
- "@enonic-types/lib-node"
22
- ]
23
- }
24
- }
25
- ```
26
-
27
13
  ### Require and custom imports
28
14
 
29
- To make `require` work out of box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP global
30
- objects, e.g. `log`, `app`, `__`, etc, requiring library by the default path will return typed object.
15
+ To make `require` work out of the box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
16
+ global objects, e.g. `log`, `app`, `__`, etc, requiring a library by the default path will return typed object.
31
17
 
32
18
  `tsconfig.json`
33
19
 
34
- ```diff
20
+ ```json
35
21
  {
36
22
  "compilerOptions": {
37
23
  "types": [
38
- + "@enonic-types/global"
39
- "@enonic-types/lib-node"
24
+ "@enonic-types/global"
40
25
  ]
41
26
  }
42
27
  }
@@ -49,7 +34,7 @@ const {connect, multiRepoConnect} = require('/lib/xp/node');
49
34
  ```
50
35
 
51
36
  More detailed explanation on how it works and how to type custom import function can be
52
- found [here](https://github.com/enonic/xp/tree/master/modules/lib/typescript/README.md).
37
+ found [here](https://developer.enonic.com/docs/xp/stable/api).
53
38
 
54
39
  ### ES6-style import
55
40
 
@@ -58,16 +43,13 @@ types mapping to your configuration.
58
43
 
59
44
  `tsconfig.json`
60
45
 
61
- ```diff
46
+ ```json
62
47
  {
63
48
  "compilerOptions": {
64
- "types": [
65
- "@enonic-types/lib-node"
66
- ]
67
- + "baseUrl": "./",
68
- + "paths": {
69
- + "/lib/xp/node": ["node_modules/@enonic-types/lib-node"],
70
- + }
49
+ "baseUrl": "./",
50
+ "paths": {
51
+ "/lib/xp/node": ["node_modules/@enonic-types/lib-node"]
52
+ }
71
53
  }
72
54
  }
73
55
  ```
package/node.d.ts CHANGED
@@ -11,6 +11,11 @@ declare global {
11
11
  '/lib/xp/node': typeof import('./node');
12
12
  }
13
13
  }
14
+ import type { PrincipalKey } from '@enonic-types/core';
15
+ export type { PrincipalKey, UserKey, GroupKey, RoleKey } from '@enonic-types/core';
16
+ declare type WithRequiredProperty<T, K extends keyof T> = T & {
17
+ [P in K]-?: T[P];
18
+ };
14
19
  export interface Bucket {
15
20
  [subAggregationName: string]: BucketsAggregation | StatsAggregation | SingleValueMetricAggregation | string | number | undefined;
16
21
  key: string;
@@ -46,9 +51,7 @@ export interface TermsAggregation {
46
51
  size?: number;
47
52
  minDocCount?: number;
48
53
  };
49
- aggregations?: {
50
- [subAggregations: string]: Aggregation;
51
- };
54
+ aggregations?: Record<string, Aggregation>;
52
55
  }
53
56
  export interface HistogramAggregation {
54
57
  histogram: {
@@ -59,9 +62,7 @@ export interface HistogramAggregation {
59
62
  extendedBoundMax?: number;
60
63
  minDocCount?: number;
61
64
  };
62
- aggregations?: {
63
- [subAggregations: string]: Aggregation;
64
- };
65
+ aggregations?: Record<string, Aggregation>;
65
66
  }
66
67
  export interface DateHistogramAggregation {
67
68
  dateHistogram: {
@@ -70,9 +71,7 @@ export interface DateHistogramAggregation {
70
71
  minDocCount?: number;
71
72
  format: string;
72
73
  };
73
- aggregations?: {
74
- [subAggregations: string]: Aggregation;
75
- };
74
+ aggregations?: Record<string, Aggregation>;
76
75
  }
77
76
  export interface NumericRange {
78
77
  from?: number;
@@ -84,18 +83,14 @@ export interface NumericRangeAggregation {
84
83
  field: string;
85
84
  ranges?: NumericRange[];
86
85
  };
87
- aggregations?: {
88
- [subAggregations: string]: Aggregation;
89
- };
86
+ aggregations?: Record<string, Aggregation>;
90
87
  }
91
88
  export interface NumericRangeAggregation {
92
89
  range: {
93
90
  field: string;
94
91
  ranges?: NumericRange[];
95
92
  };
96
- aggregations?: {
97
- [subAggregations: string]: Aggregation;
98
- };
93
+ aggregations?: Record<string, Aggregation>;
99
94
  }
100
95
  export interface DateRange {
101
96
  from?: string;
@@ -108,9 +103,7 @@ export interface DateRangeAggregation {
108
103
  format: string;
109
104
  ranges: DateRange[];
110
105
  };
111
- aggregations?: {
112
- [subAggregations: string]: Aggregation;
113
- };
106
+ aggregations?: Record<string, Aggregation>;
114
107
  }
115
108
  export interface StatsAggregation {
116
109
  stats: {
@@ -262,12 +255,12 @@ export interface StemmedDslExpression {
262
255
  language: string;
263
256
  }
264
257
  export interface BooleanDslExpression {
265
- should?: DslExpression | DslExpression[];
266
- must?: DslExpression | DslExpression[];
267
- mustNot?: DslExpression | DslExpression[];
268
- filter?: DslExpression | DslExpression[];
258
+ should?: QueryDsl | QueryDsl[];
259
+ must?: QueryDsl | QueryDsl[];
260
+ mustNot?: QueryDsl | QueryDsl[];
261
+ filter?: QueryDsl | QueryDsl[];
262
+ boost?: number;
269
263
  }
270
- export declare type DslExpression = TermDslExpression | InDslExpression | LikeDslExpression | RangeDslExpression | PathMatchDslExpression | MatchAllDslExpression | FulltextDslExpression | NgramDslExpression | BooleanDslExpression | StemmedDslExpression;
271
264
  export declare type QueryDsl = {
272
265
  boolean: BooleanDslExpression;
273
266
  } | {
@@ -329,44 +322,13 @@ export interface NodeQueryResult {
329
322
  }[];
330
323
  }[];
331
324
  }
332
- export interface NodeMultiRepoQueryResult {
333
- total: number;
334
- count: number;
325
+ export declare type NodeMultiRepoQueryResult = NodeQueryResult & {
335
326
  hits: {
336
- id: string;
337
- score: number;
338
327
  repoId: string;
339
328
  branch: string;
340
- explanation?: Explanation;
341
- highlight?: HighlightResult;
342
329
  }[];
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 {
330
+ };
331
+ export declare type CreateNodeParams<NodeData = unknown> = {
370
332
  _name?: string;
371
333
  _parentPath?: string;
372
334
  _indexConfig?: NodeConfigEntry;
@@ -374,19 +336,15 @@ export interface CreateNodeParams {
374
336
  _inheritsPermissions?: boolean;
375
337
  _manualOrderValue?: number;
376
338
  _childOrder?: string;
377
- }
378
- export interface ModifyNodeParams {
339
+ } & NodeData;
340
+ export interface ModifyNodeParams<NodeData = unknown> {
379
341
  key: string;
380
- editor: (node: Node) => Node;
342
+ editor: (node: Node<NodeData>) => Node<NodeData>;
381
343
  }
382
344
  export interface GetNodeParams {
383
345
  key: string;
384
346
  versionId?: string;
385
347
  }
386
- interface GetNodeHandlerParams {
387
- add(key: string): void;
388
- add(key: string, versionId?: string | null): void;
389
- }
390
348
  export interface PushNodeParams {
391
349
  key?: string | null;
392
350
  keys?: string[] | null;
@@ -403,23 +361,16 @@ export interface PushNodesResult {
403
361
  }[];
404
362
  deleted: string[];
405
363
  }
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
364
  export interface DiffBranchesParams {
415
365
  key: string;
416
366
  target: string;
417
367
  includeChildren: boolean;
418
368
  }
419
- interface DiffBranchesHandlerParams {
420
- setKey(value: string): void;
421
- setTargetBranch(value: string): void;
422
- setIncludeChildren(value: boolean): void;
369
+ export interface DiffBranchesResult {
370
+ diff: {
371
+ id: string;
372
+ status: string;
373
+ }[];
423
374
  }
424
375
  export interface GetBinaryParams {
425
376
  key: string;
@@ -436,35 +387,19 @@ export interface SetChildOrderParams {
436
387
  export interface QueryNodeParams {
437
388
  start?: number;
438
389
  count?: number;
439
- query: QueryDsl | string;
390
+ query?: QueryDsl | string;
440
391
  sort?: string | SortDsl | SortDsl[];
441
392
  filters?: Filter | Filter[];
442
393
  aggregations?: Record<string, Aggregation>;
443
394
  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;
395
+ highlight?: Highlight;
396
+ explain?: boolean;
457
397
  }
458
398
  export interface FindVersionsParams {
459
399
  key: string;
460
400
  start?: number | null;
461
401
  count?: number | null;
462
402
  }
463
- interface FindVersionsHandlerParams {
464
- setKey(key: string): void;
465
- setStart(start?: number | null): void;
466
- setCount(count?: number | null): void;
467
- }
468
403
  export interface NodeVersion {
469
404
  versionId: string;
470
405
  nodeId: string;
@@ -492,14 +427,6 @@ export interface FindChildrenParams {
492
427
  countOnly: boolean;
493
428
  recursive: boolean;
494
429
  }
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
430
  export interface FindNodesByParentResult {
504
431
  total: number;
505
432
  count: number;
@@ -549,8 +476,7 @@ export interface NodeConfigEntry {
549
476
  indexValueProcessors: string[];
550
477
  languages: string[];
551
478
  }
552
- export interface Node {
553
- [key: string]: unknown;
479
+ export declare type Node<Data = Record<string, unknown>> = {
554
480
  _id: string;
555
481
  _name: string;
556
482
  _path: string;
@@ -564,289 +490,41 @@ export interface Node {
564
490
  _indexConfig: NodeIndexConfig;
565
491
  _inheritsPermissions: boolean;
566
492
  _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
- */
493
+ } & Data;
494
+ export interface RepoConnection {
495
+ create<NodeData = Record<string, unknown>>(params: CreateNodeParams<NodeData>): Node<NodeData>;
496
+ modify<NodeData = Record<string, unknown>>(params: ModifyNodeParams<NodeData>): Node<NodeData>;
497
+ get<NodeData = Record<string, unknown>>(key: string | GetNodeParams): Node<NodeData> | null;
498
+ get<NodeData = Record<string, unknown>>(keys: (string | GetNodeParams)[]): Node<NodeData>[] | null;
499
+ get<NodeData = Record<string, unknown>>(...keys: (string | GetNodeParams | (string | GetNodeParams)[])[]): Node<NodeData>[] | null;
500
+ get<NodeData = Record<string, unknown>>(...keys: (string | GetNodeParams | (string | GetNodeParams)[])[]): Node<NodeData> | Node<NodeData>[] | null;
501
+ delete(...keys: (string | string[])[]): string[];
650
502
  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
- */
503
+ diff(params: DiffBranchesParams): DiffBranchesResult;
673
504
  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
505
  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
- */
506
+ setChildOrder<NodeData = Record<string, unknown>>(params: SetChildOrderParams): Node<NodeData>;
507
+ query(params: QueryNodeParams): NodeQueryResult;
725
508
  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
509
  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
510
  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
511
  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
512
  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
- */
513
+ refresh(mode?: RefreshMode): void;
514
+ setRootPermissions<NodeData = Record<string, unknown>>(params: SetRootPermissionsParams): Node<NodeData>;
515
+ commit(params: CommitParams): NodeCommit;
814
516
  getCommit(params: GetCommitParams): NodeCommit | null;
815
517
  }
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;
518
+ export interface MultiRepoConnection {
519
+ query(params: QueryNodeParams): NodeMultiRepoQueryResult;
842
520
  }
843
521
  export interface ConnectParams {
844
522
  repoId: string;
845
523
  branch: string;
846
- principals: string[];
847
- user: {
524
+ principals?: PrincipalKey[];
525
+ user?: {
848
526
  login: string;
849
- idProvider: string;
527
+ idProvider?: string;
850
528
  };
851
529
  }
852
530
  /**
@@ -864,6 +542,9 @@ export interface ConnectParams {
864
542
  * @returns {RepoConnection} Returns a new repo-connection.
865
543
  */
866
544
  export declare function connect(params: ConnectParams): RepoConnection;
545
+ export interface MultiRepoConnectParams {
546
+ sources: WithRequiredProperty<ConnectParams, 'principals'>[];
547
+ }
867
548
  /**
868
549
  * Creates a connection to several repositories with a given branch and authentication info.
869
550
  *
@@ -876,12 +557,8 @@ export declare function connect(params: ConnectParams): RepoConnection;
876
557
  * @param {object} [params.sources.user] User to execute the callback with. Default is the current user.
877
558
  * @param {string} params.sources.user.login Login of the user.
878
559
  * @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.
560
+ * @param {string[]} params.sources.principals Principals to execute the callback with.
880
561
  *
881
562
  * @returns {MultiRepoConnection} Returns a new multirepo-connection.
882
563
  */
883
- export interface MultiRepoConnectParams {
884
- sources: ConnectParams[];
885
- }
886
564
  export declare function multiRepoConnect(params: MultiRepoConnectParams): MultiRepoConnection;
887
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enonic-types/lib-node",
3
- "version": "7.11.0-B1",
3
+ "version": "7.11.0-B4",
4
4
  "description": "Type definitions for lib-node.",
5
5
  "types": "node.d.ts",
6
6
  "files": [
@@ -26,6 +26,9 @@
26
26
  "url": "https://github.com/enonic/xp/issues"
27
27
  },
28
28
  "homepage": "https://github.com/enonic/xp/tree/master#readme",
29
+ "dependencies": {
30
+ "@enonic-types/core": "7.11.0-B4"
31
+ },
29
32
  "publishConfig": {
30
33
  "access": "public"
31
34
  }