Specify Docs
Specify ↗︎Changelog ↗︎Guide ↗︎
V2
V2
  • Getting started
    • Introduction
    • What is Specify?
    • Pulling your first tokens with the CLI
    • Glossary
  • Collect
    • What is a Source?
    • Available sources
      • Figma Variables & Styles
      • Tokens Studio
  • Distribute
    • What is a Destination?
    • Available destinations
      • GitHub
      • Specify CLI
      • Specify SDK
      • HTTP API
  • Concepts
    • Overview
    • Parsers Engine
    • SDTF Client
      • SDTF Engine
    • Specify Design Token Format
  • Guides
    • Configuration file 101
    • Specify CLI usage 101
      • Getting started
      • Authentication
      • Generate Files
    • Specify SDK usage 101
      • Getting started
      • Retrieving and working with the tokens
      • Updating tokens
      • Converting a token to XXX
      • Executing generation parsers
    • Specify SDK Cheatsheet
    • Manage font files
    • Querying a SDTF graph
  • Reference
    • Parsers Engine
    • Parsers
      • change-case
      • convert-color
      • convert-dimension
      • make-line-height-relative
      • filter
      • register-view
      • select-modes
      • prefix-by
      • suffix-by
      • replace-string
      • to-css-custom-properties
      • to-css-text-style
      • to-css-font-import
      • to-flutter
      • to-javascript
      • to-json
      • to-json-list
      • to-kotlin
      • to-react-native
      • to-scss-mixin-text-style
      • to-scss-map
      • to-sdtf
      • to-style-dictionary
      • to-swift
      • to-tailwind
      • to-typescript
      • svgo
      • svg-to-jsx
      • svg-to-tsx
      • to-svg-file
      • to-bitmap-file
      • to-file
    • Specify SDK
      • SpecifyClient
      • SDTFClient
      • Converters
        • CSS
      • ParsersEngineResults
    • SDTF Engine
      • Query API
      • Mutation API
      • SDTF Query Language
      • SDTF QueryResult
      • TokenState
        • Stateful Value
    • HTTP API
      • POST /parsers-engine-rpc
    • Specify CLI
  • Resources
    • Parser Rules templates
      • CSS Custom Properties
      • Tailwind
      • React Native
      • Flutter
      • SDTF
      • JSON
    • Specify CLI VS Specify SDK
    • Playground
    • Best practices
  • Useful links
    • Discord
    • YouTube
    • Twitter
    • Help Center
    • Canny
Powered by GitBook
On this page
  • getTokenState
  • getGroupState
  • getCollectionState
  • getNearestCollectionState
  • getAllTokenStates
  • getAllGroupStates
  • getAllCollectionStates
  • getAllNodeStates
  • getTokenChildrenOf
  • getGroupChildrenOf
  • getCollectionChildrenOf
  • getChildrenOf
  • getParentsOf
  • getGroupChildren
  • getTokenChildren
  • getCollectionChildren
  • renderJSONTree
  • getAliasReference
  • getAllAliasReferences
  • getAliasReferencesTo
  • getAliasReferencesFrom
  • getStatefulAliasReference
  • getStatefulAliasReferencesTo
  • getStatefulAliasReferencesFrom

Was this helpful?

Export as PDF
  1. Reference
  2. SDTF Engine

Query API

Methods for locally accessing and iterating the token tree.

You access each of the query methods over:

sdtfEngine.query.[method]

getTokenState

Get a tokenState instance from the tokens token tree.

function getTokenState(
  path: Array<string>
):
  | { status: "resolved"; tokenState: TokenState<Type> }
  | { status: "unresolvable"; reason: "DOES_NOT_EXIST" };

getGroupState

Get a groupState instance from the tokens token tree.

function getGroupState(
  path: Array<string>
):
  | { status: "resolved"; groupState: GroupState }
  | { status: "unresolvable"; reason: "DOES_NOT_EXIST" };

getCollectionState

Get a collectionState instance from the tokens token tree.

