@softr/cli 0.1.1-se21216.6 → 0.1.1-se21216.9

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.
Files changed (3) hide show
  1. package/README.md +3 -3
  2. package/dist/cli.mjs +64 -58
  3. 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>]` | List the workflows you can access, one table per workspace. 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; `--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>]` | Create a workflow on the server with one trigger (default `WEBHOOK`) and the local directory for it. |
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: the app lists it, and the app's members may view it. |
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,64 @@ 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(async (title, opts, command) => {
15272
- const options = globalOptions(command);
15273
- const cwd = process.cwd();
15274
- const dir = path10.resolve(cwd, opts.dir ?? slug(title));
15275
- if (await configExists(dir)) {
15276
- throw new CliError(`${path10.join(dir, CONFIG_FILE_NAME)} already exists.`, "Pick another --dir or title.");
15277
- }
15278
- const trigger = findCatalogEntry(opts.trigger, "trigger");
15279
- const target = resolveTarget();
15280
- const client = await authenticatedClient(target);
15281
- const workspaceId = await resolveWorkspace(client, opts.workspace ?? process.env["SOFTR_WORKSPACE_ID"]);
15282
- const created = await createWorkflow(client, {
15283
- workspaceId,
15284
- applicationId: null,
15285
- title,
15286
- thumbnail: null,
15287
- triggers: [{ id: TRIGGER_ID, type: trigger.type, version: trigger.version, inputs: trigger.template }],
15288
- actions: [],
15289
- paths: [],
15290
- // Like the studio: the author's time zone, so schedules and waits mean what they read.
15291
- configuration: { timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC" }
15292
- });
15293
- const workflow = await getWorkflow(client, created.id);
15294
- const config = { $schema: SCHEMA_POINTER, ...toLocalConfig(workflow) };
15295
- const configFile = await writeConfig(dir, config);
15296
- await writeSchemaFile(dir);
15297
- const syncedHash = definitionHash((await packWorkflow(config, dir)).packed);
15298
- await writeState(dir, {
15299
- ...target,
15300
- workflowId: created.id,
15301
- version: workflow.version,
15302
- draft: workflow.draft,
15303
- syncedHash
15304
- });
15305
- const studioUrl = `${target.studioUrl}/workflow/${created.id}`;
15306
- emit(
15307
- options,
15308
- `Created "${title}" (${created.id}) with a ${trigger.type} trigger "${TRIGGER_ID}" in workspace ${workspaceId}.
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
+ // Both halves of a link: the workflow belongs to the app (its members may view it), and the app lists it.
15287
+ applicationId,
15288
+ ...applicationId ? { pinToApplicationId: applicationId } : {},
15289
+ title,
15290
+ thumbnail: null,
15291
+ triggers: [{ id: TRIGGER_ID, type: trigger.type, version: trigger.version, inputs: trigger.template }],
15292
+ actions: [],
15293
+ paths: [],
15294
+ // Like the studio: the author's time zone, so schedules and waits mean what they read.
15295
+ configuration: { timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC" }
15296
+ });
15297
+ const workflow = await getWorkflow(client, created.id);
15298
+ const config = { $schema: SCHEMA_POINTER, ...toLocalConfig(workflow) };
15299
+ const configFile = await writeConfig(dir, config);
15300
+ await writeSchemaFile(dir);
15301
+ const syncedHash = definitionHash((await packWorkflow(config, dir)).packed);
15302
+ await writeState(dir, {
15303
+ ...target,
15304
+ workflowId: created.id,
15305
+ version: workflow.version,
15306
+ draft: workflow.draft,
15307
+ syncedHash
15308
+ });
15309
+ const studioUrl = `${target.studioUrl}/workflow/${created.id}`;
15310
+ emit(
15311
+ options,
15312
+ `Created "${title}" (${created.id}) with a ${trigger.type} trigger "${TRIGGER_ID}" in workspace ${workspaceId}${applicationId ? `, linked to application ${applicationId}` : ""}.
15309
15313
  ${path10.relative(cwd, configFile)}
15310
15314
  ${studioUrl}
15311
15315
  Next: softr workflows add <TYPE> --dir ${path10.relative(cwd, dir) || "."} (see "spec" for the types), then push and test.`,
15312
- {
15313
- workflowId: created.id,
15314
- workspaceId,
15315
- title,
15316
- triggerId: TRIGGER_ID,
15317
- triggerType: trigger.type,
15318
- dir,
15319
- studioUrl
15320
- }
15321
- );
15322
- });
15316
+ {
15317
+ workflowId: created.id,
15318
+ workspaceId,
15319
+ applicationId,
15320
+ title,
15321
+ triggerId: TRIGGER_ID,
15322
+ triggerType: trigger.type,
15323
+ dir,
15324
+ studioUrl
15325
+ }
15326
+ );
15327
+ }
15328
+ );
15323
15329
  }
15324
15330
 
15325
15331
  // src/commands/integrations.ts
@@ -16690,7 +16696,7 @@ Pass --workspace <id> to a command, or set SOFTR_WORKSPACE_ID, to work in one of
16690
16696
  // package.json
16691
16697
  var package_default = {
16692
16698
  name: "@softr/cli",
16693
- version: "0.1.1-se21216.6",
16699
+ version: "0.1.1-se21216.9",
16694
16700
  description: "The Softr command line: build, test and publish Softr workflows from local files; more Softr APIs to come",
16695
16701
  keywords: [
16696
16702
  "softr",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softr/cli",
3
- "version": "0.1.1-se21216.6",
3
+ "version": "0.1.1-se21216.9",
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",