text
Function, in @jr2/orchestrator/src/http-effect.ts. It is an export of @jr2/orchestrator, on the Authoring surface page, in Effects.
ts
function text<
const V extends Array<Secret | OpenSecret | string>,
>(
strings: TemplateStringsArray,
...values: V,
): MarkedIf<V[number], Text>Make a string from literal text and Effect secrets, as a tagged template: text`Token ${secret("x")}`. The Effector puts in the value of each secret when it makes the call. Use it for a url with a secret in its path, or for a header value. Use it also for auth, where it is the whole Authorization header, or for a part of basic.
It refuses a ${…} that is not a secret(...) or a string: text`…`: a value is a secret("name") or a string, got <value>.
Parameters
strings: The literal text of the template.values: The${…}values, each asecret(...)or a string.
Returns: The string, which the Effector makes.
Example
ts
import { http, jr2Setup, secret, text } from "@jr2/orchestrator";
export const machine = jr2Setup({
actors: {
notify: http({
method: "POST",
url: text`https://api.telegram.org/bot${secret("telegram")}/sendMessage`,
headers: { "x-run-source": text`jr2` },
request: () => ({ json: { chat_id: "12345", text: "The run is done." } }),
}),
},
}).createMachine({
id: "notify",
initial: "notifying",
states: {
notifying: { invoke: { src: "notify", onDone: "done" } },
done: { type: "final" },
},
});See also