function getCollectionState(
  path: Array<string>
):
  | { status: 'resolved'; collectionState: CollectionState }
  | { status: 'unresolvable'; reason: 'DOES_NOT_EXIST' };

getNearestCollectionState

Get the collectionState instance enclosing the given path.

function getNearestCollectionState(
  path: Array<string>
):     | { status: 'resolved'; collectionState: CollectionState }
  | { status: 'unresolvable'; reason: 'DOES_NOT_EXIST' };

getAllTokenStates

Get all tokenState instances from the tokens token tree.

function getAllTokenStates(): Array<TokenState>;

getAllGroupStates

Get all groupState instances from the tokens token tree.

function getAllGroupStates(): Array<GroupState>;

getAllCollectionStates

Get all collectionState instances from the tokens token tree.

function getAllCollectionStates(): Array<CollectionState>;

getAllNodeStates

Get all tokenState, groupState and collectionState instances from the tokens token tree.

function getAllNodeStates(): Array<TokenState | GroupState | CollectionState>;

getTokenChildrenOf

Get the tokenState instances that are children of the given path.

function getTokenChildrenOf(path: Array<string>): Array<TokenState>;

getGroupChildrenOf

Get the groupState instances that are children of the given path.

function getGroupChildrenOf(path: Array<string>): Array<GroupState>;

getCollectionChildrenOf

Get the collectionState instances that are children of the given path.

function getCollectionChildrenOf(path: Array<string>): Array<CollectionState>;

getChildrenOf

Get the tokenState, groupState and collectionState instances that are children of the given path.

function getChildrenOf(path: Array<string>, depth: number): Array<TokenState | GroupState | CollectionState>;

getParentsOf

Get the groupState and collectionState instances that are parents of the given path.

function getParentsOf(path: Array<string>, depth: number): Array<TokenState | GroupState | CollectionState>;

getGroupChildren

Get groupState instances that are direct children of the given path.

function getGroupChildren(path: Array<string>): Array<GroupState>;

getTokenChildren

Get tokenState instances that are direct children of the given path.

function getTokenChildren(path: Array<string>): Array<TokenState>;

getCollectionChildren

Get collectionState instances that are direct children of the given path.

function getCollectionChildren(path: Array<string>): Array<CollectionState>;

renderJSONTree

Get the JSON representation of the tokens token tree.

function renderJSONTree(renderOptions: RenderOptions): JSON;

getAliasReference

Get the aliasReference instance from given coordinates.

function getAliasReference(
  from: AliasReferenceCoordinates
): Result<AliasReference, SDTFError>;

getAllAliasReferences

Get all aliasReference instances from the tokens token tree.

function getAllAliasReferences(): Array<AliasReference>;

getAliasReferencesTo

Get all aliasReference instances that reference the given "to" coordinates.

function getAliasReferencesTo(
  to: Partial<AliasReferenceCoordinates>,
  options: AliasReferenceResolvabilityOptions
): Array<AliasReference>;

getAliasReferencesFrom

Get all aliasReference instances that reference the given "from" coordinates.

function getAliasReferencesFrom(
  from: Partial<AliasReferenceCoordinates>,
  options: AliasReferenceResolvabilityOptions
): Array<AliasReference>;

getStatefulAliasReference

Get the statefulAliasReference instance of the given "from" coordinates.

function getStatefulAliasReference(
  from: AliasReferenceCoordinates
): Result<StatefulAliasReference, SDTFError>;

getStatefulAliasReferencesTo

Get the statefulAliasReference instances that reference the given "to" coordinates.

function getStatefulAliasReferencesTo(
  to: Partial<AliasReferenceCoordinates>,
  options: AliasReferenceResolvabilityOptions
): Array<StatefulAliasReference>;

getStatefulAliasReferencesFrom

Get the statefulAliasReference instances that reference the given "from" coordinates.

function getStatefulAliasReferencesFrom(
  from: Partial<AliasReferenceCoordinates>,
  options: AliasReferenceResolvabilityOptions
): Array<StatefulAliasReference>;
PreviousSDTF EngineNextMutation API

Last updated 1 year ago

Was this helpful?