Use Ontology SDK (OSDK) in a widget set

You can use OSDK in a widget set by following the steps outlined in each section below.

Configure an OSDK for your widget set

To configure an Ontology SDK (OSDK) for your widget set, navigate to the overview page of your widget set and then select Configure SDK in the top bar on the page.

Configure SDK options.

Then, select an ontology and the specific resources that you would like to access from your widget.

Enable Ontology APIs

You also need to enable the Ontology APIs for your widget set to prevent API calls made from the OSDK from failing. This action can be performed by a user with the Information Security Officer role.

Cofigure the OSDK in your widget

After the above steps have been completed, you can start using your OSDK in your widget set. To do so, ensure that @custom-widget/sdk is listed in your package.json and properly installed using the following JSON:

Copied!
1 2 3 4 5 6 7 { // ... "dependencies": { // ... "@custom-widget/sdk": "latest" } }

Ensure that your client is configured with the baseUrl set to window.location.origin. You can provide any dummy value for the auth token, as any access to the ontology would use the user's token and adhere to the user's permissions at runtime. Review the following code snippet:

Copied!
1 2 3 4 5 6 7 8 import { createClient } from "@osdk/client"; import { $ontologyRid } from "@custom-widget/sdk"; const client = createClient( window.location.origin, $ontologyRid, () => Promise.resolve("widgets-auth"), );

Use the OSDK

Refer to your OSDK's documentation to learn more about usage by selecting the SDK docs option on the top bar of your widget set.

SDK docs option.

Limitations

Currently, widgets do not support the following Foundry API features:

  • Object set subscriptions
  • Non-Ontology APIs