@softr/cli 0.1.1-se21216.6 → 0.1.1-se21216.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/cli.mjs +62 -58
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ ones. A workflow directory remembers the target it was pulled from.
|
|
|
49
49
|
| `workspaces` | The workspaces the stored token reaches, with your role in each and the default one. Commands that take `--workspace` default to `SOFTR_WORKSPACE_ID` when it is set, else to your only or default workspace. |
|
|
50
50
|
| `integrations [--workspace <id>] [--type <TYPE>]` | List the workspace's connected integrations (id, name, type, account, auth kind) from the studio API; the id goes into a node's `integrationId` input. Inside a workflow directory the workspace is the workflow's; `--type` filters. Credentials are never shown. |
|
|
51
51
|
|
|
52
|
-
Every command accepts `--json`. `SOFTR_TOKEN` overrides the stored token; `SOFTR_WORKSPACE_ID` is the default workspace.
|
|
52
|
+
Every command accepts `--json`. `SOFTR_TOKEN` overrides the stored token; `SOFTR_WORKSPACE_ID` is the default workspace; `SOFTR_APP_ID` links the workflows `init` creates to that application.
|
|
53
53
|
|
|
54
54
|
## Workflows
|
|
55
55
|
|
|
@@ -133,10 +133,10 @@ node still on 1.0.0 or 1.1.0 keeps its synchronous runtime without `fetch`, and
|
|
|
133
133
|
|
|
134
134
|
| Command | What it does |
|
|
135
135
|
| -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
136
|
-
| `workflows list [--workspace <id>]`
|
|
136
|
+
| `workflows list [--workspace <id>] [--app <id>]` | List the workflows you can access, one table per workspace; `--app` keeps only those linked to that application. A workspace whose listing fails is reported at the end and skipped. |
|
|
137
137
|
| `workflows pull [<workflowId>] [--dir <path>] [--force]` | Download a workflow into a directory (new `./<title-slug>/` by default). Without an id, list what you can pull. |
|
|
138
138
|
| `workflows push [--dir <path>] [--dry-run] [--force]` | Inline `@@` references and code files, save as a new draft. Sends nothing when the files match the last sync, and refuses when the server copy changed since then (`--force` overrides both). Warns about placeholders that no saved test data backs. |
|
|
139
|
-
| `workflows init <title> [--workspace <id>] [--trigger <TYPE>] [--dir <path>]`
|
|
139
|
+
| `workflows init <title> [--workspace <id>] [--app <id>] [--trigger <TYPE>] [--dir <path>]` | Create a workflow on the server with one trigger (default `WEBHOOK`) and the local directory for it; `--app` links it to an application, so the studio lists it with that app. |
|
|
140
140
|
| `workflows upgrade [<nodeId>...] [--dir <path>]` | Move nodes on an older version of their type to the current one (CUSTOM_CODE 1.0.0 and 1.1.0 become 1.2.0: the integrations list is added, the code file keeps its body and gets the new header). Every command that touches a workflow lists such nodes in a note. |
|
|
141
141
|
| `workflows add <TYPE> [--id <id>] [--after <nodeId>] [--in-loop <loopId>] [--to <actionId>] [--lang JAVASCRIPT\|PYTHON] [--title <t>]` | Append an action after a node (default: the only node without a successor) and the path to it, or append a trigger (`--to` connects it). Custom code gets `actions/<id>.js\|py` with an empty function. Comments in the config survive. |
|
|
142
142
|
| `workflows replace <nodeId> <TYPE>` | Give a node another type of the same kind: id, title and paths stay, inputs start from the new template. |
|
package/dist/cli.mjs
CHANGED
|
@@ -14397,8 +14397,8 @@ function updateWorkflow(client, workflowId, body) {
|
|
|
14397
14397
|
function getWorkflowOutputs(client, workflowId) {
|
|
14398
14398
|
return apiRequest(client, "GET", `/v1/workflows/${workflowId}/outputs`);
|
|
14399
14399
|
}
|
|
14400
|
-
function listWorkflows(client, workspaceId) {
|
|
14401
|
-
const query = new URLSearchParams({ workspaceId, limit: "500" });
|
|
14400
|
+
function listWorkflows(client, workspaceId, applicationId) {
|
|
14401
|
+
const query = new URLSearchParams({ workspaceId, ...applicationId ? { applicationId } : {}, limit: "500" });
|
|
14402
14402
|
return apiRequest(client, "GET", `/v1/workflows?${query}`);
|
|
14403
14403
|
}
|
|
14404
14404
|
function testAction(client, workflowId, hierarchyPath2, mode) {
|
|
@@ -14725,7 +14725,7 @@ function toRow(workflow, workspace) {
|
|
|
14725
14725
|
updatedAt: workflow.updatedAt ?? null
|
|
14726
14726
|
};
|
|
14727
14727
|
}
|
|
14728
|
-
async function collectWorkflows(client, workspaceId) {
|
|
14728
|
+
async function collectWorkflows(client, workspaceId, applicationId) {
|
|
14729
14729
|
const workspaces = await listWorkspaces(client);
|
|
14730
14730
|
const selected = workspaceId ? workspaces.filter((workspace) => workspace.id === workspaceId) : workspaces;
|
|
14731
14731
|
if (workspaceId && !selected.length) {
|
|
@@ -14737,7 +14737,7 @@ async function collectWorkflows(client, workspaceId) {
|
|
|
14737
14737
|
const listing = { workspaces: [], workflows: [], failures: [] };
|
|
14738
14738
|
for (const workspace of selected) {
|
|
14739
14739
|
try {
|
|
14740
|
-
const page = await listWorkflows(client, workspace.id);
|
|
14740
|
+
const page = await listWorkflows(client, workspace.id, applicationId);
|
|
14741
14741
|
listing.workspaces.push({ id: workspace.id, name: workspace.name });
|
|
14742
14742
|
listing.workflows.push(...page.items.map((workflow) => toRow(workflow, workspace)));
|
|
14743
14743
|
} catch (error) {
|
|
@@ -14788,16 +14788,16 @@ ${workflowTable(rows)}` : `${heading}
|
|
|
14788
14788
|
}
|
|
14789
14789
|
return blocks.join("\n\n");
|
|
14790
14790
|
}
|
|
14791
|
-
async function emitWorkflowList(options, client, workspaceId, human) {
|
|
14792
|
-
const listing = await collectWorkflows(client, workspaceId);
|
|
14791
|
+
async function emitWorkflowList(options, client, workspaceId, human, applicationId) {
|
|
14792
|
+
const listing = await collectWorkflows(client, workspaceId, applicationId);
|
|
14793
14793
|
emit(options, [human, renderWorkflows(listing)].filter(Boolean).join("\n\n"), { ...listing });
|
|
14794
14794
|
}
|
|
14795
14795
|
function registerList(program3) {
|
|
14796
|
-
program3.command("list").description("List the workflows you can access, grouped by workspace").option("--workspace <id>", "only this workspace (default: $SOFTR_WORKSPACE_ID when set)").action(async (opts, command) => {
|
|
14796
|
+
program3.command("list").description("List the workflows you can access, grouped by workspace").option("--workspace <id>", "only this workspace (default: $SOFTR_WORKSPACE_ID when set)").option("--app <id>", "only the workflows linked to this application").action(async (opts, command) => {
|
|
14797
14797
|
const options = globalOptions(command);
|
|
14798
14798
|
const target = resolveTarget(await readState(process.cwd()));
|
|
14799
14799
|
const client = await authenticatedClient(target);
|
|
14800
|
-
await emitWorkflowList(options, client, opts.workspace ?? process.env["SOFTR_WORKSPACE_ID"]);
|
|
14800
|
+
await emitWorkflowList(options, client, opts.workspace ?? process.env["SOFTR_WORKSPACE_ID"], void 0, opts.app);
|
|
14801
14801
|
});
|
|
14802
14802
|
}
|
|
14803
14803
|
|
|
@@ -15268,58 +15268,62 @@ function registerInit(program3) {
|
|
|
15268
15268
|
program3.command("init").description("Create a new workflow with one trigger, on the server and as a local directory").argument("<title>", "the workflow title").option(
|
|
15269
15269
|
"--workspace <id>",
|
|
15270
15270
|
"workspace to create it in (default: $SOFTR_WORKSPACE_ID, else your only or default workspace)"
|
|
15271
|
-
).option("--trigger <TYPE>", 'trigger type from "spec" (default WEBHOOK)', "WEBHOOK").option("--dir <path>", "directory to create (default: ./<title-slug>)").action(
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
|
|
15280
|
-
|
|
15281
|
-
|
|
15282
|
-
|
|
15283
|
-
|
|
15284
|
-
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
|
|
15288
|
-
|
|
15289
|
-
|
|
15290
|
-
|
|
15291
|
-
|
|
15292
|
-
|
|
15293
|
-
|
|
15294
|
-
|
|
15295
|
-
|
|
15296
|
-
|
|
15297
|
-
|
|
15298
|
-
|
|
15299
|
-
|
|
15300
|
-
|
|
15301
|
-
|
|
15302
|
-
|
|
15303
|
-
|
|
15304
|
-
|
|
15305
|
-
|
|
15306
|
-
|
|
15307
|
-
|
|
15308
|
-
|
|
15271
|
+
).option("--app <id>", "application to link the workflow to (default: $SOFTR_APP_ID when set)").option("--trigger <TYPE>", 'trigger type from "spec" (default WEBHOOK)', "WEBHOOK").option("--dir <path>", "directory to create (default: ./<title-slug>)").action(
|
|
15272
|
+
async (title, opts, command) => {
|
|
15273
|
+
const options = globalOptions(command);
|
|
15274
|
+
const cwd = process.cwd();
|
|
15275
|
+
const dir = path10.resolve(cwd, opts.dir ?? slug(title));
|
|
15276
|
+
if (await configExists(dir)) {
|
|
15277
|
+
throw new CliError(`${path10.join(dir, CONFIG_FILE_NAME)} already exists.`, "Pick another --dir or title.");
|
|
15278
|
+
}
|
|
15279
|
+
const trigger = findCatalogEntry(opts.trigger, "trigger");
|
|
15280
|
+
const target = resolveTarget();
|
|
15281
|
+
const client = await authenticatedClient(target);
|
|
15282
|
+
const workspaceId = await resolveWorkspace(client, opts.workspace ?? process.env["SOFTR_WORKSPACE_ID"]);
|
|
15283
|
+
const applicationId = opts.app ?? process.env["SOFTR_APP_ID"] ?? null;
|
|
15284
|
+
const created = await createWorkflow(client, {
|
|
15285
|
+
workspaceId,
|
|
15286
|
+
applicationId,
|
|
15287
|
+
title,
|
|
15288
|
+
thumbnail: null,
|
|
15289
|
+
triggers: [{ id: TRIGGER_ID, type: trigger.type, version: trigger.version, inputs: trigger.template }],
|
|
15290
|
+
actions: [],
|
|
15291
|
+
paths: [],
|
|
15292
|
+
// Like the studio: the author's time zone, so schedules and waits mean what they read.
|
|
15293
|
+
configuration: { timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC" }
|
|
15294
|
+
});
|
|
15295
|
+
const workflow = await getWorkflow(client, created.id);
|
|
15296
|
+
const config = { $schema: SCHEMA_POINTER, ...toLocalConfig(workflow) };
|
|
15297
|
+
const configFile = await writeConfig(dir, config);
|
|
15298
|
+
await writeSchemaFile(dir);
|
|
15299
|
+
const syncedHash = definitionHash((await packWorkflow(config, dir)).packed);
|
|
15300
|
+
await writeState(dir, {
|
|
15301
|
+
...target,
|
|
15302
|
+
workflowId: created.id,
|
|
15303
|
+
version: workflow.version,
|
|
15304
|
+
draft: workflow.draft,
|
|
15305
|
+
syncedHash
|
|
15306
|
+
});
|
|
15307
|
+
const studioUrl = `${target.studioUrl}/workflow/${created.id}`;
|
|
15308
|
+
emit(
|
|
15309
|
+
options,
|
|
15310
|
+
`Created "${title}" (${created.id}) with a ${trigger.type} trigger "${TRIGGER_ID}" in workspace ${workspaceId}${applicationId ? `, linked to application ${applicationId}` : ""}.
|
|
15309
15311
|
${path10.relative(cwd, configFile)}
|
|
15310
15312
|
${studioUrl}
|
|
15311
15313
|
Next: softr workflows add <TYPE> --dir ${path10.relative(cwd, dir) || "."} (see "spec" for the types), then push and test.`,
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
|
|
15317
|
-
|
|
15318
|
-
|
|
15319
|
-
|
|
15320
|
-
|
|
15321
|
-
|
|
15322
|
-
|
|
15314
|
+
{
|
|
15315
|
+
workflowId: created.id,
|
|
15316
|
+
workspaceId,
|
|
15317
|
+
applicationId,
|
|
15318
|
+
title,
|
|
15319
|
+
triggerId: TRIGGER_ID,
|
|
15320
|
+
triggerType: trigger.type,
|
|
15321
|
+
dir,
|
|
15322
|
+
studioUrl
|
|
15323
|
+
}
|
|
15324
|
+
);
|
|
15325
|
+
}
|
|
15326
|
+
);
|
|
15323
15327
|
}
|
|
15324
15328
|
|
|
15325
15329
|
// src/commands/integrations.ts
|
|
@@ -16690,7 +16694,7 @@ Pass --workspace <id> to a command, or set SOFTR_WORKSPACE_ID, to work in one of
|
|
|
16690
16694
|
// package.json
|
|
16691
16695
|
var package_default = {
|
|
16692
16696
|
name: "@softr/cli",
|
|
16693
|
-
version: "0.1.1-se21216.
|
|
16697
|
+
version: "0.1.1-se21216.7",
|
|
16694
16698
|
description: "The Softr command line: build, test and publish Softr workflows from local files; more Softr APIs to come",
|
|
16695
16699
|
keywords: [
|
|
16696
16700
|
"softr",
|
package/package.json
CHANGED