Functions in Marketplace

You can use Foundry DevOps to include your functions in Marketplace products for other users to install and reuse.

Adding functions to products

To add a function to a product, create a product. Then, add a function output as shown below.

Add a function output.

You will be prompted to choose a function and a version.

Search for a function.

Including source code for code repositories

When packaging a function authored in a code repository, the backing repository will be automatically included as an additional output in the product. While you can choose to package the code repository with its source code, we generally discourage including source code for products not intended to be installed in bootstrap mode. This is because a Marketplace-installed function does not need its backing source code to execute successfully. Additionally, code repositories are not guaranteed to compile or build out of the box.

If you want to make changes to a function post-installation (for example, to fix a bug or augment functionality), we recommend making those changes to the original function, releasing a new version of the Marketplace product, and then upgrading the installation. If you do not own the installed product, you should reach out to its maintainers with a bug report or feature request.

Version and API name resolution

When a function is installed through Marketplace, there are two ways in which its version and API name are resolved: deduplication mode and stable mode.

Deduplication mode

This is the historical and default behavior for resolving a function's version and API name when installed through Marketplace.

In deduplication mode, a function's version is resolved as follows:

  • When a function is initially created by an installation, its first version is published at 0.1.0.
  • Upon subsequent installations such as upgrades, the function is published at its latest version incremented by a minor version. For example, if the latest version of the installed function is 1.1.0, the next installation will publish at 1.2.0.

Function versions are immutable. In other words, once a version of a function is published, it cannot be mutated or overridden.

The way a function's API name is resolved is as follows:

  • If the API name is already bound to another function in the installation's Ontology, the API name will be deduplicated by appending an incrementing integer suffix. For example, if the API name myFunction is already taken, the function will be installed with API name myFunction1. If that API name is also taken, it will be installed with API name myFunction2, and so on.
  • Once an API name exists on the installed function, the function maintains that API name through subsequent installations such as upgrades.

Function API names are unique per-Ontology. To be precise, if there already exists a function with an API name myFunction in an Ontology, no other function with the same API name can exist in that same Ontology.

Stable mode

Beta

Stable mode is in the beta phase of development and may not be available on your enrollment. Functionality may change during active development. Contact Palantir Support to enable this on your enrollment.

Versions and API names are an integral part of your function’s API. It is therefore desirable in many cases to preserve them when packaging and installing them through Marketplace. It is especially important when installing functions alongside upstream applications that reference function dependencies statically, as in Developer Console applications.

In stable mode, a function's version is resolved as follows:

  • The installed function is always published at its packaged version.
  • If the version already exists for the installed function, an entirely new function will be created; the old function will be hidden and its API name will be removed.

Creating new functions to resolve version conflicts affects upstream applications. If an upstream application is part of the same installation, it is automatically updated to reference the new function. Otherwise, you will need to update it manually.

A function's API name is resolved as follows:

  • The installed function is always published with the API name it was packaged with.
  • If the API name is already taken by another function, an installation error will occur. To resolve this conflict, you must delete the existing function or change its API name.

Static function inputs

This feature is only supported in TypeScript v1.

It is possible to modify parts of a function’s behavior at install time by providing a locally defined function which overrides the "static" function input that is shipped with your Marketplace product. To do this, you can specify that a particular function may be overridden by using the @Static decorator.

import { Function, Static, Double } from "@foundry/functions-api";

export class MyFunctions {

    @Function()
    public async modifyNumberByStaticFoo(
        n: Double,
        @Static() staticFunctionInput: (num: Double) => Promise<Double> = this.defaultFoo
    ): Promise<Double> {
        return await staticFunctionInput(n);
    }

    private async defaultFoo(n: number) {
        return -n;
    }

}

When packaging a function, any static inputs will appear as function inputs during installation. Installers can then provide their own function logic that will override the default behavior.

Calling queries or making API calls within overridden static functions is not supported.