@xwiki/cristal-navigation-tree-xwiki 0.21.1 → 0.22.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,17 +1,20 @@
1
1
  # @xwiki/cristal-navigation-tree-xwiki
2
2
 
3
- ## 0.21.1
3
+ ## 0.22.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Cristal 0.22 Release
4
8
 
5
9
  ### Patch Changes
6
10
 
7
- - Cristal 0.21.1 Release
8
11
  - Updated dependencies
9
- - @xwiki/cristal-api@0.21.1
10
- - @xwiki/cristal-authentication-api@0.21.1
11
- - @xwiki/cristal-model-api@0.21.1
12
- - @xwiki/cristal-model-reference-api@0.21.1
13
- - @xwiki/cristal-model-remote-url-api@0.21.1
14
- - @xwiki/cristal-navigation-tree-api@0.21.1
12
+ - @xwiki/cristal-api@0.22.0
13
+ - @xwiki/cristal-authentication-api@0.22.0
14
+ - @xwiki/cristal-model-api@0.22.0
15
+ - @xwiki/cristal-model-reference-api@0.22.0
16
+ - @xwiki/cristal-model-remote-url-api@0.22.0
17
+ - @xwiki/cristal-navigation-tree-api@0.22.0
15
18
 
16
19
  ## 0.21.0
17
20
 
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "../../../api-extractor.json"
4
+ }
@@ -1,4 +1,7 @@
1
1
  import { Container } from 'inversify';
2
+ /**
3
+ * @beta
4
+ */
2
5
  export declare class ComponentInit {
3
6
  constructor(container: Container);
4
7
  }
