Skip to content

BioLM/lltp-js

Repository files navigation

lltp-js

JavaScript/TypeScript reference SDK for LLTP (Lab-in-the-Loop Transport Protocol) v0.1.

Maintained by BioLM during protocol kickoff. See the spec repo GOVERNANCE.md for long-term stewardship intent.

Status: v0.1-alpha. Message signing (sign / verify) is not yet implemented.

Install

npm install lltp
# from source:
npm install
npm run build

Requires Node.js >=18 (native fetch).

Quick start

import { validateEnvelope, deriveOrderStatus } from "lltp";
import { readFileSync } from "node:fs";

const order = JSON.parse(
  readFileSync("tests/fixtures/scenario-a-dna-synthesis/01-order.json", "utf8"),
);

validateEnvelope(order);
console.log(deriveOrderStatus(order.requirements)); // IN_PROGRESS

Mock provider (Scenario A)

npm run mock-provider -- --port 8765

In another shell:

import { LLTPClient } from "lltp";
import { readFileSync } from "node:fs";

const order = JSON.parse(
  readFileSync("tests/fixtures/scenario-a-dna-synthesis/01-order.json", "utf8"),
);

const client = new LLTPClient();
const catalog = await client.fetchCatalog("http://127.0.0.1:8765");
const summary = await client.submitOrder("http://127.0.0.1:8765", order);
console.log(summary);

API overview

Export Purpose
validateEnvelope, validateCatalog JSON Schema validation (Ajv)
deriveOrderStatus, mergeRequirements Lifecycle derivation and STATUS merge
LLTPClient HTTP client for provider endpoints
WebhookHandler Merge STATUS/RESULT deltas with dedupe
OrderEnvelope, StatusEnvelope, … Vendored wire types from spec

Tests

npm ci
npm run build
npm test

Refreshing vendored schemas, types, and fixtures

When the spec repo changes:

cp ../lltp/schema/0.1/{envelope,provider}.schema.json src/schemas/
cp ../lltp/schema/0.1/*.ts src/schema/
cp ../lltp/examples/catalog/twist.json tests/fixtures/catalog/
cp ../lltp/examples/scenario-a-dna-synthesis/*.json tests/fixtures/scenario-a-dna-synthesis/
cp ../lltp/examples/scenario-b-approval-gate/0{1,2,3}*.json tests/fixtures/scenario-b-approval-gate/

Conformance

See CONFORMANCE.md for what this alpha SDK implements vs deferred.

Related repositories

License

Apache-2.0. See LICENSE.

About

JavaScript/TypeScript reference SDK for LLTP v0.1

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors