@xwiki/cristal-navigation-tree-xwiki 0.12.0 → 0.14.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @xwiki/cristal-navigation-tree-xwiki
2
2
 
3
+ ## 0.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 3e5f853: Cristal 0.14 Release
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [3e5f853]
12
+ - @xwiki/cristal-api@0.14.0
13
+ - @xwiki/cristal-authentication-api@0.14.0
14
+ - @xwiki/cristal-model-api@0.14.0
15
+ - @xwiki/cristal-model-reference-api@0.14.0
16
+ - @xwiki/cristal-model-remote-url-api@0.14.0
17
+ - @xwiki/cristal-navigation-tree-api@0.14.0
18
+
19
+ ## 0.13.0
20
+
21
+ ### Minor Changes
22
+
23
+ - 06a5d1b: Cristal 0.13 Release
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [06a5d1b]
28
+ - @xwiki/cristal-api@0.13.0
29
+ - @xwiki/cristal-authentication-api@0.13.0
30
+ - @xwiki/cristal-model-api@0.13.0
31
+ - @xwiki/cristal-model-reference-api@0.13.0
32
+ - @xwiki/cristal-model-remote-url-api@0.13.0
33
+ - @xwiki/cristal-navigation-tree-api@0.13.0
34
+
3
35
  ## 0.12.0
4
36
 
5
37
  ### Minor Changes