@@ -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, named } from \"inversify\";\nimport type { CristalApp, Logger } 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\") private readonly logger: Logger,\n @inject(\"CristalApp\") private readonly cristalApp: CristalApp,\n @inject(\"AuthenticationManagerProvider\")\n private authenticationManagerProvider: AuthenticationManagerProvider,\n @inject(\"RemoteURLParser\")\n @named(\"XWiki\")\n private readonly urlParser: RemoteURLParser,\n @inject(\"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 getParentNodesId(\n page: DocumentReference,\n includeTerminal: boolean = true,\n includeRootNode?: boolean,\n ): Array<string> {\n const result = includeRootNode ? [\"\"] : [];\n if (page.space) {\n let currentParent = \"\";\n for (const parent of page.space!.names) {\n currentParent += parent;\n // TODO: Support subwikis.\n result.push(`document:xwiki:${currentParent}.WebHome`);\n currentParent += \".\";\n }\n if (page.name != \"WebHome\" && includeTerminal) {\n result.push(\n `document:xwiki:${this.referenceSerializer.serialize(page)}`,\n );\n }\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 is_terminal: !treeNode.id.endsWith(\".WebHome\"),\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 .whenNamed(\"XWiki\");\n }\n}\n"],"names":["XWikiNavigationTreeSource","logger","cristalApp","authenticationManagerProvider","urlParser","referenceSerializer","id","currentId","navigationTree","authorization","headers","error","page","includeTerminal","includeRootNode","result","currentParent","parent","offset","nodes","baseXWikiURL","navigationTreeRequestUrl","jsonResponse","treeNode","documentReference","__decorateClass","injectable","__decorateParam","ComponentInit","container","NavigationTreeSourceName"],"mappings":";;;;;;;AAsCA,IAAMA,IAAN,MAAgE;AAAA,EAC9D,YACqCC,GACIC,GAE/BC,GAGSC,GAGAC,GACjB;AAVmC,SAAA,SAAAJ,GACI,KAAA,aAAAC,GAE/B,KAAA,gCAAAC,GAGS,KAAA,YAAAC,GAGA,KAAA,sBAAAC,GAEjB,KAAK,OAAO;AAAA,MACV;AAAA,IAAA;AAAA,EAEJ;AAAA;AAAA;AAAA,EAIA,MAAM,cAAcC,GAAiD;AACnE,UAAMC,IAAYD,KAAU,KACtBE,IAA4C,CAAA;AAElD,QAAI;AACF,YAAMC,IAAgB,MAAM,KAAK,8BAC9B,IAAA,GACC,uBAAA,GACEC,IAAsD;AAAA,QAC1D,QAAQ;AAAA,MAAA;AAG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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 } 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 * @beta\n **/\n@injectable()\nclass XWikiNavigationTreeSource implements NavigationTreeSource {\n constructor(\n @inject(\"Logger\") private readonly logger: Logger,\n @inject(\"CristalApp\") private readonly cristalApp: CristalApp,\n @inject(\"AuthenticationManagerProvider\")\n private authenticationManagerProvider: AuthenticationManagerProvider,\n @inject(\"RemoteURLParser\")\n @named(\"XWiki\")\n private readonly urlParser: RemoteURLParser,\n @inject(\"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 getParentNodesId(\n page: DocumentReference,\n includeTerminal: boolean = true,\n includeRootNode?: boolean,\n ): Array<string> {\n const result = includeRootNode ? [\"\"] : [];\n if (page.space) {\n let currentParent = \"\";\n for (const parent of page.space!.names) {\n currentParent += parent;\n // TODO: Support subwikis.\n result.push(`document:xwiki:${currentParent}.WebHome`);\n currentParent += \".\";\n }\n if (page.name != \"WebHome\" && includeTerminal) {\n result.push(\n `document:xwiki:${this.referenceSerializer.serialize(page)}`,\n );\n }\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 is_terminal: !treeNode.id.endsWith(\".WebHome\"),\n });\n }\n }\n\n return nodes;\n }\n}\n\n/**\n * @beta\n */\nexport class ComponentInit {\n constructor(container: Container) {\n container\n .bind<NavigationTreeSource>(NavigationTreeSourceName)\n .to(XWikiNavigationTreeSource)\n .inSingletonScope()\n .whenNamed(\"XWiki\");\n }\n}\n"],"names":["XWikiNavigationTreeSource","logger","cristalApp","authenticationManagerProvider","urlParser","referenceSerializer","id","currentId","navigationTree","authorization","headers","error","page","includeTerminal","includeRootNode","result","currentParent","parent","offset","nodes","baseXWikiURL","navigationTreeRequestUrl","jsonResponse","treeNode","documentReference","__decorateClass","injectable","__decorateParam","ComponentInit","container","NavigationTreeSourceName"],"mappings":";;;;;;;AAuCA,IAAMA,IAAN,MAAgE;AAAA,EAC9D,YACqCC,GACIC,GAE/BC,GAGSC,GAGAC,GACjB;AAVmC,SAAA,SAAAJ,GACI,KAAA,aAAAC,GAE/B,KAAA,gCAAAC,GAGS,KAAA,YAAAC,GAGA,KAAA,sBAAAC,GAEjB,KAAK,OAAO;AAAA,MACV;AAAA,IAAA;AAAA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A,OAAM,OAAO,CAAA;AAAA,GAVZ3B,CAAA;AA0IC,MAAM4B,EAAc;AAAA,EACzB,YAAYC,GAAsB;AAChC,IAAAA,EACG,KAA2BC,CAAwB,EACnD,GAAG9B,CAAyB,EAC5B,iBAAA,EACA,UAAU,OAAO;AAAA,EACtB;AACF;"}
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(o,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@xwiki/cristal-navigation-tree-api"),require("inversify")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-navigation-tree-api","inversify"],h):(o=typeof globalThis<"u"?globalThis:o||self,h(o["cristal_navigation-tree-xwiki"]={},o.cristalNavigationTreeApi,o.inversify))})(this,function(o,h,s){"use strict";var f=Object.getOwnPropertyDescriptor,g=(t,i,r,e)=>{for(var n=e>1?void 0:e?f(i,r):i,c=t.length-1,d;c>=0;c--)(d=t[c])&&(n=d(n)||n);return n},l=(t,i)=>(r,e)=>i(r,e,t);let u=class{constructor(t,i,r,e,n){this.logger=t,this.cristalApp=i,this.authenticationManagerProvider=r,this.urlParser=e,this.referenceSerializer=n,this.logger.setModule("navigation-tree-xwiki.components.XWikiNavigationTreeSource")}async getChildNodes(t){const i=t||"#",r=[];try{const e=await this.authenticationManagerProvider.get()?.getAuthorizationHeader(),n={Accept:"application/json"};e&&(n.Authorization=e),r.push(...await this.fetchNodes(i,n,0))}catch(e){this.logger.error(e),this.logger.debug("Could not load navigation tree.")}return r}getParentNodesId(t,i=!0,r){const e=r?[""]:[];if(t.space){let n="";for(const c of t.space.names)n+=c,e.push(`document:xwiki:${n}.WebHome`),n+=".";t.name!="WebHome"&&i&&e.push(`document:xwiki:${this.referenceSerializer.serialize(t)}`)}return e}async fetchNodes(t,i,r){const e=[],n=this.cristalApp.getWikiConfig().baseURL.replace(/\/[^/]*$/,""),c=new URL(`${this.cristalApp.getWikiConfig().baseURL}/bin/get`);c.search=new URLSearchParams([["id",t],["outputSyntax","plain"],["sheet","XWiki.DocumentTree"],["data","children"],["compact","true"],["offset",r.toString()],["showTranslations","false"],["showAttachments","false"]]).toString();const w=await(await fetch(c,{headers:i})).json();for(const a of w)if(a.id=="pagination:wiki:xwiki")e.push(...await this.fetchNodes(t,i,a.data.offset));else if(!["attachments","translations"].includes(a.data.type)&&a.a_attr){const p=this.urlParser.parse(`${n}${a.a_attr.href}`);e.push({id:a.id,label:a.text,location:p.space,url:this.cristalApp.getRouter().resolve({name:"view",params:{page:this.referenceSerializer.serialize(p)}}).href,has_children:a.children,is_terminal:!a.id.endsWith(".WebHome")})}return e}};u=g([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"))],u);class m{constructor(i){i.bind(h.name).to(u).inSingletonScope().whenNamed("XWiki")}}o.ComponentInit=m,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@xwiki/cristal-navigation-tree-api"),require("inversify")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-navigation-tree-api","inversify"],h):(o=typeof globalThis<"u"?globalThis:o||self,h(o["cristal_navigation-tree-xwiki"]={},o.cristalNavigationTreeApi,o.inversify))})(this,(function(o,h,s){"use strict";var f=Object.getOwnPropertyDescriptor,g=(t,i,r,e)=>{for(var n=e>1?void 0:e?f(i,r):i,c=t.length-1,d;c>=0;c--)(d=t[c])&&(n=d(n)||n);return n},l=(t,i)=>(r,e)=>i(r,e,t);let u=class{constructor(t,i,r,e,n){this.logger=t,this.cristalApp=i,this.authenticationManagerProvider=r,this.urlParser=e,this.referenceSerializer=n,this.logger.setModule("navigation-tree-xwiki.components.XWikiNavigationTreeSource")}async getChildNodes(t){const i=t||"#",r=[];try{const e=await this.authenticationManagerProvider.get()?.getAuthorizationHeader(),n={Accept:"application/json"};e&&(n.Authorization=e),r.push(...await this.fetchNodes(i,n,0))}catch(e){this.logger.error(e),this.logger.debug("Could not load navigation tree.")}return r}getParentNodesId(t,i=!0,r){const e=r?[""]:[];if(t.space){let n="";for(const c of t.space.names)n+=c,e.push(`document:xwiki:${n}.WebHome`),n+=".";t.name!="WebHome"&&i&&e.push(`document:xwiki:${this.referenceSerializer.serialize(t)}`)}return e}async fetchNodes(t,i,r){const e=[],n=this.cristalApp.getWikiConfig().baseURL.replace(/\/[^/]*$/,""),c=new URL(`${this.cristalApp.getWikiConfig().baseURL}/bin/get`);c.search=new URLSearchParams([["id",t],["outputSyntax","plain"],["sheet","XWiki.DocumentTree"],["data","children"],["compact","true"],["offset",r.toString()],["showTranslations","false"],["showAttachments","false"]]).toString();const w=await(await fetch(c,{headers:i})).json();for(const a of w)if(a.id=="pagination:wiki:xwiki")e.push(...await this.fetchNodes(t,i,a.data.offset));else if(!["attachments","translations"].includes(a.data.type)&&a.a_attr){const p=this.urlParser.parse(`${n}${a.a_attr.href}`);e.push({id:a.id,label:a.text,location:p.space,url:this.cristalApp.getRouter().resolve({name:"view",params:{page:this.referenceSerializer.serialize(p)}}).href,has_children:a.children,is_terminal:!a.id.endsWith(".WebHome")})}return e}};u=g([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"))],u);class m{constructor(i){i.bind(h.name).to(u).inSingletonScope().whenNamed("XWiki")}}o.ComponentInit=m,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, named } from \"inversify\";\nimport type { CristalApp, Logger } 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\") private readonly logger: Logger,\n @inject(\"CristalApp\") private readonly cristalApp: CristalApp,\n @inject(\"AuthenticationManagerProvider\")\n private authenticationManagerProvider: AuthenticationManagerProvider,\n @inject(\"RemoteURLParser\")\n @named(\"XWiki\")\n private readonly urlParser: RemoteURLParser,\n @inject(\"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 getParentNodesId(\n page: DocumentReference,\n includeTerminal: boolean = true,\n includeRootNode?: boolean,\n ): Array<string> {\n const result = includeRootNode ? [\"\"] : [];\n if (page.space) {\n let currentParent = \"\";\n for (const parent of page.space!.names) {\n currentParent += parent;\n // TODO: Support subwikis.\n result.push(`document:xwiki:${currentParent}.WebHome`);\n currentParent += \".\";\n }\n if (page.name != \"WebHome\" && includeTerminal) {\n result.push(\n `document:xwiki:${this.referenceSerializer.serialize(page)}`,\n );\n }\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 is_terminal: !treeNode.id.endsWith(\".WebHome\"),\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 .whenNamed(\"XWiki\");\n }\n}\n"],"names":["XWikiNavigationTreeSource","logger","cristalApp","authenticationManagerProvider","urlParser","referenceSerializer","id","currentId","navigationTree","authorization","headers","error","page","includeTerminal","includeRootNode","result","currentParent","parent","offset","nodes","baseXWikiURL","navigationTreeRequestUrl","jsonResponse","treeNode","documentReference","__decorateClass","injectable","__decorateParam","ComponentInit","container","NavigationTreeSourceName"],"mappings":"4jBAsCA,IAAMA,EAAN,KAAgE,CAC9D,YACqCC,EACIC,EAE/BC,EAGSC,EAGAC,EACjB,CAVmC,KAAA,OAAAJ,EACI,KAAA,WAAAC,EAE/B,KAAA,8BAAAC,EAGS,KAAA,UAAAC,EAGA,KAAA,oBAAAC,EAEjB,KAAK,OAAO,UACV,4DAAA,CAEJ,CAIA,MAAM,cAAcC,EAAiD,CACnE,MAAMC,EAAYD,GAAU,IACtBE,EAA4C,CAAA,EAElD,GAAI,CACF,MAAMC,EAAgB,MAAM,KAAK,8BAC9B,IAAA,GACC,uBAAA,EACEC,EAAsD,CAC1D,OAAQ,kB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K,MAAM,CAAA,UAGpE,CAAC,CAAC,cAAe,cAAc,EAAE,SAASA,EAAS,KAAK,IAAI,GAC5DA,EAAS,OACT,CACA,MAAMC,EAAoB,KAAK,UAAU,MACvC,GAAGJ,CAAY,GAAGG,EAAS,OAAO,IAAI,EAAA,EAExCJ,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,CAC5D,CACD,EAAE,KACH,aAAcD,EAAS,SACvB,YAAa,CAACA,EAAS,GAAG,SAAS,UAAU,CAAA,CAC9C,CACH,CAGF,OAAOJ,CACT,CACF,EArIMnB,EAANyB,EAAA,CADCC,aAAA,EAGIC,aAAO,QAAQ,CAAA,EACfA,aAAO,YAAY,CAAA,EACnBA,aAAO,+BAA+B,CAAA,EAEtCA,aAAO,iBAAiB,CAAA,EACxBA,YAAM,OAAO,CAAA,EAEbA,aAAO,0BAA0B,CAAA,EACjCA,YAAM,OAAO,CAAA,CAAA,EAVZ3B,CAAA,EAuIC,MAAM4B,CAAc,CACzB,YAAYC,EAAsB,CAChCA,EACG,KAA2BC,EAAAA,IAAwB,EACnD,GAAG9B,CAAyB,EAC5B,iBAAA,EACA,UAAU,OAAO,CACtB,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 } 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 * @beta\n **/\n@injectable()\nclass XWikiNavigationTreeSource implements NavigationTreeSource {\n constructor(\n @inject(\"Logger\") private readonly logger: Logger,\n @inject(\"CristalApp\") private readonly cristalApp: CristalApp,\n @inject(\"AuthenticationManagerProvider\")\n private authenticationManagerProvider: AuthenticationManagerProvider,\n @inject(\"RemoteURLParser\")\n @named(\"XWiki\")\n private readonly urlParser: RemoteURLParser,\n @inject(\"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 getParentNodesId(\n page: DocumentReference,\n includeTerminal: boolean = true,\n includeRootNode?: boolean,\n ): Array<string> {\n const result = includeRootNode ? [\"\"] : [];\n if (page.space) {\n let currentParent = \"\";\n for (const parent of page.space!.names) {\n currentParent += parent;\n // TODO: Support subwikis.\n result.push(`document:xwiki:${currentParent}.WebHome`);\n currentParent += \".\";\n }\n if (page.name != \"WebHome\" && includeTerminal) {\n result.push(\n `document:xwiki:${this.referenceSerializer.serialize(page)}`,\n );\n }\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 is_terminal: !treeNode.id.endsWith(\".WebHome\"),\n });\n }\n }\n\n return nodes;\n }\n}\n\n/**\n * @beta\n */\nexport class ComponentInit {\n constructor(container: Container) {\n container\n .bind<NavigationTreeSource>(NavigationTreeSourceName)\n .to(XWikiNavigationTreeSource)\n .inSingletonScope()\n .whenNamed(\"XWiki\");\n }\n}\n"],"names":["XWikiNavigationTreeSource","logger","cristalApp","authenticationManagerProvider","urlParser","referenceSerializer","id","currentId","navigationTree","authorization","headers","error","page","includeTerminal","includeRootNode","result","currentParent","parent","offset","nodes","baseXWikiURL","navigationTreeRequestUrl","jsonResponse","treeNode","documentReference","__decorateClass","injectable","__decorateParam","ComponentInit","container","NavigationTreeSourceName"],"mappings":"6jBAuCA,IAAMA,EAAN,KAAgE,CAC9D,YACqCC,EACIC,EAE/BC,EAGSC,EAGAC,EACjB,CAVmC,KAAA,OAAAJ,EACI,KAAA,WAAAC,EAE/B,KAAA,8BAAAC,EAGS,KAAA,UAAAC,EAGA,KAAA,oBAAAC,EAEjB,KAAK,OAAO,UACV,4DAAA,CAEJ,CAIA,MAAM,cAAcC,EAAiD,CACnE,MAAMC,EAAYD,GAAU,IACtBE,EAA4C,CAAA,EAElD,GAAI,CACF,MAAMC,EAAgB,MAAM,KAAK,8BAC9B,IAAA,GACC,uBAAA,EACEC,EAAsD,CAC1D,OAAQ,kBAAA,EAGND,IACFC,EAAQ,cAAgBD,GAG1BD,EAAe,KAAK,GAAI,MAAM,KAAK,WAAWD,EAAWG,EAAS,CAAC,CAAE,CACvE,OAASC,EAAO,CACd,KAAK,OAAO,MAAMA,CAAK,EACvB,KAAK,OAAO,MAAM,iCAAiC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J,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,CAC5D,CACD,EAAE,KACH,aAAcD,EAAS,SACvB,YAAa,CAACA,EAAS,GAAG,SAAS,UAAU,CAAA,CAC9C,CACH,CAGF,OAAOJ,CACT,CACF,EArIMnB,EAANyB,EAAA,CADCC,aAAA,EAGIC,aAAO,QAAQ,CAAA,EACfA,aAAO,YAAY,CAAA,EACnBA,aAAO,+BAA+B,CAAA,EAEtCA,aAAO,iBAAiB,CAAA,EACxBA,YAAM,OAAO,CAAA,EAEbA,aAAO,0BAA0B,CAAA,EACjCA,YAAM,OAAO,CAAA,CAAA,EAVZ3B,CAAA,EA0IC,MAAM4B,CAAc,CACzB,YAAYC,EAAsB,CAChCA,EACG,KAA2BC,EAAAA,IAAwB,EACnD,GAAG9B,CAAyB,EAC5B,iBAAA,EACA,UAAU,OAAO,CACtB,CACF"}
@@ -0,0 +1,16 @@
1
+ ## API Report File for "@xwiki/cristal-navigation-tree-xwiki"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { Container } from 'inversify';
8
+
9
+ // @beta (undocumented)
10
+ export class ComponentInit {
11
+ constructor(container: Container);
12
+ }
13
+
14
+ // (No @packageDocumentation comment for this package)
15
+
16
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xwiki/cristal-navigation-tree-xwiki",
3
- "version": "0.21.1",
3
+ "version": "0.22.0",
4
4
  "license": "LGPL 2.1",
5
5
  "author": "XWiki Org Community <contact@xwiki.org>",
6
6
  "homepage": "https://cristal.xwiki.org/",
@@ -26,30 +26,32 @@
26
26
  }
27
27
  },
28
28
  "main": "./dist/index.es.js",
29
+ "types": "./dist/index.d.ts",
29
30
  "dependencies": {
30
- "@xwiki/cristal-api": "0.21.1",
31
- "@xwiki/cristal-authentication-api": "0.21.1",
32
- "@xwiki/cristal-model-api": "0.21.1",
33
- "@xwiki/cristal-model-remote-url-api": "0.21.1",
34
- "@xwiki/cristal-navigation-tree-api": "0.21.1",
35
- "@xwiki/cristal-model-reference-api": "0.21.1"
31
+ "@xwiki/cristal-api": "0.22.0",
32
+ "@xwiki/cristal-model-reference-api": "0.22.0",
33
+ "@xwiki/cristal-model-remote-url-api": "0.22.0",
34
+ "@xwiki/cristal-navigation-tree-api": "0.22.0",
35
+ "@xwiki/cristal-authentication-api": "0.22.0",
36
+ "@xwiki/cristal-model-api": "0.22.0"
36
37
  },
37
38
  "peerDependencies": {
38
39
  "inversify": "7.x",
39
40
  "reflect-metadata": "0.x"
40
41
  },
41
42
  "devDependencies": {
42
- "inversify": "7.7.0",
43
+ "inversify": "7.9.0",
43
44
  "reflect-metadata": "0.2.2",
44
45
  "typescript": "5.9.2",
45
- "vite": "7.0.6",
46
- "@xwiki/cristal-dev-config": "0.21.1"
46
+ "vite": "7.1.5",
47
+ "@xwiki/cristal-dev-config": "0.22.0"
47
48
  },
48
49
  "scripts": {
49
- "build": "tsc --project tsconfig.json && vite build",
50
+ "api-extractor:local": "api-extractor run --local",
51
+ "build": "vite build",
50
52
  "clean": "rimraf dist",
51
53
  "lint": "eslint \"./src/**/*.{ts,tsx,vue}\" --max-warnings=0",
52
- "test": "vitest --run"
53
- },
54
- "types": "./dist/index.d.ts"
54
+ "test": "vitest --run",
55
+ "typecheck": "tsc"
56
+ }
55
57
  }
@@ -34,6 +34,7 @@ import type {
34
34
  * Implementation of NavigationTreeSource for the XWiki backend.
35
35
  *
36
36
  * @since 0.10
37
+ * @beta
37
38
  **/
38
39
  @injectable()
39
40
  class XWikiNavigationTreeSource implements NavigationTreeSource {
@@ -171,6 +172,9 @@ class XWikiNavigationTreeSource implements NavigationTreeSource {
171
172
  }
172
173
  }
173
174
 
175
+ /**
176
+ * @beta
177
+ */
174
178
  export class ComponentInit {
175
179
  constructor(container: Container) {
176
180
  container
package/vitest.config.ts CHANGED
@@ -19,7 +19,7 @@
19
19
  */
20
20
 
21
21
  import localConfig from "./vite.config";
22
+ import { vitestVue as defaultConfig } from "@xwiki/cristal-dev-config";
22
23
  import { mergeConfig } from "vitest/config";
23
- import defaultConfig from "@xwiki/cristal-dev-config/vitest-vue.config";
24
24
 
25
25
  export default mergeConfig(defaultConfig, localConfig);