HomeGuidesAPI Reference
Log In
Guides

Spektr SDK

📦 JavaScript: client-sdk (npm)

  1. Get the npm repository endpoint:
export CODEARTIFACT_NPM_URL=$(aws codeartifact get-repository-endpoint \
  --domain spektr \
  --domain-owner {spektr-id} \
  --repository spektr-npm \
  --format npm \
  --query repositoryEndpoint \
  --output text)
  1. Authenticate npm:
aws codeartifact login \
  --tool npm \
  --domain spektr \
  --domain-owner {spektr-id} \
  --repository spektr-npm

This command automatically configures your .npmrc to use the CodeArtifact repo.

  1. Install the package:
npm install @spektr/client-sdk

✅ Notes

  • Your access is limited to read-only access to specific repositories.
  • The external ID is required when assuming the role, do not share it externally.
  • The token expires after 12 hours; you’ll need to refresh it using the above steps.

Conditional Fields unwrap

Usage:

The formEvaluation method unwraps the full form after evaluation of all the conditional fields and rules.

import SpektrSdk from '@spektr/client-sdk'

// example
const unwrappedForm = SpektrSdk.formEvaluation(form, {
      first_name: 'John',
      last_name: 'Doe',
      date_of_birth: '1747170000000',
      country_of_residence: 'DK'
})


Translation

Usage:

The translateFields method transforms all the field labels to the provided language passed as argument. This can also be used to generate all the options for static values such as NACE codes, Country codes, etc.

import SpektrSdk from '@spektr/client-sdk'

const translatedForm = await SpektrSdk.translateFields(
  response.node.form.fields, selectedLanguage
);