CRI Format
Overview
A CRI (Kinotic Resource Identifier) is used by Kinotic to route requests to the appropriate service, method, or event stream. It is a URI-like format with parts named for clarity within the Kinotic platform.
Format
scheme://[scope@]resourceName[/path][#version]
Everything in brackets ([]) is optional.
Components
Scheme
Identifies the type of resource being addressed.
| Scheme | Description |
|---|---|
srv | Published services and their methods |
stream | Event streams |
Scope
An optional qualifier that narrows the CRI to a specific context, such as a tenant ID, user ID, or device ID. When present, it appears before the @ symbol.
If a scope needs sub-scopes, use the format scope:sub-scope.
srv://tenant-123@com.example.OrderService
stream://device-42@temperature/sensor-1
Resource Name
The name of the resource being addressed. For services, this is the fully qualified service name. For streams, this is the event type name.
srv://com.example.UserService
stream://temperature
Path
An optional path that identifies a specific part of the resource, such as a method name on a service.
srv://com.example.UserService/findById
stream://temperature/sensor-1
Version
An optional semantic version for the resource. Enables versioned service routing so multiple versions of a service can coexist.
srv://com.example.UserService/findById#1.0.0
srv://com.example.UserService#2.0.0
Factory Function
The createCRI function provides several overloads for constructing CRI instances:
import { createCRI } from '@kinotic-ai/core'
// From a raw string
const cri1 = createCRI('srv://com.example.UserService/findById#1.0.0')
// From scheme and resource name
const cri2 = createCRI('srv', 'com.example.UserService')
// From scheme, scope, and resource name
const cri3 = createCRI('stream', 'tenant-123', 'orders')
// From all components
const cri4 = createCRI('srv', null, 'com.example.UserService', 'findById', '1.0.0')
CRI Interface
The CRI interface provides methods to access each component:
const cri = createCRI('srv://tenant-123@com.example.OrderService/placeOrder#2.0.0')
cri.scheme() // 'srv'
cri.scope() // 'tenant-123'
cri.hasScope() // true
cri.resourceName() // 'com.example.OrderService'
cri.path() // 'placeOrder'
cri.hasPath() // true
cri.version() // '2.0.0'
cri.hasVersion() // true
cri.baseResource() // 'srv://tenant-123@com.example.OrderService'
cri.raw() // 'srv://tenant-123@com.example.OrderService/placeOrder#2.0.0'
Examples
| CRI | Description |
|---|---|
srv://com.example.UserService | A published service |
srv://com.example.UserService/findById | A specific method on a service |
srv://com.example.UserService/findById#1.0.0 | A versioned service method |
stream://temperature | An event stream for temperature data |
stream://temperature/sensor-1 | A specific path within a stream |
stream://tenant-123@orders/placed | A scoped event stream |
srv://tenant-123@com.example.OrderService | A scoped service |