devtk-core
v1.0.0
Published
Pure developer utility functions for DevToolbox
Readme
devtk-core
Shared, local utility functions for the DevToolbox website, devtk CLI, and devtk-mcp server. Requires Node.js 20 or newer. The functions do not call a hosted DevToolbox service or execute shell commands.
Install
npm install devtk-coreUse
import {
compareJson,
jsonToTypescript,
parseCurl,
curlToCode,
queryJson,
validateCron,
nextCronRuns,
compactSql,
} from 'devtk-core'
compareJson({ active: true }, { active: false })
jsonToTypescript({ name: 'Ada', active: true }, 'User')
const request = parseCurl('curl -X POST https://example.com/api -d "hello"')
curlToCode(request, 'fetch') // Also supports 'axios' and 'python'
await queryJson({ users: [{ name: 'Ada' }] }, '$.users[*].name', 'jsonpath')
await queryJson({ users: [{ name: 'Ada' }] }, '.users[] | .name', 'jq')
validateCron('0 9 * * 1-5')
nextCronRuns('0 9 * * 1-5', 'Asia/Kolkata') // UTC ISO strings
compactSql("select 'from' as word from words")Behavior and limits
compareJson(before, after, ignoreArrayOrder = false)returns changed paths. Object key order is ignored; array order is significant unless requested otherwise.jsonToTypescript(value, rootName = 'Root')infers types from a sample. A single sample cannot establish every optional field in a real API.parseCurl(source)parses common cURL flags as text. It does not execute the command.curlToCode(request, language)returns{ code, credentials }; review generated requests before running them.queryJson(value, expression, mode)keeps JSONPath and jq syntax separate. jq runs through a local WebAssembly dependency.- Cron accepts standard five-field expressions and IANA time zones. Preview search is bounded to 25 years; cron dialects differ.
compactSql(sql)reduces whitespace outside quoted strings and comments. It is not a SQL optimizer or validator.
License
MIT. See LICENSE.
