Deploying and Registering a JSSP Service Type

To build your JSSP project, run the NPM build command as shown below. This generates a bundled .js file in the /dist folder, which is the file you use to create a service type in K2.

To build a compact bundled file, execute the command
npm run build
You can use the following command syntax to build a more readable .js file:
npm run build:dev

There are two ways you can register your new custom JSSP service type:

Once the Service Type is registered, you can configure one or more service instances of the new service.

If you change your broker code and update the bundled .js file, you must refresh service instances that use the bundled .js file, and regenerate or update SmartObjects based on the service.

Create From URL

You can use the Create From URL approach to register your JSSP service type when the bundled .js file is located in a URL. For example, use this approach if you want to register a service type based on a .js file that someone else maintains and updates to a central location, or if you are building your own service type and will publish the .js file to a URL. In this case, when you're ready to test your code, copy the latest version of the bundled .js file from the /dist folder to a publicly-accessible location, such as GitHub (use GitHub's Raw view URL if the bundled js file is a project source file).

Once the .js code file is available at a URL, open the K2 Management site and browse to the JavaScript Service Provider SmartObject located at Categories > System > Management > SmartObjects > SmartObjects. Execute the Create method and supply a name, description, and URL, then click OK.

The File URL must be in a location accessible to the K2 environment you are working in.

Create from File

Use the Create From File approach to register your JSSP service type when you do not want to publish your bundled .js file to a URL, but rather want to store the .js file in the K2 database. You will use a K2-provided SmartForm to deploy your .jssp file to your K2 environment.

When using this approach, you must rename your .js file to a .jssp file, otherwise the file upload will fail. If you used the sample projects provided by K2, you can configure your source to generate your bundled file automatically as a .jssp file by editing the rollup.config.js supporting file

If this is the first time you are deploying any .jssp file, use the Package and Deployment tool to deploy the provided .kspx deployment package to your K2 environment. This package contains the JSSP Connector Form. (If you have not enabled Package and Deployment in your K2 environment yet, see the article How To: Download, Install, and Start Using the Package and Deployment for K2 Cloud.)

Once you have deployed the JSSP Connector form with the provided package, you can run the JSSP Connector Form located in the JSSP Connector Management folder. Specify a System Name, Display Name and Description, and then upload your .jssp file. Click the Create or Update button. Keep a note of the System Name handy for updating your service type. You will use the same form and the same System Name to update an existing service type with a new version, and remember to refresh any service instances that use the service type to pick up any changes made in the new version.

Using the JSSP Service Type Management Form to upload/update a .jssp file

Considerations when deploying and registering a JSSP Service Type