@lunnoa/client 2.4.0 → 2.5.0

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/dist/index.d.cts CHANGED
@@ -715,7 +715,7 @@ interface paths {
715
715
  put?: never;
716
716
  /**
717
717
  * Upsert a workflow by slug from a linear step list
718
- * @description Creates or updates a workflow identified by workspace-scoped `slug`. Builds a minimal valid graph (one catalogue trigger, Manually Run when omitted, then linear catalogue-action steps). Marks `managedByCode` by default. Prefer the CLI (`npx @lunnoa/client workflows deploy`) over calling this from application code.
718
+ * @description Creates or updates a workflow identified by workspace-scoped `slug`. Builds a minimal valid graph (one catalogue trigger, Manually Run when omitted, then catalogue-action steps; the last step may branch with `paths`). Marks `managedByCode` by default. Prefer the CLI (`npx @lunnoa/client workflows deploy`) over calling this from application code.
719
719
  */
720
720
  post: operations["WorkflowsController_upsertBySlug"];
721
721
  delete?: never;
@@ -2318,6 +2318,24 @@ interface components {
2318
2318
  name?: string;
2319
2319
  /** @description Step description. */
2320
2320
  description?: string;
2321
+ /** @description Branches after this step. Only on flow-control_action_conditional-paths, flow-control_action_manually-decide-paths, or flow-control_action_request-approval (approved path first, then rejected), and only on the last step of a list. */
2322
+ paths?: components["schemas"]["UpsertWorkflowPathDto"][];
2323
+ };
2324
+ UpsertWorkflowPathConditionDto: {
2325
+ /** @description One step reference, e.g. ={{step:load,amount}}. */
2326
+ field: string;
2327
+ /** @description contains, does_not_contain, equals, does_not_equal, exists, does_not_exist, starts_with, ends_with, is_empty, is_not_empty, comes_before, comes_after, is_in_the_past, is_in_the_future, is_true, is_false, is_truthy, is_falsey, is_greater_than, is_less_than, is_greater_than_or_equal_to, is_less_than_or_equal_to, matches_regex, does_not_match_regex. */
2328
+ condition: string;
2329
+ /** @description Value to compare with. */
2330
+ value?: string;
2331
+ };
2332
+ UpsertWorkflowPathDto: {
2333
+ /** @description Path label, unique on its step. */
2334
+ label: string;
2335
+ /** @description Conditional Paths only. Groups are OR-ed, conditions inside a group AND-ed. Omit to always take this path. */
2336
+ when?: components["schemas"]["UpsertWorkflowPathConditionDto"][][];
2337
+ /** @description Steps on this path. */
2338
+ steps: components["schemas"]["UpsertWorkflowStepDto"][];
2321
2339
  };
2322
2340
  UpsertWorkflowTriggerInputFieldDto: {
2323
2341
  /** @description Field id. Callers pass this key to workflows.execute. */
@@ -2367,7 +2385,7 @@ interface components {
2367
2385
  isActive?: boolean;
2368
2386
  /** @description Catalogue trigger. Omit for a Manually Run trigger with no input fields. */
2369
2387
  trigger?: components["schemas"]["UpsertWorkflowTriggerDto"];
2370
- /** @description Linear catalogue-action steps (v1; no branches). */
2388
+ /** @description Catalogue-action steps in order. The last step may branch with `paths`. */
2371
2389
  steps: components["schemas"]["UpsertWorkflowStepDto"][];
2372
2390
  /** @description Marks the row as managed by code (CLI / SDK). Defaults to true on this endpoint. */
2373
2391
  managedByCode?: boolean;
@@ -6733,6 +6751,32 @@ interface WorkflowStepDefinition {
6733
6751
  /** Per-step input overrides. Values may contain `ref.trigger` / `ref.step`. */
6734
6752
  input?: Record<string, unknown>;
6735
6753
  name?: string;
6754
+ /**
6755
+ * Branches after this step. Only on Conditional Paths, Manually Decide Path,
6756
+ * or Request Approval (approved path first, then rejected), and only on the
6757
+ * last step of a list. Put later steps inside each path.
6758
+ */
6759
+ paths?: WorkflowPathDefinition[];
6760
+ }
6761
+ /** Conditions Conditional Paths evaluates (same list as the builder). */
6762
+ declare const PATH_CONDITIONS: readonly ["contains", "does_not_contain", "equals", "does_not_equal", "exists", "does_not_exist", "starts_with", "ends_with", "is_empty", "is_not_empty", "comes_before", "comes_after", "is_in_the_past", "is_in_the_future", "is_true", "is_false", "is_truthy", "is_falsey", "is_greater_than", "is_less_than", "is_greater_than_or_equal_to", "is_less_than_or_equal_to", "matches_regex", "does_not_match_regex"];
6763
+ type PathConditionType = (typeof PATH_CONDITIONS)[number];
6764
+ interface PathCondition {
6765
+ /** One reference: `ref.trigger(...)` or `ref.step(...)`. */
6766
+ field: string;
6767
+ condition: PathConditionType;
6768
+ /** Compared as text. Omit for exists / is_empty / is_true and similar. */
6769
+ value?: string;
6770
+ }
6771
+ interface WorkflowPathDefinition {
6772
+ /** Unique on its step. On Request Approval use `Approved` / `Rejected`. */
6773
+ label: string;
6774
+ /**
6775
+ * Conditional Paths only. Groups are OR-ed, conditions in a group AND-ed.
6776
+ * Omit to always take this path.
6777
+ */
6778
+ when?: PathCondition[][];
6779
+ steps: WorkflowStepDefinition[];
6736
6780
  }
6737
6781
  interface WorkflowDefinition {
6738
6782
  kind: typeof DEFINE_KINDS.workflow;
@@ -6746,7 +6790,7 @@ interface WorkflowDefinition {
6746
6790
  * `runs.start` ignores this and runs the steps only.
6747
6791
  */
6748
6792
  trigger?: TriggerDefinition;
6749
- /** Linear steps (v1; no branches). */
6793
+ /** Steps in order. The last step may branch with `paths`. */
6750
6794
  steps: WorkflowStepDefinition[];
6751
6795
  }
6752
6796
  type AgentToolDefinition = ActionDefinition | WorkflowDefinition | {
@@ -7545,6 +7589,13 @@ interface UpsertWorkflowStepInput {
7545
7589
  input?: Record<string, unknown>;
7546
7590
  name?: string;
7547
7591
  description?: string;
7592
+ /** Branches after this step (last step of a list only). */
7593
+ paths?: UpsertWorkflowPathInput[];
7594
+ }
7595
+ interface UpsertWorkflowPathInput {
7596
+ label: string;
7597
+ when?: WorkflowPathDefinition['when'];
7598
+ steps: UpsertWorkflowStepInput[];
7548
7599
  }
7549
7600
  interface UpsertWorkflowTriggerInput {
7550
7601
  triggerId: string;
@@ -7792,4 +7843,4 @@ interface CreateServerClientOptions {
7792
7843
  */
7793
7844
  declare function createServerClient(options: CreateServerClientOptions): LunnoaClient;
7794
7845
 
7795
- export { API_KEY_PREFIX, type ActionDefinition, ActionsResource, type AddQueueItemErrorInput, type Agent, AgentChatClient, AgentChatStream, type AgentDefinition, type AgentToolDefinition, AgentsResource, type AiConnection, type AiConnectionDefinition, type AiConnectionModel, AiConnectionsResource, type ApprovalInboxItem, ApprovalsResource, AuthResource, type AuthTokens, type BulkCreateQueueItemsInput, type BulkCreateQueueItemsResult, type ChangeEntityStateInput, type ChangeEntityStateResult, type ChatMode, type Connection, type ConnectionDefinition, ConnectionsResource, type CreateBrowserClientOptions, type CreateEntityInput, type CreateKnowledgeInput, type CreateQueueInput, type CreateQueueItemInput, type CreateServerClientOptions, type CreateTaskInput, type CreateVariableInput, type CurrentUser, DEFINE_KINDS, type DefineKind, type DeletedTask, DiscoveryResource, type EligibleApprover, type EnabledFeatures, EntitiesResource, type Entity, type EntityStateHistoryEntry, type EntityStateTransitions, type EntityType, type EntityTypeDefinition, type EntityTypeReadOptions, EntityTypesResource, type ExecuteWorkflowResult, type Execution, type ExecutionPathStep, type ExecutionProgress, type ExecutionProgressPayload, type ExecutionProgressStep, ExecutionProgressStream, type ExecutionStatus, type ExecutionStreamEvent, type ExecutionStreamEventType, ExecutionTimeoutError, ExecutionsResource, type ExportEntitiesInput, type FetchLike, HttpClient, type ImportEntitiesInput, type ImportEntitiesResult, type ImportTemplate, type Knowledge, type KnowledgeDocument, type KnowledgeDocumentGroup, KnowledgeResource, type ListEntitiesOptions, type ListQueryOptions, type ListQueueItemsByObjectOptions, type ListQueueItemsOptions, type LocalStorageTokenStoreOptions, type LoginRequires2FA, type LoginResult, type LoginSuccess, LunnoaApiError, LunnoaClient, type LunnoaClientOptions, type MessageTaskInput, type OffsetPagination, type PagePagination, type PaginatedEntities, type PendingInput, type PendingInputField, type QueryValue, type Queue, type QueueAllowedObjectType, type QueueItem, type QueueItemCreated, type QueueItemErrorEntry, type QueueItemFull, type QueueItemList, type QueueItemObjectSummary, type QueueItemStats, type QueueItemStatus, QueueItemsResource, type QueueStats, QueuesResource, type RecordMeasureValueInput, type RequestOptions, type RunActionInput, type RunActionOptions, type RunActionResult, RunsResource, type SaveUploadedTextInput, type Scorecard, type ScorecardMeasure, type ScorecardMeasureStatus, type ScorecardMeasureValue, type ScorecardObjective, type ScorecardSummary, ScorecardsResource, type SseEvent, SsoAuthResource, type SsoProviderSummary, type SsoProvidersResponse, type StartRunInput, type StartRunInputDto, type StartRunOptions, type StartRunStep, type StopStreamOptions, type StreamMessageOptions, type Table, TablesResource, type Task, type TaskListItem, TasksResource, type TokenStore, type TriggerDefinition, type TriggerInputFieldDefinition, type UpdateEntityInput, type UpdateKnowledgeInput, type UpdateQueueInput, type UpdateQueueItemInput, type UpdateTaskInput, type UpdateVariableInput, type UpsertAgentBySlugInput, type UpsertAgentBySlugInputDto, type UpsertAgentToolInput, type UpsertEntityTypeBySlugInput, type UpsertTableBySlugInput, type UpsertWorkflowBySlugInput, type UpsertWorkflowBySlugInputDto, type UpsertWorkflowStepInput, type UpsertWorkflowTriggerInput, type Variable, VariablesResource, type WaitUntilFinishedOptions, type WatchProgressOptions, type Workflow, type WorkflowApp, WorkflowAppsResource, type WorkflowDefinition, type WorkflowStepDefinition, WorkflowsResource, assertApiKeyAllowedInEnvironment, type components, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineTrigger, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, type operations, parseSseEvents, parseSseStream, type paths, ref, resolveActionAppId, resolveActionId, resolveTriggerAppId, resolveTriggerId };
7846
+ export { API_KEY_PREFIX, type ActionDefinition, ActionsResource, type AddQueueItemErrorInput, type Agent, AgentChatClient, AgentChatStream, type AgentDefinition, type AgentToolDefinition, AgentsResource, type AiConnection, type AiConnectionDefinition, type AiConnectionModel, AiConnectionsResource, type ApprovalInboxItem, ApprovalsResource, AuthResource, type AuthTokens, type BulkCreateQueueItemsInput, type BulkCreateQueueItemsResult, type ChangeEntityStateInput, type ChangeEntityStateResult, type ChatMode, type Connection, type ConnectionDefinition, ConnectionsResource, type CreateBrowserClientOptions, type CreateEntityInput, type CreateKnowledgeInput, type CreateQueueInput, type CreateQueueItemInput, type CreateServerClientOptions, type CreateTaskInput, type CreateVariableInput, type CurrentUser, DEFINE_KINDS, type DefineKind, type DeletedTask, DiscoveryResource, type EligibleApprover, type EnabledFeatures, EntitiesResource, type Entity, type EntityStateHistoryEntry, type EntityStateTransitions, type EntityType, type EntityTypeDefinition, type EntityTypeReadOptions, EntityTypesResource, type ExecuteWorkflowResult, type Execution, type ExecutionPathStep, type ExecutionProgress, type ExecutionProgressPayload, type ExecutionProgressStep, ExecutionProgressStream, type ExecutionStatus, type ExecutionStreamEvent, type ExecutionStreamEventType, ExecutionTimeoutError, ExecutionsResource, type ExportEntitiesInput, type FetchLike, HttpClient, type ImportEntitiesInput, type ImportEntitiesResult, type ImportTemplate, type Knowledge, type KnowledgeDocument, type KnowledgeDocumentGroup, KnowledgeResource, type ListEntitiesOptions, type ListQueryOptions, type ListQueueItemsByObjectOptions, type ListQueueItemsOptions, type LocalStorageTokenStoreOptions, type LoginRequires2FA, type LoginResult, type LoginSuccess, LunnoaApiError, LunnoaClient, type LunnoaClientOptions, type MessageTaskInput, type OffsetPagination, PATH_CONDITIONS, type PagePagination, type PaginatedEntities, type PathCondition, type PathConditionType, type PendingInput, type PendingInputField, type QueryValue, type Queue, type QueueAllowedObjectType, type QueueItem, type QueueItemCreated, type QueueItemErrorEntry, type QueueItemFull, type QueueItemList, type QueueItemObjectSummary, type QueueItemStats, type QueueItemStatus, QueueItemsResource, type QueueStats, QueuesResource, type RecordMeasureValueInput, type RequestOptions, type RunActionInput, type RunActionOptions, type RunActionResult, RunsResource, type SaveUploadedTextInput, type Scorecard, type ScorecardMeasure, type ScorecardMeasureStatus, type ScorecardMeasureValue, type ScorecardObjective, type ScorecardSummary, ScorecardsResource, type SseEvent, SsoAuthResource, type SsoProviderSummary, type SsoProvidersResponse, type StartRunInput, type StartRunInputDto, type StartRunOptions, type StartRunStep, type StopStreamOptions, type StreamMessageOptions, type Table, TablesResource, type Task, type TaskListItem, TasksResource, type TokenStore, type TriggerDefinition, type TriggerInputFieldDefinition, type UpdateEntityInput, type UpdateKnowledgeInput, type UpdateQueueInput, type UpdateQueueItemInput, type UpdateTaskInput, type UpdateVariableInput, type UpsertAgentBySlugInput, type UpsertAgentBySlugInputDto, type UpsertAgentToolInput, type UpsertEntityTypeBySlugInput, type UpsertTableBySlugInput, type UpsertWorkflowBySlugInput, type UpsertWorkflowBySlugInputDto, type UpsertWorkflowPathInput, type UpsertWorkflowStepInput, type UpsertWorkflowTriggerInput, type Variable, VariablesResource, type WaitUntilFinishedOptions, type WatchProgressOptions, type Workflow, type WorkflowApp, WorkflowAppsResource, type WorkflowDefinition, type WorkflowPathDefinition, type WorkflowStepDefinition, WorkflowsResource, assertApiKeyAllowedInEnvironment, type components, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineTrigger, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, type operations, parseSseEvents, parseSseStream, type paths, ref, resolveActionAppId, resolveActionId, resolveTriggerAppId, resolveTriggerId };
package/dist/index.d.ts CHANGED
@@ -715,7 +715,7 @@ interface paths {
715
715
  put?: never;
716
716
  /**
717
717
  * Upsert a workflow by slug from a linear step list
718
- * @description Creates or updates a workflow identified by workspace-scoped `slug`. Builds a minimal valid graph (one catalogue trigger, Manually Run when omitted, then linear catalogue-action steps). Marks `managedByCode` by default. Prefer the CLI (`npx @lunnoa/client workflows deploy`) over calling this from application code.
718
+ * @description Creates or updates a workflow identified by workspace-scoped `slug`. Builds a minimal valid graph (one catalogue trigger, Manually Run when omitted, then catalogue-action steps; the last step may branch with `paths`). Marks `managedByCode` by default. Prefer the CLI (`npx @lunnoa/client workflows deploy`) over calling this from application code.
719
719
  */
720
720
  post: operations["WorkflowsController_upsertBySlug"];
721
721
  delete?: never;
@@ -2318,6 +2318,24 @@ interface components {
2318
2318
  name?: string;
2319
2319
  /** @description Step description. */
2320
2320
  description?: string;
2321
+ /** @description Branches after this step. Only on flow-control_action_conditional-paths, flow-control_action_manually-decide-paths, or flow-control_action_request-approval (approved path first, then rejected), and only on the last step of a list. */
2322
+ paths?: components["schemas"]["UpsertWorkflowPathDto"][];
2323
+ };
2324
+ UpsertWorkflowPathConditionDto: {
2325
+ /** @description One step reference, e.g. ={{step:load,amount}}. */
2326
+ field: string;
2327
+ /** @description contains, does_not_contain, equals, does_not_equal, exists, does_not_exist, starts_with, ends_with, is_empty, is_not_empty, comes_before, comes_after, is_in_the_past, is_in_the_future, is_true, is_false, is_truthy, is_falsey, is_greater_than, is_less_than, is_greater_than_or_equal_to, is_less_than_or_equal_to, matches_regex, does_not_match_regex. */
2328
+ condition: string;
2329
+ /** @description Value to compare with. */
2330
+ value?: string;
2331
+ };
2332
+ UpsertWorkflowPathDto: {
2333
+ /** @description Path label, unique on its step. */
2334
+ label: string;
2335
+ /** @description Conditional Paths only. Groups are OR-ed, conditions inside a group AND-ed. Omit to always take this path. */
2336
+ when?: components["schemas"]["UpsertWorkflowPathConditionDto"][][];
2337
+ /** @description Steps on this path. */
2338
+ steps: components["schemas"]["UpsertWorkflowStepDto"][];
2321
2339
  };
2322
2340
  UpsertWorkflowTriggerInputFieldDto: {
2323
2341
  /** @description Field id. Callers pass this key to workflows.execute. */
@@ -2367,7 +2385,7 @@ interface components {
2367
2385
  isActive?: boolean;
2368
2386
  /** @description Catalogue trigger. Omit for a Manually Run trigger with no input fields. */
2369
2387
  trigger?: components["schemas"]["UpsertWorkflowTriggerDto"];
2370
- /** @description Linear catalogue-action steps (v1; no branches). */
2388
+ /** @description Catalogue-action steps in order. The last step may branch with `paths`. */
2371
2389
  steps: components["schemas"]["UpsertWorkflowStepDto"][];
2372
2390
  /** @description Marks the row as managed by code (CLI / SDK). Defaults to true on this endpoint. */
2373
2391
  managedByCode?: boolean;
@@ -6733,6 +6751,32 @@ interface WorkflowStepDefinition {
6733
6751
  /** Per-step input overrides. Values may contain `ref.trigger` / `ref.step`. */
6734
6752
  input?: Record<string, unknown>;
6735
6753
  name?: string;
6754
+ /**
6755
+ * Branches after this step. Only on Conditional Paths, Manually Decide Path,
6756
+ * or Request Approval (approved path first, then rejected), and only on the
6757
+ * last step of a list. Put later steps inside each path.
6758
+ */
6759
+ paths?: WorkflowPathDefinition[];
6760
+ }
6761
+ /** Conditions Conditional Paths evaluates (same list as the builder). */
6762
+ declare const PATH_CONDITIONS: readonly ["contains", "does_not_contain", "equals", "does_not_equal", "exists", "does_not_exist", "starts_with", "ends_with", "is_empty", "is_not_empty", "comes_before", "comes_after", "is_in_the_past", "is_in_the_future", "is_true", "is_false", "is_truthy", "is_falsey", "is_greater_than", "is_less_than", "is_greater_than_or_equal_to", "is_less_than_or_equal_to", "matches_regex", "does_not_match_regex"];
6763
+ type PathConditionType = (typeof PATH_CONDITIONS)[number];
6764
+ interface PathCondition {
6765
+ /** One reference: `ref.trigger(...)` or `ref.step(...)`. */
6766
+ field: string;
6767
+ condition: PathConditionType;
6768
+ /** Compared as text. Omit for exists / is_empty / is_true and similar. */
6769
+ value?: string;
6770
+ }
6771
+ interface WorkflowPathDefinition {
6772
+ /** Unique on its step. On Request Approval use `Approved` / `Rejected`. */
6773
+ label: string;
6774
+ /**
6775
+ * Conditional Paths only. Groups are OR-ed, conditions in a group AND-ed.
6776
+ * Omit to always take this path.
6777
+ */
6778
+ when?: PathCondition[][];
6779
+ steps: WorkflowStepDefinition[];
6736
6780
  }
6737
6781
  interface WorkflowDefinition {
6738
6782
  kind: typeof DEFINE_KINDS.workflow;
@@ -6746,7 +6790,7 @@ interface WorkflowDefinition {
6746
6790
  * `runs.start` ignores this and runs the steps only.
6747
6791
  */
6748
6792
  trigger?: TriggerDefinition;
6749
- /** Linear steps (v1; no branches). */
6793
+ /** Steps in order. The last step may branch with `paths`. */
6750
6794
  steps: WorkflowStepDefinition[];
6751
6795
  }
6752
6796
  type AgentToolDefinition = ActionDefinition | WorkflowDefinition | {
@@ -7545,6 +7589,13 @@ interface UpsertWorkflowStepInput {
7545
7589
  input?: Record<string, unknown>;
7546
7590
  name?: string;
7547
7591
  description?: string;
7592
+ /** Branches after this step (last step of a list only). */
7593
+ paths?: UpsertWorkflowPathInput[];
7594
+ }
7595
+ interface UpsertWorkflowPathInput {
7596
+ label: string;
7597
+ when?: WorkflowPathDefinition['when'];
7598
+ steps: UpsertWorkflowStepInput[];
7548
7599
  }
7549
7600
  interface UpsertWorkflowTriggerInput {
7550
7601
  triggerId: string;
@@ -7792,4 +7843,4 @@ interface CreateServerClientOptions {
7792
7843
  */
7793
7844
  declare function createServerClient(options: CreateServerClientOptions): LunnoaClient;
7794
7845
 
7795
- export { API_KEY_PREFIX, type ActionDefinition, ActionsResource, type AddQueueItemErrorInput, type Agent, AgentChatClient, AgentChatStream, type AgentDefinition, type AgentToolDefinition, AgentsResource, type AiConnection, type AiConnectionDefinition, type AiConnectionModel, AiConnectionsResource, type ApprovalInboxItem, ApprovalsResource, AuthResource, type AuthTokens, type BulkCreateQueueItemsInput, type BulkCreateQueueItemsResult, type ChangeEntityStateInput, type ChangeEntityStateResult, type ChatMode, type Connection, type ConnectionDefinition, ConnectionsResource, type CreateBrowserClientOptions, type CreateEntityInput, type CreateKnowledgeInput, type CreateQueueInput, type CreateQueueItemInput, type CreateServerClientOptions, type CreateTaskInput, type CreateVariableInput, type CurrentUser, DEFINE_KINDS, type DefineKind, type DeletedTask, DiscoveryResource, type EligibleApprover, type EnabledFeatures, EntitiesResource, type Entity, type EntityStateHistoryEntry, type EntityStateTransitions, type EntityType, type EntityTypeDefinition, type EntityTypeReadOptions, EntityTypesResource, type ExecuteWorkflowResult, type Execution, type ExecutionPathStep, type ExecutionProgress, type ExecutionProgressPayload, type ExecutionProgressStep, ExecutionProgressStream, type ExecutionStatus, type ExecutionStreamEvent, type ExecutionStreamEventType, ExecutionTimeoutError, ExecutionsResource, type ExportEntitiesInput, type FetchLike, HttpClient, type ImportEntitiesInput, type ImportEntitiesResult, type ImportTemplate, type Knowledge, type KnowledgeDocument, type KnowledgeDocumentGroup, KnowledgeResource, type ListEntitiesOptions, type ListQueryOptions, type ListQueueItemsByObjectOptions, type ListQueueItemsOptions, type LocalStorageTokenStoreOptions, type LoginRequires2FA, type LoginResult, type LoginSuccess, LunnoaApiError, LunnoaClient, type LunnoaClientOptions, type MessageTaskInput, type OffsetPagination, type PagePagination, type PaginatedEntities, type PendingInput, type PendingInputField, type QueryValue, type Queue, type QueueAllowedObjectType, type QueueItem, type QueueItemCreated, type QueueItemErrorEntry, type QueueItemFull, type QueueItemList, type QueueItemObjectSummary, type QueueItemStats, type QueueItemStatus, QueueItemsResource, type QueueStats, QueuesResource, type RecordMeasureValueInput, type RequestOptions, type RunActionInput, type RunActionOptions, type RunActionResult, RunsResource, type SaveUploadedTextInput, type Scorecard, type ScorecardMeasure, type ScorecardMeasureStatus, type ScorecardMeasureValue, type ScorecardObjective, type ScorecardSummary, ScorecardsResource, type SseEvent, SsoAuthResource, type SsoProviderSummary, type SsoProvidersResponse, type StartRunInput, type StartRunInputDto, type StartRunOptions, type StartRunStep, type StopStreamOptions, type StreamMessageOptions, type Table, TablesResource, type Task, type TaskListItem, TasksResource, type TokenStore, type TriggerDefinition, type TriggerInputFieldDefinition, type UpdateEntityInput, type UpdateKnowledgeInput, type UpdateQueueInput, type UpdateQueueItemInput, type UpdateTaskInput, type UpdateVariableInput, type UpsertAgentBySlugInput, type UpsertAgentBySlugInputDto, type UpsertAgentToolInput, type UpsertEntityTypeBySlugInput, type UpsertTableBySlugInput, type UpsertWorkflowBySlugInput, type UpsertWorkflowBySlugInputDto, type UpsertWorkflowStepInput, type UpsertWorkflowTriggerInput, type Variable, VariablesResource, type WaitUntilFinishedOptions, type WatchProgressOptions, type Workflow, type WorkflowApp, WorkflowAppsResource, type WorkflowDefinition, type WorkflowStepDefinition, WorkflowsResource, assertApiKeyAllowedInEnvironment, type components, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineTrigger, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, type operations, parseSseEvents, parseSseStream, type paths, ref, resolveActionAppId, resolveActionId, resolveTriggerAppId, resolveTriggerId };
7846
+ export { API_KEY_PREFIX, type ActionDefinition, ActionsResource, type AddQueueItemErrorInput, type Agent, AgentChatClient, AgentChatStream, type AgentDefinition, type AgentToolDefinition, AgentsResource, type AiConnection, type AiConnectionDefinition, type AiConnectionModel, AiConnectionsResource, type ApprovalInboxItem, ApprovalsResource, AuthResource, type AuthTokens, type BulkCreateQueueItemsInput, type BulkCreateQueueItemsResult, type ChangeEntityStateInput, type ChangeEntityStateResult, type ChatMode, type Connection, type ConnectionDefinition, ConnectionsResource, type CreateBrowserClientOptions, type CreateEntityInput, type CreateKnowledgeInput, type CreateQueueInput, type CreateQueueItemInput, type CreateServerClientOptions, type CreateTaskInput, type CreateVariableInput, type CurrentUser, DEFINE_KINDS, type DefineKind, type DeletedTask, DiscoveryResource, type EligibleApprover, type EnabledFeatures, EntitiesResource, type Entity, type EntityStateHistoryEntry, type EntityStateTransitions, type EntityType, type EntityTypeDefinition, type EntityTypeReadOptions, EntityTypesResource, type ExecuteWorkflowResult, type Execution, type ExecutionPathStep, type ExecutionProgress, type ExecutionProgressPayload, type ExecutionProgressStep, ExecutionProgressStream, type ExecutionStatus, type ExecutionStreamEvent, type ExecutionStreamEventType, ExecutionTimeoutError, ExecutionsResource, type ExportEntitiesInput, type FetchLike, HttpClient, type ImportEntitiesInput, type ImportEntitiesResult, type ImportTemplate, type Knowledge, type KnowledgeDocument, type KnowledgeDocumentGroup, KnowledgeResource, type ListEntitiesOptions, type ListQueryOptions, type ListQueueItemsByObjectOptions, type ListQueueItemsOptions, type LocalStorageTokenStoreOptions, type LoginRequires2FA, type LoginResult, type LoginSuccess, LunnoaApiError, LunnoaClient, type LunnoaClientOptions, type MessageTaskInput, type OffsetPagination, PATH_CONDITIONS, type PagePagination, type PaginatedEntities, type PathCondition, type PathConditionType, type PendingInput, type PendingInputField, type QueryValue, type Queue, type QueueAllowedObjectType, type QueueItem, type QueueItemCreated, type QueueItemErrorEntry, type QueueItemFull, type QueueItemList, type QueueItemObjectSummary, type QueueItemStats, type QueueItemStatus, QueueItemsResource, type QueueStats, QueuesResource, type RecordMeasureValueInput, type RequestOptions, type RunActionInput, type RunActionOptions, type RunActionResult, RunsResource, type SaveUploadedTextInput, type Scorecard, type ScorecardMeasure, type ScorecardMeasureStatus, type ScorecardMeasureValue, type ScorecardObjective, type ScorecardSummary, ScorecardsResource, type SseEvent, SsoAuthResource, type SsoProviderSummary, type SsoProvidersResponse, type StartRunInput, type StartRunInputDto, type StartRunOptions, type StartRunStep, type StopStreamOptions, type StreamMessageOptions, type Table, TablesResource, type Task, type TaskListItem, TasksResource, type TokenStore, type TriggerDefinition, type TriggerInputFieldDefinition, type UpdateEntityInput, type UpdateKnowledgeInput, type UpdateQueueInput, type UpdateQueueItemInput, type UpdateTaskInput, type UpdateVariableInput, type UpsertAgentBySlugInput, type UpsertAgentBySlugInputDto, type UpsertAgentToolInput, type UpsertEntityTypeBySlugInput, type UpsertTableBySlugInput, type UpsertWorkflowBySlugInput, type UpsertWorkflowBySlugInputDto, type UpsertWorkflowPathInput, type UpsertWorkflowStepInput, type UpsertWorkflowTriggerInput, type Variable, VariablesResource, type WaitUntilFinishedOptions, type WatchProgressOptions, type Workflow, type WorkflowApp, WorkflowAppsResource, type WorkflowDefinition, type WorkflowPathDefinition, type WorkflowStepDefinition, WorkflowsResource, assertApiKeyAllowedInEnvironment, type components, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineTrigger, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, type operations, parseSseEvents, parseSseStream, type paths, ref, resolveActionAppId, resolveActionId, resolveTriggerAppId, resolveTriggerId };
package/dist/index.js CHANGED
@@ -540,6 +540,32 @@ var DEFINE_KINDS = {
540
540
  agent: "agent",
541
541
  entityType: "entityType"
542
542
  };
543
+ var PATH_CONDITIONS = [
544
+ "contains",
545
+ "does_not_contain",
546
+ "equals",
547
+ "does_not_equal",
548
+ "exists",
549
+ "does_not_exist",
550
+ "starts_with",
551
+ "ends_with",
552
+ "is_empty",
553
+ "is_not_empty",
554
+ "comes_before",
555
+ "comes_after",
556
+ "is_in_the_past",
557
+ "is_in_the_future",
558
+ "is_true",
559
+ "is_false",
560
+ "is_truthy",
561
+ "is_falsey",
562
+ "is_greater_than",
563
+ "is_less_than",
564
+ "is_greater_than_or_equal_to",
565
+ "is_less_than_or_equal_to",
566
+ "matches_regex",
567
+ "does_not_match_regex"
568
+ ];
543
569
  function defineConnection(config = {}) {
544
570
  return { kind: DEFINE_KINDS.connection, ...config };
545
571
  }
@@ -601,32 +627,44 @@ function collectRefs(value, out) {
601
627
  Object.values(value).forEach((item) => collectRefs(item, out));
602
628
  }
603
629
  }
630
+ var CONDITIONAL_PATHS_ID = "flow-control_action_conditional-paths";
631
+ var APPROVAL_ID = "flow-control_action_request-approval";
632
+ var BRANCHING_ACTION_IDS = /* @__PURE__ */ new Set([
633
+ CONDITIONAL_PATHS_ID,
634
+ "flow-control_action_manually-decide-paths",
635
+ APPROVAL_ID
636
+ ]);
637
+ var PATH_CONDITION_SET = new Set(PATH_CONDITIONS);
638
+ var SINGLE_REF_PATTERN = /^={{step:[^}]*}}$/;
639
+ function collectKeys(steps, seen) {
640
+ for (const step of steps) {
641
+ if (step.key !== void 0) {
642
+ if (!STEP_KEY_PATTERN.test(step.key) || step.key === TRIGGER_KEY) {
643
+ throw new Error(
644
+ `Step key "${step.key}" must start with a letter, use letters, digits, - or _, and not be "${TRIGGER_KEY}".`
645
+ );
646
+ }
647
+ if (seen.has(step.key)) {
648
+ throw new Error(`Step key "${step.key}" is used twice.`);
649
+ }
650
+ seen.add(step.key);
651
+ }
652
+ for (const path of step.paths ?? []) collectKeys(path.steps ?? [], seen);
653
+ }
654
+ }
604
655
  function assertStepRefs(config) {
605
656
  const triggerId = config.trigger?.id.trim() ?? MANUAL_TRIGGER_ID;
606
657
  const triggerFields = triggerId === MANUAL_TRIGGER_ID ? new Set((config.trigger?.inputs ?? []).map((f) => f.id.trim())) : void 0;
607
658
  const allKeys = /* @__PURE__ */ new Set();
608
- for (const step of config.steps) {
609
- if (step.key === void 0) continue;
610
- if (!STEP_KEY_PATTERN.test(step.key) || step.key === TRIGGER_KEY) {
611
- throw new Error(
612
- `Step key "${step.key}" must start with a letter, use letters, digits, - or _, and not be "${TRIGGER_KEY}".`
613
- );
614
- }
615
- if (allKeys.has(step.key)) {
616
- throw new Error(`Step key "${step.key}" is used twice.`);
617
- }
618
- allKeys.add(step.key);
619
- }
620
- const earlier = /* @__PURE__ */ new Set([TRIGGER_KEY]);
621
- config.steps.forEach((step, index) => {
659
+ collectKeys(config.steps, allKeys);
660
+ const checkRefs = (value, earlier, where) => {
622
661
  const refs = [];
623
- collectRefs([step.use?.input, step.input], refs);
624
- const where = `Step "${step.key ?? step.name ?? index + 1}"`;
662
+ collectRefs(value, refs);
625
663
  for (const [key = "", ...path] of refs) {
626
664
  const shown = `={{step:${[key, ...path].join(",")}}}`;
627
665
  if (!earlier.has(key)) {
628
666
  throw new Error(
629
- allKeys.has(key) ? `${where}: ${shown} refers to itself or a later step. Use the trigger or an earlier step.` : `${where}: ${shown} names unknown key "${key}". Use "trigger" or an earlier step's key.`
667
+ allKeys.has(key) ? `${where}: ${shown} refers to itself, a later step, or a step on another path. Use the trigger or an earlier step on the same path.` : `${where}: ${shown} names unknown key "${key}". Use "trigger" or an earlier step's key.`
630
668
  );
631
669
  }
632
670
  if (key === TRIGGER_KEY && triggerFields && !triggerFields.has(path[0] ?? "")) {
@@ -635,8 +673,54 @@ function assertStepRefs(config) {
635
673
  );
636
674
  }
637
675
  }
638
- if (step.key) earlier.add(step.key);
639
- });
676
+ };
677
+ const checkChain = (steps, visible) => {
678
+ const earlier = new Set(visible);
679
+ steps.forEach((step, index) => {
680
+ const where = `Step "${step.key ?? step.name ?? index + 1}"`;
681
+ checkRefs([step.use?.input, step.input], earlier, where);
682
+ if (step.key) earlier.add(step.key);
683
+ if (!step.paths?.length) return;
684
+ const actionId = step.use ? resolveActionId(step.use) : "";
685
+ if (!BRANCHING_ACTION_IDS.has(actionId)) {
686
+ throw new Error(`${where}: paths only work on ${[...BRANCHING_ACTION_IDS].join(", ")}.`);
687
+ }
688
+ if (index !== steps.length - 1) {
689
+ throw new Error(
690
+ `${where}: a step with paths must be the last step in its list. Put later steps inside each path.`
691
+ );
692
+ }
693
+ if (actionId === APPROVAL_ID && step.paths.length > 2) {
694
+ throw new Error(`${where}: Request Approval takes at most two paths (approved, then rejected).`);
695
+ }
696
+ const labels = /* @__PURE__ */ new Set();
697
+ for (const path of step.paths) {
698
+ const label = path?.label?.trim();
699
+ if (!label) throw new Error(`${where}: every path needs a label.`);
700
+ if (labels.has(label)) throw new Error(`${where}: path label "${label}" is used twice.`);
701
+ labels.add(label);
702
+ if (path.when !== void 0 && actionId !== CONDITIONAL_PATHS_ID) {
703
+ throw new Error(`${where}: "when" only works on Conditional Paths.`);
704
+ }
705
+ for (const condition of (path.when ?? []).flat()) {
706
+ if (!SINGLE_REF_PATTERN.test(condition?.field?.trim() ?? "")) {
707
+ throw new Error(
708
+ `${where}, path "${label}": a condition's field must be one ref.trigger(...) or ref.step(...).`
709
+ );
710
+ }
711
+ if (!PATH_CONDITION_SET.has(condition.condition)) {
712
+ throw new Error(
713
+ `${where}, path "${label}": condition "${condition.condition}" is not supported. Use one of: ${PATH_CONDITIONS.join(", ")}.`
714
+ );
715
+ }
716
+ }
717
+ checkRefs(path.when, earlier, `${where}, path "${label}"`);
718
+ if (!path.steps?.length) throw new Error(`${where}: path "${label}" needs at least one step.`);
719
+ checkChain(path.steps, earlier);
720
+ }
721
+ });
722
+ };
723
+ checkChain(config.steps, /* @__PURE__ */ new Set([TRIGGER_KEY]));
640
724
  }
641
725
  function defineWorkflow(config) {
642
726
  if (!config.slug?.trim()) {
@@ -1935,6 +2019,11 @@ function stepFromDefinition(step) {
1935
2019
  ...step.name ? { name: step.name } : {}
1936
2020
  };
1937
2021
  }
2022
+ if (step.paths?.length) {
2023
+ throw new Error(
2024
+ "runs.start runs straight lines only. Deploy workflows with paths, then execute them."
2025
+ );
2026
+ }
1938
2027
  const use = step.use;
1939
2028
  const input = {
1940
2029
  ...use.input ?? {},
@@ -2167,7 +2256,14 @@ function stepToUpsertInput(step) {
2167
2256
  ...step.input ?? {}
2168
2257
  },
2169
2258
  name: step.name ?? use.name,
2170
- description: use.description
2259
+ description: use.description,
2260
+ ...step.paths?.length ? {
2261
+ paths: step.paths.map((path) => ({
2262
+ label: path.label,
2263
+ ...path.when ? { when: path.when } : {},
2264
+ steps: path.steps.map(stepToUpsertInput)
2265
+ }))
2266
+ } : {}
2171
2267
  };
2172
2268
  }
2173
2269
  function workflowDefinitionToUpsert(def) {
@@ -2375,6 +2471,6 @@ function createServerClient(options) {
2375
2471
  });
2376
2472
  }
2377
2473
 
2378
- export { API_KEY_PREFIX, ActionsResource, AgentChatClient, AgentChatStream, AgentsResource, AiConnectionsResource, ApprovalsResource, AuthResource, ConnectionsResource, DEFINE_KINDS, DiscoveryResource, EntitiesResource, EntityTypesResource, ExecutionProgressStream, ExecutionTimeoutError, ExecutionsResource, HttpClient, KnowledgeResource, LunnoaApiError, LunnoaClient, QueueItemsResource, QueuesResource, RunsResource, ScorecardsResource, SsoAuthResource, TablesResource, TasksResource, VariablesResource, WorkflowAppsResource, WorkflowsResource, assertApiKeyAllowedInEnvironment, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineTrigger, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, parseSseEvents, parseSseStream, ref, resolveActionAppId, resolveActionId, resolveTriggerAppId, resolveTriggerId };
2474
+ export { API_KEY_PREFIX, ActionsResource, AgentChatClient, AgentChatStream, AgentsResource, AiConnectionsResource, ApprovalsResource, AuthResource, ConnectionsResource, DEFINE_KINDS, DiscoveryResource, EntitiesResource, EntityTypesResource, ExecutionProgressStream, ExecutionTimeoutError, ExecutionsResource, HttpClient, KnowledgeResource, LunnoaApiError, LunnoaClient, PATH_CONDITIONS, QueueItemsResource, QueuesResource, RunsResource, ScorecardsResource, SsoAuthResource, TablesResource, TasksResource, VariablesResource, WorkflowAppsResource, WorkflowsResource, assertApiKeyAllowedInEnvironment, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineTrigger, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, parseSseEvents, parseSseStream, ref, resolveActionAppId, resolveActionId, resolveTriggerAppId, resolveTriggerId };
2379
2475
  //# sourceMappingURL=index.js.map
2380
2476
  //# sourceMappingURL=index.js.map