Skip to content

Package UIs

This page describes how to serve a web user interface (UI) from a package, and how an Administrator approves it.

A package can carry a web UI: plain HTML, JavaScript, and CSS files stored in the package next to manifest.yaml. The Package Manager serves these files straight from the package, so a UI needs no separate hosting, image, or deployment. Push the package and open it in a browser.

Because a package UI is script that runs in the browser of whoever opens it, a UI's scripts run only after an Administrator approves that exact version. See Approval and the Package UI approval reference.

How a UI is served

What Detail
URL <platform host>/packagemanager/file/<package>/
Default page index.html (or index.htm) at the requested directory. /file/<package> redirects to /file/<package>/.
Other files Any file in the package, at its path: /file/<package>/assets/app.js
Version The latest version of the package, unless you pass ?version=<version>.
Access Requests are authenticated and entitled like any other package request.
Headers X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, Referrer-Policy: same-origin, and Cache-Control: private, no-store. SAMEORIGIN lets another page on the platform embed your UI.

In the URL, <platform host> is the address of your kdb Insights Enterprise deployment.

Files are served inline on the platform origin, so an approved page's scripts run with the rights of whoever opens it. That is why approval exists.

Prerequisites

Before you build and serve a package UI:

  • Install the command-line interface (CLI) and authenticate with your deployment.
  • Ensure you have write access to the package that will contain the UI.
  • Ask a user with the Administrator role to review and approve the package version. An Administrator is also required to configure the content security policy (CSP).
  • Install Node.js if you want to follow the optional Vite examples on this page.

Build a package UI

A package UI is an ordinary package whose files include a web page. Any toolchain works as long as the result is a directory of static files with an index.html.

Create the package

To create the package, run the following command:

kxi package init my-ui --version 1.0.0

This creates my-ui/ with a manifest.yaml. A UI needs no tables, pipelines, or other components, so the manifest can stay minimal. For example:

name: my-ui
version: 1.0.0
metadata:
  description: "My package UI"

Quote values that contain a colon

Quote any description that contains a colon followed by a space. Otherwise the manifest is not valid YAML, and the server rejects the push.

Add the UI files

Put the page and its assets in the package directory:

my-ui/
  manifest.yaml
  index.html
  assets/
    app.js
    style.css

Every file in the package directory is stored, except those matched by .kxignore. By default, .kxignore leaves out .git, .vscode, .gh, .svn, .nfs*, and .uuid. Add patterns to a .kxignore file in the package to leave out source maps, node_modules or other build leftovers.

Do not include secrets

Do not put credentials, tokens, private keys, or other secrets in the package. Exclude source maps and other files that expose sensitive source or configuration. Treat .kxignore as a packaging aid, not as a security boundary, and check the package contents before you push them.

Use document-relative URLs

The page is served below /packagemanager/file/<package>/, not at the site root, so reference everything relative to the page:

<link rel="stylesheet" href="assets/style.css" />
<script type="module" src="./assets/app.js"></script>

A root-absolute URL such as src="/assets/app.js" points at the platform host, not your package, and returns 404. Do not hard-code /packagemanager either, because a proxy might add or remove that prefix. Work out the API root from location.pathname, or use relative URLs.

For a bundler, set the public base to ./. With Vite:

import { defineConfig } from 'vite';

export default defineConfig({
  base: './',
  build: { outDir: 'dist', emptyOutDir: true },
});

Build into a directory, then copy manifest.yaml next to the built index.html and assets/.

Write for the content security policy (CSP)

A CSP is a set of rules that tells the browser which scripts and resources a page may load. An approved UI is served with the Administrator's PACKAGE_UI_CSP policy, if one is set. Ask the Administrator for the policy, and avoid what a strict one blocks: inline <script> blocks and eval. Keep scripts in files, which works under script-src 'self'. See Configure the Administrator CSP.

