confluence-cli 1.31.0 → 1.31.1
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.
- package/lib/confluence-client.js +41 -11
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/lib/confluence-client.js
CHANGED
|
@@ -27,6 +27,28 @@ const NAMED_ENTITIES = {
|
|
|
27
27
|
Eth: 'Ð', Thorn: 'Þ'
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
function createSemaphore(limit) {
|
|
31
|
+
let active = 0;
|
|
32
|
+
const waiters = [];
|
|
33
|
+
return {
|
|
34
|
+
async acquire() {
|
|
35
|
+
if (active < limit) {
|
|
36
|
+
active++;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
await new Promise(resolve => waiters.push(resolve));
|
|
40
|
+
},
|
|
41
|
+
release() {
|
|
42
|
+
if (waiters.length > 0) {
|
|
43
|
+
const next = waiters.shift();
|
|
44
|
+
next();
|
|
45
|
+
} else {
|
|
46
|
+
active--;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
30
52
|
class ConfluenceClient {
|
|
31
53
|
constructor(config) {
|
|
32
54
|
this.domain = config.domain;
|
|
@@ -1959,25 +1981,33 @@ class ConfluenceClient {
|
|
|
1959
1981
|
* Get all descendant pages recursively
|
|
1960
1982
|
*/
|
|
1961
1983
|
async getAllDescendantPages(pageId, maxDepth = 10, currentDepth = 0) {
|
|
1984
|
+
const semaphore = createSemaphore(10);
|
|
1985
|
+
return this._collectDescendants(pageId, maxDepth, currentDepth, semaphore);
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
async _collectDescendants(pageId, maxDepth, currentDepth, semaphore) {
|
|
1962
1989
|
if (currentDepth >= maxDepth) {
|
|
1963
1990
|
return [];
|
|
1964
1991
|
}
|
|
1965
1992
|
|
|
1966
|
-
|
|
1993
|
+
await semaphore.acquire();
|
|
1994
|
+
let children;
|
|
1995
|
+
try {
|
|
1996
|
+
children = await this.getChildPages(pageId);
|
|
1997
|
+
} finally {
|
|
1998
|
+
semaphore.release();
|
|
1999
|
+
}
|
|
2000
|
+
|
|
1967
2001
|
// Attach parentId so we can later reconstruct hierarchy if needed
|
|
1968
2002
|
const childrenWithParent = children.map(child => ({ ...child, parentId: pageId }));
|
|
1969
|
-
let allDescendants = [...childrenWithParent];
|
|
1970
2003
|
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
child.id,
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
);
|
|
1977
|
-
allDescendants = allDescendants.concat(grandChildren);
|
|
1978
|
-
}
|
|
2004
|
+
const grandChildrenLists = await Promise.all(
|
|
2005
|
+
children.map(child =>
|
|
2006
|
+
this._collectDescendants(child.id, maxDepth, currentDepth + 1, semaphore)
|
|
2007
|
+
)
|
|
2008
|
+
);
|
|
1979
2009
|
|
|
1980
|
-
return
|
|
2010
|
+
return childrenWithParent.concat(...grandChildrenLists);
|
|
1981
2011
|
}
|
|
1982
2012
|
|
|
1983
2013
|
/**
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "confluence-cli",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "confluence-cli",
|
|
9
|
-
"version": "1.31.
|
|
9
|
+
"version": "1.31.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^1.15.0",
|