@softr/cli 0.1.1 → 0.1.2-se21873.13

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 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; `SOFTR_PINNED_APP_ID` pins the workflows `init` creates to that application.
52
+ Every command accepts `--json`. `SOFTR_TOKEN` overrides the stored token; `SOFTR_WORKSPACE_ID` is the default workspace.
53
53
 
54
54
  ## Workflows
55
55
 
@@ -133,10 +133,11 @@ 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>] [--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. |
136
+ | `workflows list [--workspace <id>] [--app <id>]` | List the workflows you can access, one table per workspace, with their trigger types; `--json` gives each trigger's id too (`triggers`), the `triggerId` app code fires a workflow by. `--app` keeps only those pinned 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>] [--pin-to-app <id>] [--trigger <TYPE>] [--dir <path>]` | Create a workflow on the server with one trigger (default `WEBHOOK`) and the local directory for it; `--pin-to-app` pins it to an application, so the app lists it. |
139
+ | `workflows init <title> [--workspace <id>] [--pin-to-app <id>] [--trigger <TYPE>] [--dir <path>]` | Create a workflow on the server with one trigger (default `WEBHOOK`) and the local directory for it; `--pin-to-app` (default `SOFTR_PINNED_APP_ID`) pins it to an application of the same workspace, so the app lists it. |
140
+ | `workflows pin [--app <id>] [--id <workflowId>] [--dir <path>]` / `unpin` | Pin an existing workflow to an application of its workspace, or remove it from the app. The app defaults to `SOFTR_PINNED_APP_ID`, the workflow to the one in the directory. |
140
141
  | `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
142
  | `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
143
  | `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
@@ -14401,6 +14401,12 @@ function listWorkflows(client, workspaceId, { applicationId } = {}) {
14401
14401
  const query = new URLSearchParams({ workspaceId, ...applicationId ? { applicationId } : {}, limit: "500" });
14402
14402
  return apiRequest(client, "GET", `/v1/workflows?${query}`);
14403
14403
  }
14404
+ function pinWorkflow(client, workflowId, applicationId) {
14405
+ return apiRequestVoid(client, "POST", `/v1/workflows/${workflowId}/pinned-applications/${applicationId}`);
14406
+ }
14407
+ function unpinWorkflow(client, workflowId, applicationId) {
14408
+ return apiRequestVoid(client, "DELETE", `/v1/workflows/${workflowId}/pinned-applications/${applicationId}`);
14409
+ }
14404
14410
  function testAction(client, workflowId, hierarchyPath2, mode) {
14405
14411
  return apiRequest(client, "POST", `/v1/workflows/${workflowId}/outputs/${mode}/actions/${hierarchyPath2}`, {});
14406
14412
  }
@@ -14725,7 +14731,8 @@ function toRow(workflow, workspace) {
14725
14731
  live: workflow.enabledVersion ?? null,
14726
14732
  version: workflow.version,
14727
14733
  draft: workflow.draft,
14728
- updatedAt: workflow.updatedAt ?? null
14734
+ updatedAt: workflow.updatedAt ?? null,
14735
+ triggers: (workflow.triggerSummaries ?? []).map(({ id, type }) => ({ id, type }))
14729
14736
  };
14730
14737
  }
14731
14738
  async function collectWorkflows(client, { workspaceId, applicationId } = {}) {
@@ -14757,16 +14764,23 @@ async function collectWorkflows(client, { workspaceId, applicationId } = {}) {
14757
14764
  }
14758
14765
  return listing;
14759
14766
  }
14760
- var TITLE_WIDTH = 42;
14767
+ var TITLE_WIDTH = 34;
14761
14768
  function workflowTable(rows) {
14762
14769
  const table = new import_cli_table3.default({
14763
- head: ["ID", "Title", "Status", "Version", "Draft"],
14764
- colWidths: [38, TITLE_WIDTH, 14, 9, 7],
14770
+ head: ["ID", "Title", "Triggers", "Status", "Version", "Draft"],
14771
+ colWidths: [38, TITLE_WIDTH, 30, 14, 9, 7],
14765
14772
  wordWrap: true,
14766
14773
  style: { head: [], border: [], "padding-left": 1, "padding-right": 1 }
14767
14774
  });
14768
14775
  for (const row of rows) {
14769
- table.push([row.id, row.title, row.live === null ? "not enabled" : `live v${row.live}`, row.version, row.draft]);
14776
+ table.push([
14777
+ row.id,
14778
+ row.title,
14779
+ row.triggers.map((trigger) => trigger.type).join("\n"),
14780
+ row.live === null ? "not enabled" : `live v${row.live}`,
14781
+ row.version,
14782
+ row.draft
14783
+ ]);
14770
14784
  }
14771
14785
  return table.toString();
14772
14786
  }
@@ -16258,6 +16272,57 @@ ${renderIssues(issues)}` : "every node tested on current data"}`
16258
16272
  });
16259
16273
  }
16260
16274
 
16275
+ // src/commands/pin.ts
16276
+ async function pinTarget(opts) {
16277
+ const applicationId = opts.app ?? process.env["SOFTR_PINNED_APP_ID"];
16278
+ if (!applicationId) {
16279
+ throw new CliError("No application given.", "Pass --app <applicationId> or set SOFTR_PINNED_APP_ID.");
16280
+ }
16281
+ if (opts.id && opts.dir) {
16282
+ throw new CliError("Pass either --id or --dir, not both.");
16283
+ }
16284
+ if (opts.id) {
16285
+ return { applicationId, workflowId: opts.id, client: await authenticatedClient(resolveTarget()) };
16286
+ }
16287
+ const dir = await findWorkflowDir(process.cwd(), opts.dir);
16288
+ const config = await readConfig(dir);
16289
+ if (!config.id) {
16290
+ throw new CliError(
16291
+ 'softr-workflows.jsonc has no "id".',
16292
+ "Pass --id <workflowId>, or pull or init the workflow first."
16293
+ );
16294
+ }
16295
+ const target = resolveTarget(await readState(dir));
16296
+ return { applicationId, workflowId: config.id, client: await authenticatedClient(target) };
16297
+ }
16298
+ function withPinOptions(command) {
16299
+ return command.option("--app <applicationId>", "the application (default: $SOFTR_PINNED_APP_ID)").option("--id <workflowId>", "the workflow (default: the one in the workflow directory)").option("--dir <path>", "workflow directory (default: the current directory)");
16300
+ }
16301
+ function registerPin(program3) {
16302
+ withPinOptions(
16303
+ program3.command("pin").description("Pin the workflow to an application of its workspace; it then lists under that app")
16304
+ ).action(async (opts, command) => {
16305
+ const { applicationId, workflowId, client } = await pinTarget(opts);
16306
+ await pinWorkflow(client, workflowId, applicationId);
16307
+ emit(globalOptions(command), `Pinned workflow ${workflowId} to application ${applicationId}.`, {
16308
+ workflowId,
16309
+ applicationId,
16310
+ pinned: true
16311
+ });
16312
+ });
16313
+ withPinOptions(program3.command("unpin").description("Remove the workflow from an application")).action(
16314
+ async (opts, command) => {
16315
+ const { applicationId, workflowId, client } = await pinTarget(opts);
16316
+ await unpinWorkflow(client, workflowId, applicationId);
16317
+ emit(globalOptions(command), `Unpinned workflow ${workflowId} from application ${applicationId}.`, {
16318
+ workflowId,
16319
+ applicationId,
16320
+ pinned: false
16321
+ });
16322
+ }
16323
+ );
16324
+ }
16325
+
16261
16326
  // src/commands/push.ts
16262
16327
  import path12 from "node:path";
16263
16328
 
@@ -16703,7 +16768,7 @@ Pass --workspace <id> to a command, or set SOFTR_WORKSPACE_ID, to work in one of
16703
16768
  // package.json
16704
16769
  var package_default = {
16705
16770
  name: "@softr/cli",
16706
- version: "0.1.1",
16771
+ version: "0.1.2-se21873.13",
16707
16772
  description: "The Softr command line: build, test and publish Softr workflows from local files; more Softr APIs to come",
16708
16773
  keywords: [
16709
16774
  "softr",
@@ -16770,6 +16835,7 @@ registerAdd(workflows);
16770
16835
  registerEdit(workflows);
16771
16836
  registerUpgrade(workflows);
16772
16837
  registerPublish(workflows);
16838
+ registerPin(workflows);
16773
16839
  registerSpec(workflows);
16774
16840
  registerSchema(workflows);
16775
16841
  program2.parseAsync(process.argv).catch(reportError);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softr/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2-se21873.13",
4
4
  "description": "The Softr command line: build, test and publish Softr workflows from local files; more Softr APIs to come",
5
5
  "keywords": [
6
6
  "softr",