package/dist/index.es.js CHANGED
@@ -1,98 +1,107 @@
1
- import { name as d } from "@xwiki/cristal-navigation-tree-api";
2
- import { injectable as u, inject as c } from "inversify";
3
- var f = Object.defineProperty, m = Object.getOwnPropertyDescriptor, v = (i, e, o, r) => {
4
- for (var t = r > 1 ? void 0 : r ? m(e, o) : e, n = i.length - 1, s; n >= 0; n--)
5
- (s = i[n]) && (t = (r ? s(e, o, t) : s(t)) || t);
6
- return r && t && f(e, o, t), t;
7
- }, p = (i, e) => (o, r) => e(o, r, i);
8
- let g = class {
9
- constructor(i, e, o) {
10
- this.authenticationManagerProvider = o, this.logger = i, this.logger.setModule(
1
+ import { name as g } from "@xwiki/cristal-navigation-tree-api";
2
+ import { injectable as f, inject as c, named as u } from "inversify";
3
+ var m = Object.defineProperty, v = Object.getOwnPropertyDescriptor, w = (r, t, a, i) => {
4
+ for (var e = i > 1 ? void 0 : i ? v(t, a) : t, n = r.length - 1, l; n >= 0; n--)
5
+ (l = r[n]) && (e = (i ? l(t, a, e) : l(e)) || e);
6
+ return i && e && m(t, a, e), e;
7
+ }, s = (r, t) => (a, i) => t(a, i, r);
8
+ let h = class {
9
+ constructor(r, t, a, i, e) {
10
+ this.logger = r, this.cristalApp = t, this.authenticationManagerProvider = a, this.urlParser = i, this.referenceSerializer = e, this.logger.setModule(
11
11
  "navigation-tree-xwiki.components.XWikiNavigationTreeSource"
12
- ), this.cristalApp = e;
12
+ );
13
13
  }
14
- async getChildNodes(i) {
15
- var r;
16
- const e = i || "#", o = [];
14
+ // TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
15
+ // eslint-disable-next-line max-statements
16
+ async getChildNodes(r) {
17
+ var i;
18
+ const t = r || "#", a = [];
17
19
  try {
18
- const t = await ((r = this.authenticationManagerProvider.get()) == null ? void 0 : r.getAuthorizationHeader()), n = {
20
+ const e = await ((i = this.authenticationManagerProvider.get()) == null ? void 0 : i.getAuthorizationHeader()), n = {
19
21
  Accept: "application/json"
20
22
  };
21
- t && (n.Authorization = t), o.push(...await this.fetchNodes(e, n, 0));
22
- } catch (t) {
23
- this.logger.error(t), this.logger.debug("Could not load navigation tree.");
23
+ e && (n.Authorization = e), a.push(...await this.fetchNodes(t, n, 0));
24
+ } catch (e) {
25
+ this.logger.error(e), this.logger.debug("Could not load navigation tree.");
24
26
  }
25
- return o;
27
+ return a;
26
28
  }
27
- getParentNodesId(i) {
28
- const e = [];
29
- if (i) {
30
- const o = i.document.getIdentifier();
31
- if (!o)
29
+ // TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
30
+ // eslint-disable-next-line max-statements
31
+ getParentNodesId(r) {
32
+ const t = [];
33
+ if (r) {
34
+ const a = r.document.getIdentifier();
35
+ if (!a)
32
36
  return this.logger.debug(
33
- `No identifier found for page ${i.name}, cannot resolve parents.`
37
+ `No identifier found for page ${r.name}, cannot resolve parents.`
34
38
  ), [];
35
- const r = o.replace(/\.WebHome$/, "").split(new RegExp("(?<![^\\\\](?:\\\\\\\\)*\\\\)\\."));
36
- let t = "", n;
37
- for (n = 0; n < r.length - 1; n++)
38
- t += r[n], e.push(`document:xwiki:${t}.WebHome`), t += ".";
39
- e.push(`document:xwiki:${o}`);
39
+ const i = a.replace(/\.WebHome$/, "").split(new RegExp("(?<![^\\\\](?:\\\\\\\\)*\\\\)\\."));
40
+ let e = "", n;
41
+ for (n = 0; n < i.length - 1; n++)
42
+ e += i[n], t.push(`document:xwiki:${e}.WebHome`), e += ".";
43
+ t.push(`document:xwiki:${a}`);
40
44
  }
41
- return e;
45
+ return t;
42
46
  }
43
- async fetchNodes(i, e, o) {
44
- const r = [], t = this.cristalApp.getWikiConfig().baseURL.replace(/\/[^/]*$/, ""), n = new URL(
47
+ // TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
48
+ // eslint-disable-next-line max-statements
49
+ async fetchNodes(r, t, a) {
50
+ const i = [], e = this.cristalApp.getWikiConfig().baseURL.replace(/\/[^/]*$/, ""), n = new URL(
45
51
  `${this.cristalApp.getWikiConfig().baseURL}/bin/get`
46
52
  );
47
53
  n.search = new URLSearchParams([
48
- ["id", i],
54
+ ["id", r],
49
55
  ["outputSyntax", "plain"],
50
56
  ["sheet", "XWiki.DocumentTree"],
51
57
  ["data", "children"],
52
58
  ["compact", "true"],
53
- ["offset", o.toString()]
59
+ ["offset", a.toString()],
60
+ ["showTranslations", "false"],
61
+ ["showAttachments", "false"]
54
62
  ]).toString();
55
- const h = await (await fetch(n, { headers: e })).json();
56
- for (const a of h)
57
- if (a.id == "pagination:wiki:xwiki")
58
- r.push(
59
- ...await this.fetchNodes(i, e, a.data.offset)
63
+ const d = await (await fetch(n, { headers: t })).json();
64
+ for (const o of d)
65
+ if (o.id == "pagination:wiki:xwiki")
66
+ i.push(
67
+ ...await this.fetchNodes(r, t, o.data.offset)
60
68
  );
61
- else if (!["attachments", "translations"].includes(a.data.type) && a.a_attr) {
62
- const l = decodeURIComponent(
63
- this.cristalApp.getWikiConfig().storage.getPageFromViewURL(
64
- `${t}${a.a_attr.href}`
65
- )
69
+ else if (!["attachments", "translations"].includes(o.data.type) && o.a_attr) {
70
+ const p = this.urlParser.parse(
71
+ `${e}${o.a_attr.href}`
66
72
  );
67
- r.push({
68
- id: a.id,
69
- label: a.text,
70
- location: l.replace(/\.WebHome$/, ""),
73
+ i.push({
74
+ id: o.id,
75
+ label: o.text,
76
+ location: p.space,
71
77
  url: this.cristalApp.getRouter().resolve({
72
78
  name: "view",
73
79
  params: {
74
- page: l
80
+ page: this.referenceSerializer.serialize(p)
75
81
  }
76
82
  }).href,
77
- has_children: a.children
78
- //TODO: ignore translations and attachments
83
+ has_children: o.children
79
84
  });
80
85
  }
81
- return r;
86
+ return i;
82
87
  }
83
88
  };
84
- g = v([
85
- u(),
86
- p(0, c("Logger")),
87
- p(1, c("CristalApp")),
88
- p(2, c("AuthenticationManagerProvider"))
89
- ], g);
90
- class P {
91
- constructor(e) {
92
- e.bind(d).to(g).inSingletonScope().whenTargetNamed("XWiki");
89
+ h = w([
90
+ f(),
91
+ s(0, c("Logger")),
92
+ s(1, c("CristalApp")),
93
+ s(2, c("AuthenticationManagerProvider")),
94
+ s(3, c("RemoteURLParser")),
95
+ s(3, u("XWiki")),
96
+ s(4, c("ModelReferenceSerializer")),
97
+ s(4, u("XWiki"))
98
+ ], h);
99
+ class R {
100
+ constructor(t) {
101
+ t.bind(g).to(h).inSingletonScope().whenTargetNamed("XWiki");
93
102
  }
94
103
  }
95
104
  export {
96
- P as ComponentInit
105
+ R as ComponentInit
97
106
  };
98
107
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/components/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { name as NavigationTreeSourceName } from \"@xwiki/cristal-navigation-tree-api\";\nimport { Container, inject, injectable } from \"inversify\";\nimport type { CristalApp, Logger, PageData } from \"@xwiki/cristal-api\";\nimport type { AuthenticationManagerProvider } from \"@xwiki/cristal-authentication-api\";\nimport type {\n NavigationTreeNode,\n NavigationTreeSource,\n} from \"@xwiki/cristal-navigation-tree-api\";\n\n/**\n * Implementation of NavigationTreeSource for the XWiki backend.\n *\n * @since 0.10\n **/\n@injectable()\nclass XWikiNavigationTreeSource implements NavigationTreeSource {\n private cristalApp: CristalApp;\n public logger: Logger;\n\n constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject<CristalApp>(\"CristalApp\") cristalApp: CristalApp,\n @inject<AuthenticationManagerProvider>(\"AuthenticationManagerProvider\")\n private authenticationManagerProvider: AuthenticationManagerProvider,\n ) {\n this.logger = logger;\n this.logger.setModule(\n \"navigation-tree-xwiki.components.XWikiNavigationTreeSource\",\n );\n this.cristalApp = cristalApp;\n }\n\n async getChildNodes(id?: string): Promise<Array<NavigationTreeNode>> {\n const currentId = id ? id : \"#\";\n const navigationTree: Array<NavigationTreeNode> = [];\n\n try {\n const authorization = await this.authenticationManagerProvider\n .get()\n ?.getAuthorizationHeader();\n const headers: { Accept: string; Authorization?: string } = {\n Accept: \"application/json\",\n };\n\n if (authorization) {\n headers.Authorization = authorization;\n }\n\n navigationTree.push(...(await this.fetchNodes(currentId, headers, 0)));\n } catch (error) {\n this.logger.error(error);\n this.logger.debug(\"Could not load navigation tree.\");\n }\n return navigationTree;\n }\n\n getParentNodesId(page?: PageData): Array<string> {\n const result = [];\n if (page) {\n const documentId = page.document.getIdentifier();\n if (!documentId) {\n this.logger.debug(\n `No identifier found for page ${page.name}, cannot resolve parents.`,\n );\n return [];\n }\n // TODO: Use a page resolver instead when CRISTAL-234 is fixed.\n const parents = documentId\n .replace(/\\.WebHome$/, \"\")\n .split(/(?<![^\\\\](?:\\\\\\\\)*\\\\)\\./);\n let currentParent = \"\";\n let i;\n for (i = 0; i < parents.length - 1; i++) {\n currentParent += parents[i];\n // TODO: Support subwikis.\n result.push(`document:xwiki:${currentParent}.WebHome`);\n currentParent += \".\";\n }\n result.push(`document:xwiki:${documentId}`);\n }\n return result;\n }\n\n private async fetchNodes(\n currentId: string,\n headers: { Accept: string; Authorization?: string },\n offset: number,\n ): Promise<Array<NavigationTreeNode>> {\n const nodes: Array<NavigationTreeNode> = [];\n const baseXWikiURL = this.cristalApp\n .getWikiConfig()\n .baseURL.replace(/\\/[^/]*$/, \"\");\n\n const navigationTreeRequestUrl = new URL(\n `${this.cristalApp.getWikiConfig().baseURL}/bin/get`,\n );\n navigationTreeRequestUrl.search = new URLSearchParams([\n [\"id\", currentId],\n [\"outputSyntax\", \"plain\"],\n [\"sheet\", \"XWiki.DocumentTree\"],\n [\"data\", \"children\"],\n [\"compact\", \"true\"],\n [\"offset\", offset.toString()],\n ]).toString();\n\n const response = await fetch(navigationTreeRequestUrl, { headers });\n const jsonResponse: [\n {\n id: string;\n text: string;\n children: boolean;\n data: { type: string; offset: number };\n a_attr?: { href: string };\n },\n ] = await response.json();\n for (const treeNode of jsonResponse) {\n if (treeNode.id == \"pagination:wiki:xwiki\") {\n nodes.push(\n ...(await this.fetchNodes(currentId, headers, treeNode.data.offset)),\n );\n } else if (\n ![\"attachments\", \"translations\"].includes(treeNode.data.type) &&\n treeNode.a_attr\n ) {\n const pageId = decodeURIComponent(\n this.cristalApp\n .getWikiConfig()\n .storage.getPageFromViewURL(\n `${baseXWikiURL}${treeNode.a_attr.href}`,\n )!,\n );\n nodes.push({\n id: treeNode.id,\n label: treeNode.text,\n location: pageId.replace(/\\.WebHome$/, \"\"),\n url: this.cristalApp.getRouter().resolve({\n name: \"view\",\n params: {\n page: pageId,\n },\n }).href,\n has_children: treeNode.children, //TODO: ignore translations and attachments\n });\n }\n }\n\n return nodes;\n }\n}\n\nexport class ComponentInit {\n constructor(container: Container) {\n container\n .bind<NavigationTreeSource>(NavigationTreeSourceName)\n .to(XWikiNavigationTreeSource)\n .inSingletonScope()\n .whenTargetNamed(\"XWiki\");\n }\n}\n"],"names":["XWikiNavigationTreeSource","logger","cristalApp","authenticationManagerProvider","id","currentId","navigationTree","authorization","_a","headers","error","page","result","documentId","parents","currentParent","i","offset","nodes","baseXWikiURL","navigationTreeRequestUrl","jsonResponse","treeNode","pageId","__decorateClass","injectable","__decorateParam","ComponentInit","container","NavigationTreeSourceName"],"mappings":";;;;;;;AAmCA,IAAMA,IAAN,MAAgE;AAAA,EAI9D,YAC4BC,GACQC,GAE1BC,GACR;AADQ,SAAA,gCAAAA,GAER,KAAK,SAASF,GACd,KAAK,OAAO;AAAA,MACV;AAAA,IAAA,GAEF,KAAK,aAAaC;AAAA,EACpB;AAAA,EAEA,MAAM,cAAcE,GAAiD;;AAC7D,UAAAC,IAAYD,KAAU,KACtBE,IAA4C,CAAA;AAE9C,QAAA;AACF,YAAMC,IAAgB,QAAMC,IAAA,KAAK,8BAC9B,IAAA,MADyB,gBAAAA,EAExB,2BACEC,IAAsD;AAAA,QAC1D,QAAQ;AAAA,MAAA;AAGV,MAAIF,MACFE,EAAQ,gBAAgBF,IAGXD,EAAA,KAAK,GAAI,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EAAS,CAAA,GAS/C;AACnB,eAAWa,KAAYD;AACjB,UAAAC,EAAS,MAAM;AACX,QAAAJ,EAAA;AAAA,UACJ,GAAI,MAAM,KAAK,WAAWb,GAAWI,GAASa,EAAS,KAAK,MAAM;AAAA,QAAA;AAAA,eAGpE,CAAC,CAAC,eAAe,cAAc,EAAE,SAASA,EAAS,KAAK,IAAI,KAC5DA,EAAS,QACT;AACA,cAAMC,IAAS;AAAA,UACb,KAAK,WACF,cAAc,EACd,QAAQ;AAAA,YACP,GAAGJ,CAAY,GAAGG,EAAS,OAAO,IAAI;AAAA,UACxC;AAAA,QAAA;AAEJ,QAAAJ,EAAM,KAAK;AAAA,UACT,IAAII,EAAS;AAAA,UACb,OAAOA,EAAS;AAAA,UAChB,UAAUC,EAAO,QAAQ,cAAc,EAAE;AAAA,UACzC,KAAK,KAAK,WAAW,UAAA,EAAY,QAAQ;AAAA,YACvC,MAAM;AAAA,YACN,QAAQ;AAAA,cACN,MAAMA;AAAA,YACR;AAAA,UACD,CAAA,EAAE;AAAA,UACH,cAAcD,EAAS;AAAA;AAAA,QAAA,CACxB;AAAA,MACH;AAGK,WAAAJ;AAAA,EACT;AACF;AArIMlB,IAANwB,EAAA;AAAA,EADCC,EAAW;AAAA,EAMPC,OAAe,QAAQ,CAAA;AAAA,EACvBA,OAAmB,YAAY,CAAA;AAAA,EAC/BA,OAAsC,+BAA+B,CAAA;AAAA,GAPpE1B,CAAA;AAuIC,MAAM2B,EAAc;AAAA,EACzB,YAAYC,GAAsB;AAE7B,IAAAA,EAAA,KAA2BC,CAAwB,EACnD,GAAG7B,CAAyB,EAC5B,iBACA,EAAA,gBAAgB,OAAO;AAAA,EAC5B;AACF;"}
1
+ {"version":3,"file":"index.es.js","sources":["../src/components/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { name as NavigationTreeSourceName } from \"@xwiki/cristal-navigation-tree-api\";\nimport { Container, inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, PageData } from \"@xwiki/cristal-api\";\nimport type { AuthenticationManagerProvider } from \"@xwiki/cristal-authentication-api\";\nimport type { DocumentReference } from \"@xwiki/cristal-model-api\";\nimport type { ModelReferenceSerializer } from \"@xwiki/cristal-model-reference-api\";\nimport type { RemoteURLParser } from \"@xwiki/cristal-model-remote-url-api\";\nimport type {\n NavigationTreeNode,\n NavigationTreeSource,\n} from \"@xwiki/cristal-navigation-tree-api\";\n\n/**\n * Implementation of NavigationTreeSource for the XWiki backend.\n *\n * @since 0.10\n **/\n@injectable()\nclass XWikiNavigationTreeSource implements NavigationTreeSource {\n constructor(\n @inject<Logger>(\"Logger\") private readonly logger: Logger,\n @inject<CristalApp>(\"CristalApp\") private readonly cristalApp: CristalApp,\n @inject<AuthenticationManagerProvider>(\"AuthenticationManagerProvider\")\n private authenticationManagerProvider: AuthenticationManagerProvider,\n @inject<RemoteURLParser>(\"RemoteURLParser\")\n @named(\"XWiki\")\n private readonly urlParser: RemoteURLParser,\n @inject<ModelReferenceSerializer>(\"ModelReferenceSerializer\")\n @named(\"XWiki\")\n private readonly referenceSerializer: ModelReferenceSerializer,\n ) {\n this.logger.setModule(\n \"navigation-tree-xwiki.components.XWikiNavigationTreeSource\",\n );\n }\n\n // TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.\n // eslint-disable-next-line max-statements\n async getChildNodes(id?: string): Promise<Array<NavigationTreeNode>> {\n const currentId = id ? id : \"#\";\n const navigationTree: Array<NavigationTreeNode> = [];\n\n try {\n const authorization = await this.authenticationManagerProvider\n .get()\n ?.getAuthorizationHeader();\n const headers: { Accept: string; Authorization?: string } = {\n Accept: \"application/json\",\n };\n\n if (authorization) {\n headers.Authorization = authorization;\n }\n\n navigationTree.push(...(await this.fetchNodes(currentId, headers, 0)));\n } catch (error) {\n this.logger.error(error);\n this.logger.debug(\"Could not load navigation tree.\");\n }\n return navigationTree;\n }\n\n // TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.\n // eslint-disable-next-line max-statements\n getParentNodesId(page?: PageData): Array<string> {\n const result = [];\n if (page) {\n const documentId = page.document.getIdentifier();\n if (!documentId) {\n this.logger.debug(\n `No identifier found for page ${page.name}, cannot resolve parents.`,\n );\n return [];\n }\n // TODO: Use a page resolver instead when CRISTAL-234 is fixed.\n const parents = documentId\n .replace(/\\.WebHome$/, \"\")\n .split(/(?<![^\\\\](?:\\\\\\\\)*\\\\)\\./);\n let currentParent = \"\";\n let i;\n for (i = 0; i < parents.length - 1; i++) {\n currentParent += parents[i];\n // TODO: Support subwikis.\n result.push(`document:xwiki:${currentParent}.WebHome`);\n currentParent += \".\";\n }\n result.push(`document:xwiki:${documentId}`);\n }\n return result;\n }\n\n // TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.\n // eslint-disable-next-line max-statements\n private async fetchNodes(\n currentId: string,\n headers: { Accept: string; Authorization?: string },\n offset: number,\n ): Promise<Array<NavigationTreeNode>> {\n const nodes: Array<NavigationTreeNode> = [];\n const baseXWikiURL = this.cristalApp\n .getWikiConfig()\n .baseURL.replace(/\\/[^/]*$/, \"\");\n\n const navigationTreeRequestUrl = new URL(\n `${this.cristalApp.getWikiConfig().baseURL}/bin/get`,\n );\n navigationTreeRequestUrl.search = new URLSearchParams([\n [\"id\", currentId],\n [\"outputSyntax\", \"plain\"],\n [\"sheet\", \"XWiki.DocumentTree\"],\n [\"data\", \"children\"],\n [\"compact\", \"true\"],\n [\"offset\", offset.toString()],\n [\"showTranslations\", \"false\"],\n [\"showAttachments\", \"false\"],\n ]).toString();\n\n const response = await fetch(navigationTreeRequestUrl, { headers });\n const jsonResponse: [\n {\n id: string;\n text: string;\n children: boolean;\n data: { type: string; offset: number };\n a_attr?: { href: string };\n },\n ] = await response.json();\n for (const treeNode of jsonResponse) {\n if (treeNode.id == \"pagination:wiki:xwiki\") {\n nodes.push(\n ...(await this.fetchNodes(currentId, headers, treeNode.data.offset)),\n );\n } else if (\n ![\"attachments\", \"translations\"].includes(treeNode.data.type) &&\n treeNode.a_attr\n ) {\n const documentReference = this.urlParser.parse(\n `${baseXWikiURL}${treeNode.a_attr.href}`,\n )! as DocumentReference;\n nodes.push({\n id: treeNode.id,\n label: treeNode.text,\n location: documentReference.space!,\n url: this.cristalApp.getRouter().resolve({\n name: \"view\",\n params: {\n page: this.referenceSerializer.serialize(documentReference),\n },\n }).href,\n has_children: treeNode.children,\n });\n }\n }\n\n return nodes;\n }\n}\n\nexport class ComponentInit {\n constructor(container: Container) {\n container\n .bind<NavigationTreeSource>(NavigationTreeSourceName)\n .to(XWikiNavigationTreeSource)\n .inSingletonScope()\n .whenTargetNamed(\"XWiki\");\n }\n}\n"],"names":["XWikiNavigationTreeSource","logger","cristalApp","authenticationManagerProvider","urlParser","referenceSerializer","id","currentId","navigationTree","authorization","_a","headers","error","page","result","documentId","parents","currentParent","i","offset","nodes","baseXWikiURL","navigationTreeRequestUrl","jsonResponse","treeNode","documentReference","__decorateClass","injectable","__decorateParam","ComponentInit","container","NavigationTreeSourceName"],"mappings":";;;;;;;AAsCA,IAAMA,IAAN,MAAgE;AAAA,EAC9D,YAC6CC,GACQC,GAE3CC,GAGSC,GAGAC,GACjB;AAV2C,SAAA,SAAAJ,GACQ,KAAA,aAAAC,GAE3C,KAAA,gCAAAC,GAGS,KAAA,YAAAC,GAGA,KAAA,sBAAAC,GAEjB,KAAK,OAAO;AAAA,MACV;A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,CAAA;AAAA,EAErEA,OAAwB,iBAAiB,CAAA;AAAA,EACzCA,OAAM,OAAO,CAAA;AAAA,EAEbA,OAAiC,0BAA0B,CAAA;AAAA,EAC3DA,OAAM,OAAO,CAAA;AAAA,GAVZ5B,CAAA;AA4IC,MAAM6B,EAAc;AAAA,EACzB,YAAYC,GAAsB;AAE7B,IAAAA,EAAA,KAA2BC,CAAwB,EACnD,GAAG/B,CAAyB,EAC5B,iBAAA,EACA,gBAAgB,OAAO;AAAA,EAAA;AAE9B;"}
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(a,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@xwiki/cristal-navigation-tree-api"),require("inversify")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-navigation-tree-api","inversify"],c):(a=typeof globalThis<"u"?globalThis:a||self,c(a["cristal_navigation-tree-xwiki"]={},a.cristalNavigationTreeApi,a.inversify))})(this,function(a,c,p){"use strict";var h=Object.defineProperty,f=Object.getOwnPropertyDescriptor,m=(i,e,n,o)=>{for(var t=o>1?void 0:o?f(e,n):e,r=i.length-1,d;r>=0;r--)(d=i[r])&&(t=(o?d(e,n,t):d(t))||t);return o&&t&&h(e,n,t),t},l=(i,e)=>(n,o)=>e(n,o,i);let u=class{constructor(i,e,n){this.authenticationManagerProvider=n,this.logger=i,this.logger.setModule("navigation-tree-xwiki.components.XWikiNavigationTreeSource"),this.cristalApp=e}async getChildNodes(i){var o;const e=i||"#",n=[];try{const t=await((o=this.authenticationManagerProvider.get())==null?void 0:o.getAuthorizationHeader()),r={Accept:"application/json"};t&&(r.Authorization=t),n.push(...await this.fetchNodes(e,r,0))}catch(t){this.logger.error(t),this.logger.debug("Could not load navigation tree.")}return n}getParentNodesId(i){const e=[];if(i){const n=i.document.getIdentifier();if(!n)return this.logger.debug(`No identifier found for page ${i.name}, cannot resolve parents.`),[];const o=n.replace(/\.WebHome$/,"").split(new RegExp("(?<![^\\\\](?:\\\\\\\\)*\\\\)\\."));let t="",r;for(r=0;r<o.length-1;r++)t+=o[r],e.push(`document:xwiki:${t}.WebHome`),t+=".";e.push(`document:xwiki:${n}`)}return e}async fetchNodes(i,e,n){const o=[],t=this.cristalApp.getWikiConfig().baseURL.replace(/\/[^/]*$/,""),r=new URL(`${this.cristalApp.getWikiConfig().baseURL}/bin/get`);r.search=new URLSearchParams([["id",i],["outputSyntax","plain"],["sheet","XWiki.DocumentTree"],["data","children"],["compact","true"],["offset",n.toString()]]).toString();const w=await(await fetch(r,{headers:e})).json();for(const s of w)if(s.id=="pagination:wiki:xwiki")o.push(...await this.fetchNodes(i,e,s.data.offset));else if(!["attachments","translations"].includes(s.data.type)&&s.a_attr){const g=decodeURIComponent(this.cristalApp.getWikiConfig().storage.getPageFromViewURL(`${t}${s.a_attr.href}`));o.push({id:s.id,label:s.text,location:g.replace(/\.WebHome$/,""),url:this.cristalApp.getRouter().resolve({name:"view",params:{page:g}}).href,has_children:s.children})}return o}};u=m([p.injectable(),l(0,p.inject("Logger")),l(1,p.inject("CristalApp")),l(2,p.inject("AuthenticationManagerProvider"))],u);class v{constructor(e){e.bind(c.name).to(u).inSingletonScope().whenTargetNamed("XWiki")}}a.ComponentInit=v,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@xwiki/cristal-navigation-tree-api"),require("inversify")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-navigation-tree-api","inversify"],u):(o=typeof globalThis<"u"?globalThis:o||self,u(o["cristal_navigation-tree-xwiki"]={},o.cristalNavigationTreeApi,o.inversify))})(this,function(o,u,s){"use strict";var g=Object.defineProperty,f=Object.getOwnPropertyDescriptor,m=(n,t,r,i)=>{for(var e=i>1?void 0:i?f(t,r):t,a=n.length-1,h;a>=0;a--)(h=n[a])&&(e=(i?h(t,r,e):h(e))||e);return i&&e&&g(t,r,e),e},l=(n,t)=>(r,i)=>t(r,i,n);let p=class{constructor(n,t,r,i,e){this.logger=n,this.cristalApp=t,this.authenticationManagerProvider=r,this.urlParser=i,this.referenceSerializer=e,this.logger.setModule("navigation-tree-xwiki.components.XWikiNavigationTreeSource")}async getChildNodes(n){var i;const t=n||"#",r=[];try{const e=await((i=this.authenticationManagerProvider.get())==null?void 0:i.getAuthorizationHeader()),a={Accept:"application/json"};e&&(a.Authorization=e),r.push(...await this.fetchNodes(t,a,0))}catch(e){this.logger.error(e),this.logger.debug("Could not load navigation tree.")}return r}getParentNodesId(n){const t=[];if(n){const r=n.document.getIdentifier();if(!r)return this.logger.debug(`No identifier found for page ${n.name}, cannot resolve parents.`),[];const i=r.replace(/\.WebHome$/,"").split(new RegExp("(?<![^\\\\](?:\\\\\\\\)*\\\\)\\."));let e="",a;for(a=0;a<i.length-1;a++)e+=i[a],t.push(`document:xwiki:${e}.WebHome`),e+=".";t.push(`document:xwiki:${r}`)}return t}async fetchNodes(n,t,r){const i=[],e=this.cristalApp.getWikiConfig().baseURL.replace(/\/[^/]*$/,""),a=new URL(`${this.cristalApp.getWikiConfig().baseURL}/bin/get`);a.search=new URLSearchParams([["id",n],["outputSyntax","plain"],["sheet","XWiki.DocumentTree"],["data","children"],["compact","true"],["offset",r.toString()],["showTranslations","false"],["showAttachments","false"]]).toString();const v=await(await fetch(a,{headers:t})).json();for(const c of v)if(c.id=="pagination:wiki:xwiki")i.push(...await this.fetchNodes(n,t,c.data.offset));else if(!["attachments","translations"].includes(c.data.type)&&c.a_attr){const d=this.urlParser.parse(`${e}${c.a_attr.href}`);i.push({id:c.id,label:c.text,location:d.space,url:this.cristalApp.getRouter().resolve({name:"view",params:{page:this.referenceSerializer.serialize(d)}}).href,has_children:c.children})}return i}};p=m([s.injectable(),l(0,s.inject("Logger")),l(1,s.inject("CristalApp")),l(2,s.inject("AuthenticationManagerProvider")),l(3,s.inject("RemoteURLParser")),l(3,s.named("XWiki")),l(4,s.inject("ModelReferenceSerializer")),l(4,s.named("XWiki"))],p);class w{constructor(t){t.bind(u.name).to(p).inSingletonScope().whenTargetNamed("XWiki")}}o.ComponentInit=w,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=index.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/components/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { name as NavigationTreeSourceName } from \"@xwiki/cristal-navigation-tree-api\";\nimport { Container, inject, injectable } from \"inversify\";\nimport type { CristalApp, Logger, PageData } from \"@xwiki/cristal-api\";\nimport type { AuthenticationManagerProvider } from \"@xwiki/cristal-authentication-api\";\nimport type {\n NavigationTreeNode,\n NavigationTreeSource,\n} from \"@xwiki/cristal-navigation-tree-api\";\n\n/**\n * Implementation of NavigationTreeSource for the XWiki backend.\n *\n * @since 0.10\n **/\n@injectable()\nclass XWikiNavigationTreeSource implements NavigationTreeSource {\n private cristalApp: CristalApp;\n public logger: Logger;\n\n constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject<CristalApp>(\"CristalApp\") cristalApp: CristalApp,\n @inject<AuthenticationManagerProvider>(\"AuthenticationManagerProvider\")\n private authenticationManagerProvider: AuthenticationManagerProvider,\n ) {\n this.logger = logger;\n this.logger.setModule(\n \"navigation-tree-xwiki.components.XWikiNavigationTreeSource\",\n );\n this.cristalApp = cristalApp;\n }\n\n async getChildNodes(id?: string): Promise<Array<NavigationTreeNode>> {\n const currentId = id ? id : \"#\";\n const navigationTree: Array<NavigationTreeNode> = [];\n\n try {\n const authorization = await this.authenticationManagerProvider\n .get()\n ?.getAuthorizationHeader();\n const headers: { Accept: string; Authorization?: string } = {\n Accept: \"application/json\",\n };\n\n if (authorization) {\n headers.Authorization = authorization;\n }\n\n navigationTree.push(...(await this.fetchNodes(currentId, headers, 0)));\n } catch (error) {\n this.logger.error(error);\n this.logger.debug(\"Could not load navigation tree.\");\n }\n return navigationTree;\n }\n\n getParentNodesId(page?: PageData): Array<string> {\n const result = [];\n if (page) {\n const documentId = page.document.getIdentifier();\n if (!documentId) {\n this.logger.debug(\n `No identifier found for page ${page.name}, cannot resolve parents.`,\n );\n return [];\n }\n // TODO: Use a page resolver instead when CRISTAL-234 is fixed.\n const parents = documentId\n .replace(/\\.WebHome$/, \"\")\n .split(/(?<![^\\\\](?:\\\\\\\\)*\\\\)\\./);\n let currentParent = \"\";\n let i;\n for (i = 0; i < parents.length - 1; i++) {\n currentParent += parents[i];\n // TODO: Support subwikis.\n result.push(`document:xwiki:${currentParent}.WebHome`);\n currentParent += \".\";\n }\n result.push(`document:xwiki:${documentId}`);\n }\n return result;\n }\n\n private async fetchNodes(\n currentId: string,\n headers: { Accept: string; Authorization?: string },\n offset: number,\n ): Promise<Array<NavigationTreeNode>> {\n const nodes: Array<NavigationTreeNode> = [];\n const baseXWikiURL = this.cristalApp\n .getWikiConfig()\n .baseURL.replace(/\\/[^/]*$/, \"\");\n\n const navigationTreeRequestUrl = new URL(\n `${this.cristalApp.getWikiConfig().baseURL}/bin/get`,\n );\n navigationTreeRequestUrl.search = new URLSearchParams([\n [\"id\", currentId],\n [\"outputSyntax\", \"plain\"],\n [\"sheet\", \"XWiki.DocumentTree\"],\n [\"data\", \"children\"],\n [\"compact\", \"true\"],\n [\"offset\", offset.toString()],\n ]).toString();\n\n const response = await fetch(navigationTreeRequestUrl, { headers });\n const jsonResponse: [\n {\n id: string;\n text: string;\n children: boolean;\n data: { type: string; offset: number };\n a_attr?: { href: string };\n },\n ] = await response.json();\n for (const treeNode of jsonResponse) {\n if (treeNode.id == \"pagination:wiki:xwiki\") {\n nodes.push(\n ...(await this.fetchNodes(currentId, headers, treeNode.data.offset)),\n );\n } else if (\n ![\"attachments\", \"translations\"].includes(treeNode.data.type) &&\n treeNode.a_attr\n ) {\n const pageId = decodeURIComponent(\n this.cristalApp\n .getWikiConfig()\n .storage.getPageFromViewURL(\n `${baseXWikiURL}${treeNode.a_attr.href}`,\n )!,\n );\n nodes.push({\n id: treeNode.id,\n label: treeNode.text,\n location: pageId.replace(/\\.WebHome$/, \"\"),\n url: this.cristalApp.getRouter().resolve({\n name: \"view\",\n params: {\n page: pageId,\n },\n }).href,\n has_children: treeNode.children, //TODO: ignore translations and attachments\n });\n }\n }\n\n return nodes;\n }\n}\n\nexport class ComponentInit {\n constructor(container: Container) {\n container\n .bind<NavigationTreeSource>(NavigationTreeSourceName)\n .to(XWikiNavigationTreeSource)\n .inSingletonScope()\n .whenTargetNamed(\"XWiki\");\n }\n}\n"],"names":["XWikiNavigationTreeSource","logger","cristalApp","authenticationManagerProvider","id","currentId","navigationTree","authorization","_a","headers","error","page","result","documentId","parents","currentParent","i","offset","nodes","baseXWikiURL","navigationTreeRequestUrl","jsonResponse","treeNode","pageId","__decorateClass","injectable","__decorateParam","ComponentInit","container","NavigationTreeSourceName"],"mappings":"gnBAmCA,IAAMA,EAAN,KAAgE,CAI9D,YAC4BC,EACQC,EAE1BC,EACR,CADQ,KAAA,8BAAAA,EAER,KAAK,OAASF,EACd,KAAK,OAAO,UACV,4DAAA,EAEF,KAAK,WAAaC,CACpB,CAEA,MAAM,cAAcE,EAAiD,OAC7D,MAAAC,EAAYD,GAAU,IACtBE,EAA4C,CAAA,EAE9C,GAAA,CACF,MAAMC,EAAgB,OAAMC,EAAA,KAAK,8BAC9B,IAAA,IADyB,YAAAA,EAExB,0BACEC,EAAsD,CAC1D,OAAQ,kB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J,EAAA,KACJ,GAAI,MAAM,KAAK,WAAWb,EAAWI,EAASa,EAAS,KAAK,MAAM,CAAA,UAGpE,CAAC,CAAC,cAAe,cAAc,EAAE,SAASA,EAAS,KAAK,IAAI,GAC5DA,EAAS,OACT,CACA,MAAMC,EAAS,mBACb,KAAK,WACF,cAAc,EACd,QAAQ,mBACP,GAAGJ,CAAY,GAAGG,EAAS,OAAO,IAAI,EACxC,CAAA,EAEJJ,EAAM,KAAK,CACT,GAAII,EAAS,GACb,MAAOA,EAAS,KAChB,SAAUC,EAAO,QAAQ,aAAc,EAAE,EACzC,IAAK,KAAK,WAAW,UAAA,EAAY,QAAQ,CACvC,KAAM,OACN,OAAQ,CACN,KAAMA,CACR,CACD,CAAA,EAAE,KACH,aAAcD,EAAS,QAAA,CACxB,CACH,CAGK,OAAAJ,CACT,CACF,EArIMlB,EAANwB,EAAA,CADCC,aAAW,EAMPC,aAAe,QAAQ,CAAA,EACvBA,aAAmB,YAAY,CAAA,EAC/BA,aAAsC,+BAA+B,CAAA,CAAA,EAPpE1B,CAAA,EAuIC,MAAM2B,CAAc,CACzB,YAAYC,EAAsB,CAE7BA,EAAA,KAA2BC,EAAwB,IAAA,EACnD,GAAG7B,CAAyB,EAC5B,iBACA,EAAA,gBAAgB,OAAO,CAC5B,CACF"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/components/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { name as NavigationTreeSourceName } from \"@xwiki/cristal-navigation-tree-api\";\nimport { Container, inject, injectable, named } from \"inversify\";\nimport type { CristalApp, Logger, PageData } from \"@xwiki/cristal-api\";\nimport type { AuthenticationManagerProvider } from \"@xwiki/cristal-authentication-api\";\nimport type { DocumentReference } from \"@xwiki/cristal-model-api\";\nimport type { ModelReferenceSerializer } from \"@xwiki/cristal-model-reference-api\";\nimport type { RemoteURLParser } from \"@xwiki/cristal-model-remote-url-api\";\nimport type {\n NavigationTreeNode,\n NavigationTreeSource,\n} from \"@xwiki/cristal-navigation-tree-api\";\n\n/**\n * Implementation of NavigationTreeSource for the XWiki backend.\n *\n * @since 0.10\n **/\n@injectable()\nclass XWikiNavigationTreeSource implements NavigationTreeSource {\n constructor(\n @inject<Logger>(\"Logger\") private readonly logger: Logger,\n @inject<CristalApp>(\"CristalApp\") private readonly cristalApp: CristalApp,\n @inject<AuthenticationManagerProvider>(\"AuthenticationManagerProvider\")\n private authenticationManagerProvider: AuthenticationManagerProvider,\n @inject<RemoteURLParser>(\"RemoteURLParser\")\n @named(\"XWiki\")\n private readonly urlParser: RemoteURLParser,\n @inject<ModelReferenceSerializer>(\"ModelReferenceSerializer\")\n @named(\"XWiki\")\n private readonly referenceSerializer: ModelReferenceSerializer,\n ) {\n this.logger.setModule(\n \"navigation-tree-xwiki.components.XWikiNavigationTreeSource\",\n );\n }\n\n // TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.\n // eslint-disable-next-line max-statements\n async getChildNodes(id?: string): Promise<Array<NavigationTreeNode>> {\n const currentId = id ? id : \"#\";\n const navigationTree: Array<NavigationTreeNode> = [];\n\n try {\n const authorization = await this.authenticationManagerProvider\n .get()\n ?.getAuthorizationHeader();\n const headers: { Accept: string; Authorization?: string } = {\n Accept: \"application/json\",\n };\n\n if (authorization) {\n headers.Authorization = authorization;\n }\n\n navigationTree.push(...(await this.fetchNodes(currentId, headers, 0)));\n } catch (error) {\n this.logger.error(error);\n this.logger.debug(\"Could not load navigation tree.\");\n }\n return navigationTree;\n }\n\n // TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.\n // eslint-disable-next-line max-statements\n getParentNodesId(page?: PageData): Array<string> {\n const result = [];\n if (page) {\n const documentId = page.document.getIdentifier();\n if (!documentId) {\n this.logger.debug(\n `No identifier found for page ${page.name}, cannot resolve parents.`,\n );\n return [];\n }\n // TODO: Use a page resolver instead when CRISTAL-234 is fixed.\n const parents = documentId\n .replace(/\\.WebHome$/, \"\")\n .split(/(?<![^\\\\](?:\\\\\\\\)*\\\\)\\./);\n let currentParent = \"\";\n let i;\n for (i = 0; i < parents.length - 1; i++) {\n currentParent += parents[i];\n // TODO: Support subwikis.\n result.push(`document:xwiki:${currentParent}.WebHome`);\n currentParent += \".\";\n }\n result.push(`document:xwiki:${documentId}`);\n }\n return result;\n }\n\n // TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.\n // eslint-disable-next-line max-statements\n private async fetchNodes(\n currentId: string,\n headers: { Accept: string; Authorization?: string },\n offset: number,\n ): Promise<Array<NavigationTreeNode>> {\n const nodes: Array<NavigationTreeNode> = [];\n const baseXWikiURL = this.cristalApp\n .getWikiConfig()\n .baseURL.replace(/\\/[^/]*$/, \"\");\n\n const navigationTreeRequestUrl = new URL(\n `${this.cristalApp.getWikiConfig().baseURL}/bin/get`,\n );\n navigationTreeRequestUrl.search = new URLSearchParams([\n [\"id\", currentId],\n [\"outputSyntax\", \"plain\"],\n [\"sheet\", \"XWiki.DocumentTree\"],\n [\"data\", \"children\"],\n [\"compact\", \"true\"],\n [\"offset\", offset.toString()],\n [\"showTranslations\", \"false\"],\n [\"showAttachments\", \"false\"],\n ]).toString();\n\n const response = await fetch(navigationTreeRequestUrl, { headers });\n const jsonResponse: [\n {\n id: string;\n text: string;\n children: boolean;\n data: { type: string; offset: number };\n a_attr?: { href: string };\n },\n ] = await response.json();\n for (const treeNode of jsonResponse) {\n if (treeNode.id == \"pagination:wiki:xwiki\") {\n nodes.push(\n ...(await this.fetchNodes(currentId, headers, treeNode.data.offset)),\n );\n } else if (\n ![\"attachments\", \"translations\"].includes(treeNode.data.type) &&\n treeNode.a_attr\n ) {\n const documentReference = this.urlParser.parse(\n `${baseXWikiURL}${treeNode.a_attr.href}`,\n )! as DocumentReference;\n nodes.push({\n id: treeNode.id,\n label: treeNode.text,\n location: documentReference.space!,\n url: this.cristalApp.getRouter().resolve({\n name: \"view\",\n params: {\n page: this.referenceSerializer.serialize(documentReference),\n },\n }).href,\n has_children: treeNode.children,\n });\n }\n }\n\n return nodes;\n }\n}\n\nexport class ComponentInit {\n constructor(container: Container) {\n container\n .bind<NavigationTreeSource>(NavigationTreeSourceName)\n .to(XWikiNavigationTreeSource)\n .inSingletonScope()\n .whenTargetNamed(\"XWiki\");\n }\n}\n"],"names":["XWikiNavigationTreeSource","logger","cristalApp","authenticationManagerProvider","urlParser","referenceSerializer","id","currentId","navigationTree","authorization","_a","headers","error","page","result","documentId","parents","currentParent","i","offset","nodes","baseXWikiURL","navigationTreeRequestUrl","jsonResponse","treeNode","documentReference","__decorateClass","injectable","__decorateParam","ComponentInit","container","NavigationTreeSourceName"],"mappings":"gnBAsCA,IAAMA,EAAN,KAAgE,CAC9D,YAC6CC,EACQC,EAE3CC,EAGSC,EAGAC,EACjB,CAV2C,KAAA,OAAAJ,EACQ,KAAA,WAAAC,EAE3C,KAAA,8BAAAC,EAGS,KAAA,UAAAC,EAGA,KAAA,oBAAAC,EAEjB,KAAK,OAAO,UACV,4DACF,CAAA,CAKF,MAAM,cAAcC,EAAiD,OAC7D,MAAAC,EAAYD,GAAU,IACtBE,EAA4C,CAAC,EAE/C,GAAA,CACF,MAAMC,EAAgB,OAAMC,EAAA,KAAK,8BAC9B,IAAA,IADyB,YAAAA,EAExB,0BACEC,EAAsD,CAC1D,OAAQ,kBACV,EAEIF,IACFE,EAAQ,cAAgBF,GAGXD,EAAA,KAAK,GAAI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A,KACJ,GAAI,MAAM,KAAK,WAAWb,EAAWI,EAASa,EAAS,KAAK,MAAM,CACpE,UAEA,CAAC,CAAC,cAAe,cAAc,EAAE,SAASA,EAAS,KAAK,IAAI,GAC5DA,EAAS,OACT,CACM,MAAAC,EAAoB,KAAK,UAAU,MACvC,GAAGJ,CAAY,GAAGG,EAAS,OAAO,IAAI,EACxC,EACAJ,EAAM,KAAK,CACT,GAAII,EAAS,GACb,MAAOA,EAAS,KAChB,SAAUC,EAAkB,MAC5B,IAAK,KAAK,WAAW,UAAA,EAAY,QAAQ,CACvC,KAAM,OACN,OAAQ,CACN,KAAM,KAAK,oBAAoB,UAAUA,CAAiB,CAAA,CAE7D,CAAA,EAAE,KACH,aAAcD,EAAS,QAAA,CACxB,CAAA,CAIE,OAAAJ,CAAA,CAEX,EA1IMpB,EAAN0B,EAAA,CADCC,aAAW,EAGPC,aAAe,QAAQ,CAAA,EACvBA,aAAmB,YAAY,CAAA,EAC/BA,aAAsC,+BAA+B,CAAA,EAErEA,aAAwB,iBAAiB,CAAA,EACzCA,YAAM,OAAO,CAAA,EAEbA,aAAiC,0BAA0B,CAAA,EAC3DA,YAAM,OAAO,CAAA,CAAA,EAVZ5B,CAAA,EA4IC,MAAM6B,CAAc,CACzB,YAAYC,EAAsB,CAE7BA,EAAA,KAA2BC,EAAwB,IAAA,EACnD,GAAG/B,CAAyB,EAC5B,iBAAA,EACA,gBAAgB,OAAO,CAAA,CAE9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xwiki/cristal-navigation-tree-xwiki",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "license": "LGPL 2.1",
5
5
  "author": "XWiki Org Community <contact@xwiki.org>",
6
6
  "homepage": "https://cristal.xwiki.org/",
@@ -22,15 +22,28 @@
22
22
  },
23
23
  "main": "./dist/index.es.js",
24
24
  "dependencies": {
25
- "inversify": "6.0.3",
26
- "@xwiki/cristal-api": "0.12.0",
27
- "@xwiki/cristal-authentication-api": "0.12.0",
28
- "@xwiki/cristal-navigation-tree-api": "0.12.0"
25
+ "inversify": "6.2.1",
26
+ "@xwiki/cristal-authentication-api": "0.14.0",
27
+ "@xwiki/cristal-model-reference-api": "0.14.0",
28
+ "@xwiki/cristal-model-api": "0.14.0",
29
+ "@xwiki/cristal-model-remote-url-api": "0.14.0",
30
+ "@xwiki/cristal-api": "0.14.0",
31
+ "@xwiki/cristal-navigation-tree-api": "0.14.0"
32
+ },
33
+ "peerDependencies": {
34
+ "reflect-metadata": "0.2.2"
35
+ },
36
+ "devDependencies": {
37
+ "reflect-metadata": "0.2.2",
38
+ "typescript": "5.7.3",
39
+ "vite": "6.0.11",
40
+ "@xwiki/cristal-dev-config": "0.14.0"
29
41
  },
30
42
  "scripts": {
31
43
  "build": "tsc --project tsconfig.json && vite build",
32
44
  "clean": "rimraf dist",
33
- "lint": "eslint \"./src/**/*.{ts,tsx}\" --max-warnings=0"
45
+ "lint": "eslint \"./src/**/*.{ts,tsx,vue}\" --max-warnings=0",
46
+ "test": "vitest --run"
34
47
  },
35
48
  "types": "./dist/index.d.ts"
36
49
  }
@@ -19,9 +19,12 @@
19
19
  */
20
20
 
21
21
  import { name as NavigationTreeSourceName } from "@xwiki/cristal-navigation-tree-api";
22
- import { Container, inject, injectable } from "inversify";
22
+ import { Container, inject, injectable, named } from "inversify";
23
23
  import type { CristalApp, Logger, PageData } from "@xwiki/cristal-api";
24
24
  import type { AuthenticationManagerProvider } from "@xwiki/cristal-authentication-api";
25
+ import type { DocumentReference } from "@xwiki/cristal-model-api";
26
+ import type { ModelReferenceSerializer } from "@xwiki/cristal-model-reference-api";
27
+ import type { RemoteURLParser } from "@xwiki/cristal-model-remote-url-api";
25
28
  import type {
26
29
  NavigationTreeNode,
27
30
  NavigationTreeSource,
@@ -34,22 +37,25 @@ import type {
34
37
  **/
35
38
  @injectable()
36
39
  class XWikiNavigationTreeSource implements NavigationTreeSource {
37
- private cristalApp: CristalApp;
38
- public logger: Logger;
39
-
40
40
  constructor(
41
- @inject<Logger>("Logger") logger: Logger,
42
- @inject<CristalApp>("CristalApp") cristalApp: CristalApp,
41
+ @inject<Logger>("Logger") private readonly logger: Logger,
42
+ @inject<CristalApp>("CristalApp") private readonly cristalApp: CristalApp,
43
43
  @inject<AuthenticationManagerProvider>("AuthenticationManagerProvider")
44
44
  private authenticationManagerProvider: AuthenticationManagerProvider,
45
+ @inject<RemoteURLParser>("RemoteURLParser")
46
+ @named("XWiki")
47
+ private readonly urlParser: RemoteURLParser,
48
+ @inject<ModelReferenceSerializer>("ModelReferenceSerializer")
49
+ @named("XWiki")
50
+ private readonly referenceSerializer: ModelReferenceSerializer,
45
51
  ) {
46
- this.logger = logger;
47
52
  this.logger.setModule(
48
53
  "navigation-tree-xwiki.components.XWikiNavigationTreeSource",
49
54
  );
50
- this.cristalApp = cristalApp;
51
55
  }
52
56
 
57
+ // TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
58
+ // eslint-disable-next-line max-statements
53
59
  async getChildNodes(id?: string): Promise<Array<NavigationTreeNode>> {
54
60
  const currentId = id ? id : "#";
55
61
  const navigationTree: Array<NavigationTreeNode> = [];
@@ -74,6 +80,8 @@ class XWikiNavigationTreeSource implements NavigationTreeSource {
74
80
  return navigationTree;
75
81
  }
76
82
 
83
+ // TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
84
+ // eslint-disable-next-line max-statements
77
85
  getParentNodesId(page?: PageData): Array<string> {
78
86
  const result = [];
79
87
  if (page) {
@@ -101,6 +109,8 @@ class XWikiNavigationTreeSource implements NavigationTreeSource {
101
109
  return result;
102
110
  }
103
111
 
112
+ // TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
113
+ // eslint-disable-next-line max-statements
104
114
  private async fetchNodes(
105
115
  currentId: string,
106
116
  headers: { Accept: string; Authorization?: string },
@@ -121,6 +131,8 @@ class XWikiNavigationTreeSource implements NavigationTreeSource {
121
131
  ["data", "children"],
122
132
  ["compact", "true"],
123
133
  ["offset", offset.toString()],
134
+ ["showTranslations", "false"],
135
+ ["showAttachments", "false"],
124
136
  ]).toString();
125
137
 
126
138
  const response = await fetch(navigationTreeRequestUrl, { headers });
@@ -142,24 +154,20 @@ class XWikiNavigationTreeSource implements NavigationTreeSource {
142
154
  !["attachments", "translations"].includes(treeNode.data.type) &&
143
155
  treeNode.a_attr
144
156
  ) {
145
- const pageId = decodeURIComponent(
146
- this.cristalApp
147
- .getWikiConfig()
148
- .storage.getPageFromViewURL(
149
- `${baseXWikiURL}${treeNode.a_attr.href}`,
150
- )!,
151
- );
157
+ const documentReference = this.urlParser.parse(
158
+ `${baseXWikiURL}${treeNode.a_attr.href}`,
159
+ )! as DocumentReference;
152
160
  nodes.push({
153
161
  id: treeNode.id,
154
162
  label: treeNode.text,
155
- location: pageId.replace(/\.WebHome$/, ""),
163
+ location: documentReference.space!,
156
164
  url: this.cristalApp.getRouter().resolve({
157
165
  name: "view",
158
166
  params: {
159
- page: pageId,
167
+ page: this.referenceSerializer.serialize(documentReference),
160
168
  },
161
169
  }).href,
162
- has_children: treeNode.children, //TODO: ignore translations and attachments
170
+ has_children: treeNode.children,
163
171
  });
164
172
  }
165
173
  }
@@ -0,0 +1,25 @@
1
+ /*
2
+ * See the LICENSE file distributed with this work for additional
3
+ * information regarding copyright ownership.
4
+ *
5
+ * This is free software; you can redistribute it and/or modify it
6
+ * under the terms of the GNU Lesser General Public License as
7
+ * published by the Free Software Foundation; either version 2.1 of
8
+ * the License, or (at your option) any later version.
9
+ *
10
+ * This software is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this software; if not, write to the Free
17
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
+ */
20
+
21
+ import localConfig from "./vite.config";
22
+ import { mergeConfig } from "vitest/config";
23
+ import defaultConfig from "@xwiki/cristal-dev-config/vitest-vue.config";
24
+
25
+ export default mergeConfig(defaultConfig, localConfig);