@eloquentops/retool-test-lib
v0.2.0
Published
A dual-target JavaScript library for Retool apps and workflows.
Downloads
247
Maintainers
Readme
retool-test-lib
@eloquentops/retool-test-lib is a small JavaScript library scaffolded for two Retool use cases:
- Retool apps via a CDN-hosted UMD bundle exposed as
window.RetoolTestLib - Retool Workflows via
require("retool-test-lib")
Public API
The package exports the same top-level API in both environments:
versiongreet(name)sum(...values)pickDefined(object)createRecordId(prefix)
Install for Retool Workflows
In a Workflow, add the package to the workflow package.json:
{
"dependencies": {
"@eloquentops/retool-test-lib": "^0.1.0"
}
}Then use it in a JavaScript Code block:
const lib = require("@eloquentops/retool-test-lib");
return {
hello: lib.greet("Workflow"),
total: lib.sum(10, 20, "5"),
cleaned: lib.pickDefined({
id: 42,
name: "Example",
optional: undefined
})
};Install for Retool Apps with a CDN URL
After publishing to npm, either of these CDN URLs can be added in Retool app settings under Libraries:
https://cdn.jsdelivr.net/npm/@eloquentops/retool-test-lib@latest/dist/index.umd.min.js
https://unpkg.com/@eloquentops/retool-test-lib@latest/dist/index.umd.min.jsOnce loaded, call it from JavaScript or {{ }} expressions:
window.RetoolTestLib.greet("App");
window.RetoolTestLib.sum(1, 2, 3);
window.RetoolTestLib.createRecordId("customer");Local Development
Install dependencies:
npm installBuild the package:
npm run buildRun the smoke test:
npm run smoke-testPublished Files
The build emits:
dist/index.cjsforrequire()and package consumers, minifieddist/index.umd.min.jsfor CDN usage in Retool, minified
Publish to npm
Update the package name and version as needed, then publish:
npm publish