Node library
Contents
This API provides functions to get, query and manipulate nodes.
|
Do not use Use |
Usage
Add the following to your build.gradle file:
dependencies {
include xplibs.node
}
Add the import statement to your code:
import nodeLib from '/lib/xp/node';
You are now ready to use the API.
Events
Usage of this API produces the following events:
| Event | Occurs when |
|---|---|
|
node.created |
a node is created |
|
node.deleted |
a node is deleted |
|
node.pushed |
a node is pushed to a different branch |
|
node.duplicated |
a node is duplicated |
|
node.updated |
a node is updated |
|
node.moved |
a node is moved in the tree structure |
|
node.renamed |
a node is renamed |
|
node.sorted |
a node is sorted |
|
node.stateUpdated |
a node state is updated |
For information on events, check out the Event library
Functions
connect
Creates a connection to a repository with a given branch and authentication info.
Parameters
connect() takes a single ConnectParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
repoId |
string |
Repository ID. |
|
branch |
string |
Branch ID. |
|
principals |
Optional. Additional principals to execute the connection with. |
|
|
user |
Optional. User to execute the connection as. Defaults to the current user. |
Returns
RepoConnection : A new connection to the repository
Example
import {connect} from '/lib/xp/node';
const connection = connect({
repoId: 'my-repo',
branch: 'master'
});
multiRepoConnect
Creates a connection to several repositories with a given branch and authentication info.
Parameters
multiRepoConnect() takes a single MultiRepoConnectParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
sources |
Repositories to connect to. The |
Returns
MultiRepoConnection : A new connection object for all connected repositories.
Example
import {multiRepoConnect} from '/lib/xp/node';
const searchConnection = multiRepoConnect({
sources: [
{
repoId: 'my-repo',
branch: 'myBranch',
principals: ["role:system.admin"]
},
{
repoId: 'my-other-repo',
branch: 'master',
principals: ["role:system.admin"]
}
]
});
MultiRepoConnection
A MultiRepoConnection makes it possible to search across multiple repositories. The object has only one method: query.
query
Queries nodes in a multi-repo connection.
Parameters
query() takes a single QueryNodeParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
query |
string/object |
Optional. Query string or DSL expression. |
|
start |
number |
Optional. Start index used for paging. Defaults to |
|
count |
number |
Optional. Number of nodes to fetch, used for paging. Defaults to |
|
filters |
object |
Optional. Query filters. |
|
sort |
string/object |
Optional. Sorting string or DSL expression. Defaults to |
|
aggregations |
object |
Optional. Aggregations config. |
|
highlight |
object |
Optional. Highlighting config. |
|
suggestions |
object |
Optional. Term suggestions config, keyed by suggestion name. |
|
explain |
boolean |
Optional. If set to |
Returns
object : (NodeMultiRepoQueryResult) Query result, where each hit also carries its repoId and branch.
Example
const result = multiRepoConnection.query({
start: 0,
count: 2,
query: "startTime > instant('2016-10-11T14:38:54.454Z')",
filters: {
boolean: {
must: {
exists: {
field: "modifiedTime"
}
},
mustNot: {
hasValue: {
field: "myField",
values: [
"cheese",
"fish",
"onion"
]
}
}
},
notExists: {
field: "unwantedField"
},
ids: {
values: ["id1", "id2"]
}
}
});
const expected = {
total: 12902,
count: 2,
hits: [
{
id: "b186d24f-ac38-42ca-a6db-1c1bda6c6c26",
score: 1.2300000190734863,
repoId: "my-repo",
branch: "master"
},
{
id: "350ba4a6-589c-498b-8af0-f183850e1120",
score: 1.399999976158142,
repoId: "com.enonic.cms.default",
branch: "draft"
}
]
}
RepoConnection
A single-repo connection with various methods for working in a single repo.
All the examples below are using a repo connection to execute the functions. The repo connection can be created like this:
import {connect} from '/lib/xp/node';
const repo = connect({
repoId: "com.enonic.cms.default",
branch: "master"
});
commit
Commits the active version of nodes.
Parameters
commit() takes a single CommitParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
keys |
string/string[] |
Node keys to commit. Each key can be an id or a path. Prefer ids over paths. |
|
message |
string |
Optional. Commit message. |
Returns
object : (NodeCommit) A single commit, created and applied to all the nodes referenced in keys.
Example
const result1 = repo.commit({keys: 'nodeId'});
const expected = {
id: "aa1f76bf-4bb9-41be-b166-03561c1555b2",
message: "",
committer: "user:system:anonymous",
timestamp: "2019-01-24T15:16:36.260799Z"
}
const result2 = repo.commit({
keys: ['nodeId', 'nodeId2'],
message: 'Commit message'
});
const expected = {
id: "aa1f76bf-4bb9-41be-b166-03561c1555b2",
message: "Commit message",
committer: "user:system:anonymous",
timestamp: "2019-01-24T15:19:30.818029Z"
}
create
Creates a node. To create a node where the name is not important and there can be multiple instances under the same parent, skip the _name property and specify a displayName.
Parameters
create() takes a single CreateNodeParams object. Alongside the node’s own data, it accepts these reserved properties:
| Name | Type | Description |
|---|---|---|
|
|
string |
Optional. Name of the node. |
|
|
string |
Optional. Path to place the node under. |
|
|
object |
|
|
|
object[] |
Optional. The access control list for the node. By default the creator will have full access. |
|
|
boolean |
Optional. Set to |
|
|
number |
Optional. Value used to order the document when ordering by parent and child-order is set to manual. |
|
|
string |
Optional. Default ordering of children when calling |
Returns
object : (Node) The created node.
Example
repo connection:
const result1 = repo.create({
_name: 'nerd',
displayName: 'Carpenter and IT expert',
likes: 'Plywood',
numberOfUselessGadgets: 123
});
const expected = {
_id: "2f0d5c09-39fe-4746-9754-74491d75a185",
_name: "nerd",
_path: "/nerd",
_childOrder: "_ts DESC",
_indexConfig: {
default: {
decideByType: true,
enabled: true,
nGram: false,
fulltext: false,
includeInAllText: false,
path: false,
indexValueProcessors: [],
languages: []
},
configs: []
},
_permissions: [
{
principal: "role:system.admin",
allow: [
"READ",
"CREATE",
"MODIFY",
"DELETE",
"PUBLISH",
"READ_PERMISSIONS",
"WRITE_PERMISSIONS"
],
deny: []
},
{
principal: "role:system.everyone",
allow: [
"READ"
],
deny: []
}
],
_state: "DEFAULT",
_nodeType: "default",
_versionKey: "aa95ae7e-b975-4879-a19c-cce3b1fc3742",
_ts: "2021-05-15T08:46:37.227Z",
displayName: "Carpenter and IT expert",
likes: "Plywood",
numberOfUselessGadgets: 123
}
Setting the languages in the node config will create stemmed indices for all mapped properties.
| Use stemmed() function to query data based on these indices. |
repo.create({
_name: "fruits",
displayName: "Fruit basket",
description: "language indices usage example",
english_set: {
fruit_a: "Apple",
fruit_set: {
fruit_b: "Lemon",
fruit_c: "Orange"
}
},
norwegian_set: {
fruit_a: "Eple",
fruit_set: {
fruit_b: "Sitron",
fruit_c: "Oransje"
}
},
_indexConfig: {
default: {
enabled: true,
decideByType: true,
nGram: false,
fulltext: false,
includeInAllText: false,
path: false,
languages: ['en']
}, configs: [{
path: "norwegian_set.**",
config: {
enabled: true,
decideByType: false,
nGram: true,
fulltext: true,
includeInAllText: true,
path: false,
languages: ['no']
}
}]
}
});
Stemmed english indices will be generated for displayName, description and all strings inside english_set. Norwegian indices will be created for strings inside norwegian_set only.
delete
Deletes a node or nodes.
Parameters
delete() is positional. It accepts one or more node keys (ids or paths), where each argument can be a single key or an array of keys. Prefer ids over paths.
Returns
string[] : The list of keys that were actually deleted.
Example
const result = repo.delete('nodeId', '/node2-path', 'missingNodeId');
[
"7b175b63-b012-4f20-b31d-b8f78420d7f1",
"69f225a1-e775-4845-89f0-29b808a9a659"
]
diff
Resolves the differences for a node between the branch in the current context and a target branch.
Parameters
diff() takes a single DiffBranchesParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
key |
string |
Path or id to resolve the diff for. |
|
target |
string |
Branch to differentiate with. |
|
includeChildren |
boolean |
If set to |
Returns
object : (DiffBranchesResult) The status difference for each node in the tree that differs between the branches.
Example
const result = repo.diff({
key: '/my-name',
target: 'draft',
includeChildren: true
});
{
diff: [
{
id: "c8121875-a9b7-42e4-acf2-75cb52687ddb", (1)
status: "NEWER"
}
]
}
| 1 | There are 2 children, but only one has been changed |
duplicate
Duplicates a node.
Parameters
duplicate() takes a single DuplicateParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
nodeId |
string |
Id of the node. |
|
name |
string |
Optional. New node name. |
|
includeChildren |
boolean |
Optional. Indicates that children nodes must be duplicated, too. Defaults to |
|
parent |
string |
Optional. Destination parent path. By default, a duplicated node is added as a sibling of the source node. |
|
refresh |
string |
Optional. Refresh mode for the index of the current connection ( |
|
dataProcessor |
function |
Optional. Node data processor callback, receiving the node data and returning the processed data. |
Returns
object : (Node) The duplicated node.
Example
const result = repo.duplicate({
nodeId: 'nodeId',
name: 'duplicated-node',
includeChildren: false,
dataProcessor: (originalData) => {
originalData.data.extraProp = 'extraPropValue';
return originalData;
},
parent: '/',
refresh: 'SEARCH'
});
exists
Checks if a node exists in the current context.
Parameters
exists() is positional. It takes a single key string — the path or id of the node.
Returns
boolean : true if the node exists, false otherwise.
Examples
// Checking if a node exists by path
const result = repo.exists('/path/to/mynode');
if (result) {
log.info('Node exists');
} else {
log.info('Node does not exist');
}
// Checking if a node exists by id
const result = repo.exists('77963d9e-b3c8-4a53-85a9-20c375a92742');
if (result) {
log.info('Node exists');
} else {
log.info('Node does not exist');
}
findChildren
Fetches children of a node.
Parameters
findChildren() takes a single FindChildrenParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
parentKey |
string |
Path or id of the parent to get children of. |
|
start |
number |
Optional. Start index used for paging. Defaults to |
|
count |
number |
Optional. Number of nodes to fetch, used for paging. Defaults to |
|
childOrder |
string |
Optional. How to order the children. Defaults to the value stored on the parent. |
|
countOnly |
boolean |
Optional. Optimize for counting children only. Defaults to |
|
recursive |
boolean |
Optional. Recursively fetch all children of children. Defaults to |
Returns
object : (FindNodesByParentResult) Result stats and an array with the ids of the children.
Example
const result = repo.findChildren({
parentKey: "/my-name"
});
const expected = {
total: 2,
count: 10,
hits: [
{
id: "c8121875-a9b7-42e4-acf2-75cb52687ddb"
},
{
id: "636a616b-c8e4-480c-afa9-be88a737cf52"
}
]
}
getVersions
Returns versions of a node.
Parameters
getVersions() takes a single GetVersionsParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
key |
string |
Path or id of the node to get versions of. |
|
cursor |
string |
Optional. Opaque cursor returned in a previous result, used to fetch the next page. |
|
count |
number |
Optional. Number of versions to fetch. Defaults to |
Returns
object : (GetNodeVersionsResult) Result stats, the cursor for the next page (if any), and an array of NodeVersion entries.
Example
const firstPage = repo.getVersions({
key: '/my-name',
count: 2
});
if (firstPage.cursor) {
const nextPage = repo.getVersions({
key: '/my-name',
count: 2,
cursor: firstPage.cursor
});
}
const expected = {
total: 40,
count: 2,
cursor: "eyJ0cyI6MTAwMDAwMCwiaWQiOiJub2RlVmVyc2lvbk9sZCJ9",
hits: [
{
versionId: "72dcd8c1-9d70-444d-ad7a-508d8c1865a0",
nodeId: "ddd1c933-0725-45e8-9a54-a3dd87193f60",
nodePath: "/my-name",
timestamp: "2019-05-13T15:56:17.018Z"
},
{
versionId: "04c6b8d7-3c56-458f-80c9-c6ee551fc21d",
nodeId: "ddd1c933-0725-45e8-9a54-a3dd87193f60",
nodePath: "/my-name",
timestamp: "2019-05-13T15:56:16.995Z"
}
]
}
get
Fetches a specific node or nodes by path or ID.
Parameters
get() is positional. It accepts one or more strings (node ids or paths), one or more arrays of such strings, or one or more GetNodeParams objects. Each GetNodeParams object has these properties:
| Name | Type | Description |
|---|---|---|
|
key |
string |
Node id or path. |
|
versionId |
string |
Optional. Specific version to get the node from. Defaults to the active version. |
Returns
object : (Node or Node[]) The node, or array of nodes, fetched from the repository. Returns null when a single requested node is not found.
Example
const node = repo.get('nodeId');
const nodes = repo.get('nodeId_1', 'nodeId_2');
const nodes = repo.get(['nodeId_1', 'nodeId_2']);
const nodes = repo.get([{
key: 'nodeId',
versionId: 'versionKey'
}, {
key: '/my-name'
}, 'nodeId']);
getActiveVersion
Returns the active version of a node in the current context branch.
Parameters
getActiveVersion() takes a single GetActiveVersionParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
key |
string |
Path or id of the node. |
Returns
object : (NodeVersion) The active node version, or null if the node was not found.
Example
const version = repo.getActiveVersion({
key: '/my-name'
});
const expected = {
versionId: "72dcd8c1-9d70-444d-ad7a-508d8c1865a0",
nodeId: "ddd1c933-0725-45e8-9a54-a3dd87193f60",
nodePath: "/my-name",
timestamp: "2019-05-13T15:56:17.018Z"
}
getBinary
Returns a binary stream.
Parameters
getBinary() takes a single GetBinaryParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
key |
string |
Path or id of the node. |
|
binaryReference |
string |
Optional. Reference to the binary. |
Returns
object : (ByteSource) Stream of the binary.
Example
const binaryStream = repo.getBinary({
key: "/myNode",
binaryReference: "myBinaryReference"
});
getCommit
Returns a node version commit.
Parameters
getCommit() takes a single GetCommitParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
id |
string |
Id of the commit. |
Returns
object : (NodeCommit) The commit, or null if not found.
Example
const commit = repo.getCommit({
id: "aa1f76bf-4bb9-41be-b166-03561c1555b2"
});
const expected = {
id: "aa1f76bf-4bb9-41be-b166-03561c1555b2",
message: "",
committer: "user:system:anonymous",
timestamp: "2019-01-24T15:16:36.260799Z"
}
update
Updates a node.
Parameters
update() takes a single UpdateNodeParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
key |
string |
Path or id of the node. |
|
editor |
function |
Editor callback that receives the node and returns the modified node. |
Returns
object : (Node) The modified node.
Example
const result = repo.update({
key: key,
editor: (node) => {
node.someData.cars.push('peugeot');
return node;
}
});
patch
Applies a patch to a node.
|
This is a low-level function. It should be used with caution as it can corrupt data if used incorrectly. |
Parameters
patch() takes a single PatchNodeParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
key |
string |
Path or id of the node. |
|
editor |
function |
Patcher callback that receives the node and returns the patched node. |
|
branches |
string[] |
Optional. A list of branches to patch. Defaults to |
Returns
object : (PatchNodeResult) Patch result, with one entry in branchResults per branch where the node was patched.
Patchable Fields:
| Name | Type | Description |
|---|---|---|
|
displayName |
string |
The display name of the node. |
|
|
string |
The type definition of the node. |
|
|
object |
An object defining the search index configuration for this node. |
|
|
string |
Defines the default sort order for the node’s direct children. |
|
|
number |
Numeric value used for manual sorting among siblings (when the parent’s |
Any data can also be patched if the name of the field does not start with an underscore (_).
Examples
const patchedNode = repo.patch({
key: '/my-node',
editor: (node) => {
node.displayName = 'New Display Name';
node.newField = 'New Value';
return node;
}
});
const patchedNode = repo.patch({
key: '/my-node',
branches: ['master', 'draft', 'other'],
editor: (node) => {
node._childOrder = 'field DESC';
return node;
}
});
var ioLib = require('/lib/xp/io');
var stream = ioLib.newStream('Hello World');
const patchedNode = repo.patch({
key: '/my-node',
editor: (node) => {
node.attachmentField = {
data: stream
};
return node;
}
});
move
Renames a node or moves it to a new path.
Parameters
move() takes a single MoveNodeParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
source |
string |
Path or id of the node to be moved or renamed. |
|
target |
string |
New path or name for the node. If the target ends in slash |
Returns
object : (Node) The moved or renamed node.
Examples
const moved = repo.move({
source: '/my-name',
target: 'new-name'
});
const moved = repo.move({
source: '/my-name',
target: '/new-parent/'
});
const moved = repo.move({
source: '/my-name',
target: '/content/my-site/folder/new-name'
});
push
Pushes a node to a given branch.
Parameters
push() takes a single PushNodeParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
target |
string |
Branch to push to. |
|
key |
string |
Optional. Id or path of the node. Provide either |
|
keys |
string[] |
Optional. Array of ids or paths of the nodes. Provide either |
|
includeChildren |
boolean |
Optional. Also push children of the given nodes. Defaults to |
|
resolve |
boolean |
Optional. Resolve dependencies before pushing, meaning that references are also pushed. Defaults to |
|
exclude |
string[] |
Optional. Array of ids or paths of nodes not to be pushed. If using this, be aware that nodes need to maintain data integrity (e.g. parents must be present in the target). If data integrity is not maintained with excluded nodes, they will be pushed anyway. |
Returns
object : (PushNodesResult) Lists the keys that were pushed and any that failed.
Examples
const result = repo.push({
keys: ['a'],
target: 'otherBranch',
resolve: false
});
const expected = {
success: [
"a"
],
failed: []
}
const result = repo.push({
keys: ['a'],
target: 'otherBranch',
resolve: true,
includeChildren: true
});
const expected = {
success: [
"a",
"b",
"c"
],
failed: [
{
id: "d",
reason: "ACCESS_DENIED"
}
]
}
const result = repo.push({
keys: ['/a'],
target: 'otherBranch',
resolve: true,
includeChildren: true,
exclude: ['/a/b', '/a/c']
});
const expected = {
success: [
"a",
"d"
],
failed: []
}
query
Queries nodes.
Parameters
query() takes a single QueryNodeParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
query |
string/object |
Optional. Query string or DSL expression. |
|
start |
number |
Optional. Start index used for paging. Defaults to |
|
count |
number |
Optional. Number of nodes to fetch, used for paging. Defaults to |
|
filters |
object |
Optional. Query filters. |
|
sort |
string/object |
Optional. Sorting string or DSL expression. Defaults to |
|
aggregations |
object |
Optional. Aggregations config. |
|
highlight |
object |
Optional. Highlighting config. |
|
suggestions |
object |
Optional. Term suggestions config, keyed by suggestion name. |
|
explain |
boolean |
Optional. If set to |
Returns
object : (NodeQueryResult) Result stats, hits and, if requested, aggregations.
Examples
const result = repo.query({
query: "fulltext('_name', '_name')"
});
const expected = {
total: 4,
count: 4,
hits: [
{
id: "5be12847-cbad-4e61-a36c-e94ffb597afb",
score: 0.7071067690849304
},
{
id: "3928476f-915d-4a6a-97cc-f1c8a905f71a",
score: 0.625
},
{
id: "a2e38aab-6efb-4f20-862c-e23ef24b3fc3",
score: 0.5
},
{
id: "3a842eff-ef49-4781-8c1a-dcfcf515db51",
score: 0.5
}
],
aggregations: {}
}
const result = repo.query({
start: 0,
count: 2,
query: "startTime > instant('2016-10-11T14:38:54.454Z')",
filters: {
boolean: {
must: [
{
exists: {
field: "modifiedTime"
}
},
{
exists: {
field: "other"
}
}
],
mustNot: {
hasValue: {
field: "myField",
values: [
"cheese",
"fish",
"onion"
]
}
}
},
notExists: {
field: "unwantedField"
},
ids: {
values: ["id1", "id2"]
}
},
sort: "duration DESC",
aggregations: {
urls: {
terms: {
field: "url",
order: "_count desc",
size: 2
},
aggregations: {
duration: {
histogram: {
field: "duration",
interval: 100,
minDocCount: 1,
extendedBoundMin: 0,
extendedBoundMax: 10000,
order: "_key desc"
}
},
durationStats: {
stats: {
field: "duration"
}
}
}
}
}
});
const expected = {
total: 12902,
count: 2,
hits: [
{
id: "b186d24f-ac38-42ca-a6db-1c1bda6c6c26",
score: 1.2300000190734863
},
{
id: "350ba4a6-589c-498b-8af0-f183850e1120",
score: 1.399999976158142
}
],
aggregations: {
urls: {
buckets: [
{
key: "/site/draft/superhero/search",
docCount: 6762,
duration: {
buckets: [
{
key: "1600",
docCount: 2
},
{
key: "1400",
docCount: 1
},
{
key: "1300",
docCount: 5
}
]
}
},
{
key: "/site/draft/superhero",
docCount: 1245,
duration: {
buckets: [
{
key: "1600",
docCount: 2
},
{
key: "1400",
docCount: 1
},
{
key: "1300",
docCount: 5
}
]
}
}
]
}
}
}
const result = repo.query({
query: {
stemmed: {
field: "description",
value: "running",
language: "en"
}
}
});
const expected = {
total: 1,
count: 1,
hits: [
{
id: "2f0d5c09-39fe-4746-9756-74491d75a185",
score: 0.5
}
],
aggregations: {}
}
refresh
Refreshes indices for the current connection. The index has two parts: search and storage. It is possible to refresh both or just one of them.
Parameters
refresh() is positional. It takes an optional mode string: ALL for both indices, SEARCH for the search index or STORAGE for the storage index. Defaults to ALL.
Returns
Nothing.
Examples
repo.refresh();
repo.refresh('SEARCH');
sort
Sorts the children of a node by changing the parent’s _childOrder. When the parent is set to manual ordering, child nodes are reordered according to their _manualOrderValue.
Parameters
sort() takes a single SortNodeParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
key |
string |
Path or id of the parent node. |
|
childOrder |
string |
New child order expression for the parent (for example |
Returns
object : (SortNodeResult) The updated parent node and an array of reorderedNodes describing children whose ordering was affected.
Example
const result = repo.sort({
key: '/name-list',
childOrder: 'name DESC'
});
applyPermissions
Applies permissions on a node.
Parameters
applyPermissions() takes a single ApplyPermissionsParams object with these properties:
| Name | Type | Description |
|---|---|---|
|
key |
string |
Path or id of the node. |
|
permissions |
Optional. Array of permissions to overwrite current permissions. Cannot be combined with |
|
|
addPermissions |
Optional. Array of permissions to add. Cannot be combined with |
|
|
removePermissions |
Optional. Array of permissions to remove. Cannot be combined with |
|
|
scope |
string |
Optional. Scope of applying permissions. |
|
branches |
string[] |
Optional. Array of additional branches to apply permissions to. The current context branch should not be included. |
Returns
object : (ApplyPermissionsResult) An object keyed by node id, with one branchResults entry per branch the permissions were applied to.
Examples
repo.applyPermissions({
key: '/my-node',
permissions: [
{
principal: 'role:system.everyone',
allow: ['READ']
},
{
principal: 'user:system:my-user',
allow: ['READ', 'CREATE', 'MODIFY', 'DELETE']
}
]
});
repo.applyPermissions({
key: '/my-node',
addPermissions: [
{
principal: 'role:system.everyone',
allow: ['CREATE', 'MODIFY'] // 'READ' permission is already set and will be kept.
},
{
principal: 'user:system:my-new-user',
allow: ['READ', 'CREATE', 'MODIFY', 'DELETE'] // New user will have all permissions.
}
]
});
repo.applyPermissions({
key: '/my-node',
removePermissions: [
{
principal: 'role:system.everyone',
allow: ['CREATE', 'MODIFY'] // 'READ' permission will be kept.
},
{
principal: 'user:system:my-user',
allow: ['DELETE'] // 'DELETE' permission will be removed. All other permissions will be kept.
},
{
principal: 'user:system:my-new-user' // All permissions for this principal will be removed.
}
]
});
repo.applyPermissions({
key: '/my-node',
permissions: [
{
principal: 'role:system.everyone',
allow: ['READ']
}
],
scope: 'TREE'
});
repo.applyPermissions({
key: '/my-node',
permissions: [
{
principal: 'role:system.everyone',
allow: ['READ']
}
],
scope: 'SUBTREE'
});
repo.applyPermissions({
key: '/my-node',
permissions: [
{
principal: 'role:system.everyone',
allow: ['READ']
}
],
scope: 'TREE',
branches: ['branch1', 'branch2']
});
Type Definitions
ConnectParams
Properties
| Name | Type | Description |
|---|---|---|
|
repoId |
string |
Repository ID. |
|
branch |
string |
Branch ID. |
|
principals |
Optional. Additional principals to execute the connection with. |
|
|
user |
Optional. User to execute the connection as. Defaults to the current user. Not allowed when this source is part of a |
ConnectUser
Properties
| Name | Type | Description |
|---|---|---|
|
login |
string |
User id of the user. |
|
idProvider |
string |
Optional. Id provider containing the user. Defaults to the |
NodeCommit
Properties
| Name | Type | Description |
|---|---|---|
|
id |
string |
Commit id. |
|
message |
string |
Commit message. |
|
committer |
string |
Principal key of the commit creator. |
|
timestamp |
string |
Time of creation. |
NodeVersion
Properties
| Name | Type | Description |
|---|---|---|
|
versionId |
string |
Version id. |
|
nodeId |
string |
Node id. |
|
nodePath |
string |
Node path. |
|
timestamp |
string |
Time of the version. |
|
commitId |
string |
Optional. Id of the commit this version belongs to. |
AccessControlEntry
Properties
| Name | Type | Description |
|---|---|---|
|
principal |
Principal key (for example |
|
|
allow |
string[] |
Optional. Permissions to allow. Possible values are |
|
deny |
string[] |
Optional. Permissions to deny. Same possible values as |
NodeQueryResult
Properties
| Name | Type | Description |
|---|---|---|
|
total |
number |
Total number of nodes matching the query. |
|
count |
number |
Number of hits returned in this result. |
|
hits |
object[] |
Array of hits, each with an |
|
aggregations |
object |
Aggregations result, when aggregations were requested. |
|
suggestions |
object |
Optional. Suggestions result, when suggestions were requested. |
NodeMultiRepoQueryResult
Properties
Same shape as NodeQueryResult, except each hit also carries the repoId and branch it came from.
| Name | Type | Description |
|---|---|---|
|
total |
number |
Total number of nodes matching the query. |
|
count |
number |
Number of hits returned in this result. |
|
hits |
object[] |
Array of hits, each with |
|
aggregations |
object |
Aggregations result, when aggregations were requested. |
|
suggestions |
object |
Optional. Suggestions result, when suggestions were requested. |
FindNodesByParentResult
Properties
| Name | Type | Description |
|---|---|---|
|
total |
number |
Total number of children. |
|
count |
number |
Number of hits returned in this result. |
|
hits |
object[] |
Array of hits, each with an |
GetNodeVersionsResult
Properties
| Name | Type | Description |
|---|---|---|
|
total |
number |
Total number of versions. |
|
count |
number |
Number of hits returned in this result. |
|
cursor |
string |
Optional. Cursor used to fetch the next page, when more results are available. |
|
hits |
Array of node versions. |
DiffBranchesResult
Properties
| Name | Type | Description |
|---|---|---|
|
diff |
object[] |
Array of entries, each with an |
PushNodesResult
Properties
| Name | Type | Description |
|---|---|---|
|
success |
string[] |
Keys of the nodes that were successfully pushed. |
|
failed |
object[] |
Array of entries, each with an |
SortNodeResult
Properties
| Name | Type | Description |
|---|---|---|
|
node |
object |
( |
|
reorderedNodes |
object[] |
Array of entries, each with a |
PatchNodeResult
Properties
| Name | Type | Description |
|---|---|---|
|
branchResults |
object[] |
Array of entries, each with a |
ApplyPermissionsResult
Properties
An object keyed by node id. Each value has a single branchResults property — an array of entries, each with a branch and the resulting permissions (AccessControlEntry[]) applied in that branch.