Open UI Extension - fetch document path

Hi guys!

I started using Open UI Document Field Extension. I am wondering, is it possible to fetch document path for the document using Open UI Extension JavaScript Client Library.

I need document path for identifying the channel (root channel content folder). Then, it will be used for gathering API url that will be used in Open UI for fetching data from API.

Thanks in advance!

I’m not sure if there’s an API to retrieve the document path.
Perhaps you can add configuration in the frontend:config property of your OpenUI Extension configuration [2] to include the URL of your backend API.

You can read the config like the following:

  // read the frontend:config string property and parse it to a json object.
  const config = ui.extension.config;
  // you may use the string value of the config directly or parse it to JSON if possible...

Regards,

Woonsan

[2] Configure a Document Field Extension - Bloomreach Experience - Headless Digital Experience Platform

Thank you for quick reply.
Yes, I am using Open UI extension config for storing some common properties but it does not fit my needs for 100%.
By opening the document (where I have Open UI Extension), Open UI needs somehow identify document location (JCR Path) of the document and, based on this info, gather an API url (https:api/example.com/{channel}/products)

As the OpenUI API can give the document handle UUID, perhaps you can implement a repository managed JAX-RS component [3] giving the document info based on the uuid.

Woonsan

[3] Repository-Managed Components - Bloomreach Experience - Headless Digital Experience Platform

Thank you for advice. Yeah, it is a way how I can solve the problem.
One more option is to use derived property function for populating document path info to the document, then I can fetch this property in Open UI.
But it looks a little bit complicated for such case, from my point of view.
Another way is to customise OpenUiStringPlugin and FieldLookupService but I would not like to modify default platform functionality as it can lead to some problem during platform version upgrade and support.

If you configured a reverse proxy to enable the Channel Manager preview like [1], then your delivery application URL can be exposed to both: (1) delivery-tier url, and (2) preview-purpose authoring-tier URL with /site context path like the following:

<VirtualHost *:443>
  ServerName cms.example.com
  #...
  ProxyPass /site/ http://127.0.0.1:8080/site/
  ProxyPass / http://127.0.0.1:8080/cms/
  ProxyPassReverse / http://127.0.0.1:8080/cms/
  ProxyPassReverseCookiePath /cms /
</VirtualHost>


<VirtualHost *:443>
  ServerName www.example.com
  ServerAlias *.example.com
  #...
  ProxyPass / http://127.0.0.1:8080/site/
  ProxyPassReverse / http://127.0.0.1:8080/site/
  ProxyPassReverseCookiePath /site /
</VirtualHost>

So, in the above example, the delivery-tier domain (www.example.com) exposes the delivery application only, but the authoring-tier domain (cms.example.com) exposes both the authoring application (/cms) and the delivery application at /site context path, for preview purpose.

Therefore, if your “API” to use in your OpenUI Extension is always deployed onto the “delivery app” anyway, then your OpenUI Extension may possibly use the “API” url in the cms domain too without having to do anythings extra. e.g, https://cms.example.com/site/api/mystuffs.

Just thinking aloud,

Woonsan

[1] Configure Apache HTTP Server as Reverse Proxy for Hippo - Bloomreach Experience - Headless Digital Experience Platform

Thank you @woonsanko so much!
I implemented JAX-RS resource to expose all needed info for document by handle uuid.

It will be nice if OpenUI provide an extension point for such purposes (custom property\value provider).

Thanks, Mykyta

Thanks for the feedback!
Not sure if it will help directly or not, but we will support variable references and interpolation using the Container Configuration in the coming release, v14.7+, in the near future.

In summary, since v14.7, the frontend:config property value may contain variable references using the Container Configuration [1] for the CMS application (e.g, $CATALINA_BASE/conf/platform.properties).
Suppose this property is set to the following containing a reference to the variable called “backend.url”:

{ "my.backend.api.url": "${backend.url}" }

And if you set the backend.url property with value, “https://api.example.com”, in the Container Configuration [1] for the CMS application (e.g, $CATALINA_BASE/conf/platform.properties), then the property value will be interpreted to the following at runtime:

{ "my.backend.api.url": "https://api.example.com/" }

So, it could be possible to use a different platform.properties for example per environment with different settings.

Regards,

Woonsan

[1] HST-2 Container Configuration - Bloomreach Experience Manager (PaaS/Self-Hosted) - The Fast and Flexible Headless CMS