An unapproved UI is served with Content-Security-Policy: sandbox, so scripts and forms do not run at all. Test the page in that state too. It shows something sensible, such as static content, until it is approved.

Pack it

You can push the directory directly, or pack it into a .kxi artifact first:

kxi package packit my-ui --target ./artifacts

This writes a .kxi file into ./artifacts. A .kxi file is a zip archive with manifest.yaml at its root, so a build script can also create it with zip:

cd build/my-ui && zip -qr -X ../my-ui-1.0.0.kxi manifest.yaml index.html assets

Push it

Run the following:

kxi pm push my-ui                        # a package directory
kxi pm push artifacts/my-ui-1.0.0.kxi    # or the artifact

Pushing over an existing version overwrites its files, which also ends any approval of that version. See When an approval ends. On a directory push, use --bump patch (or minor or major) to raise the version first. Use --force to overwrite without a prompt.

Open <platform host>/packagemanager/file/my-ui/. The page loads, but its scripts do not run, and a popup says that an Administrator has to approve the UI. This is expected until the version is approved.

Develop locally

Run your development server with its API paths proxied to a Package Manager, so you do not push for every change. With Vite, proxy /v2, /file, /platform, and the other platform paths to the server (for example, http://localhost:8080). Configure the local proxy to pass an Authorization: Bearer <token> header. Read the token from a local-only environment variable or another secure local configuration. Never embed the token in browser code or built assets, or commit it to source control. Push the package only when you need to test the real approval and CSP behavior.

Approval

A UI's scripts run only for an approved version. Approval is an Administrator decision, bound to one package version and its exact content.

Role Does
Author (write access to the package) Builds and pushes the package, then asks an Administrator to approve the version.
Administrator Reviews the package content, then approves the version.

The workflow

  1. Author pushes the package: kxi pm push my-ui.
  2. Author tells the Administrator the package name and version, and what changed since the last approved version.
  3. Administrator reviews exactly what was pushed. List the files, then download the package, or single files, to read them:

    kxi pm file list --package my-ui
    kxi pm pull my-ui 1.0.0
    kxi pm file get assets/app.js --package my-ui --output ./app.js
    

    Review every script, including minified bundles and anything loaded from another host. Approve only what you have reviewed.

  4. Administrator approves the version. This needs the Administrator role:

    kxi pm config approve-ui my-ui --version 1.0.0
    

    Without --version, the latest version is approved. An Administrator who opens an unapproved page also sees this command, with the right package and version, in the popup.

  5. Administrator checks the result:

    kxi pm config list-ui
    

    The status for the version is approved.

  6. Author reloads <platform host>/packagemanager/file/my-ui/. The popup is gone, and the scripts run.

When an approval ends

For details about when an approval ends, approval states, and how to revoke an approval, see Package UI approval.

Troubleshooting

Symptom Cause and fix
The page shows, but nothing runs, and a popup mentions approval The version is not approved, or its approval ended. Ask an Administrator to run kxi pm config approve-ui.
The popup says the content changed Content was pushed after the approval. Review it, and approve again.
kxi pm config approve-ui is denied It needs the Administrator role. Ask an Administrator.
CSS and JavaScript files return 404 An asset URL starts with /. Make it document-relative.
404 for the package Wrong name or version. Check the output of kxi pm list.
The console reports a CSP violation The Administrator policy blocks something the page does, usually an inline script or a request to another host. Move it into a file, or ask the Administrator to adjust PACKAGE_UI_CSP.
list-ui shows package not found The approved version was removed. Revoke the stale entry.
The push is rejected manifest.yaml is not valid YAML, or it lacks name. Quote descriptions that contain a colon followed by a space.

Example

This is the complete journey for a UI built with a bundler:

# author
npm ci && npm run build
cp manifest.yaml dist/
kxi pm push dist

# Administrator
kxi pm pull my-ui 1.0.0
kxi pm config approve-ui my-ui --version 1.0.0
kxi pm config list-ui

Next steps

Back to top