@proteos/sdk 0.18.1

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 (94) hide show
  1. package/LICENSE +40 -0
  2. package/dist/chunk-7RGN4E22.cjs +1185 -0
  3. package/dist/chunk-7RGN4E22.cjs.map +1 -0
  4. package/dist/chunk-XJP5WCRZ.js +1125 -0
  5. package/dist/chunk-XJP5WCRZ.js.map +1 -0
  6. package/dist/index.cjs +2384 -0
  7. package/dist/index.cjs.map +1 -0
  8. package/dist/index.d.cts +5225 -0
  9. package/dist/index.d.ts +5225 -0
  10. package/dist/index.js +2146 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/meta/index.cjs +204 -0
  13. package/dist/meta/index.cjs.map +1 -0
  14. package/dist/meta/index.d.cts +2 -0
  15. package/dist/meta/index.d.ts +2 -0
  16. package/dist/meta/index.js +3 -0
  17. package/dist/meta/index.js.map +1 -0
  18. package/dist/types-BNsjfU8N.d.cts +3299 -0
  19. package/dist/types-BNsjfU8N.d.ts +3299 -0
  20. package/package.json +86 -0
  21. package/src/agent/agents.ts +53 -0
  22. package/src/agent/index.ts +134 -0
  23. package/src/agent/mcp-servers.ts +102 -0
  24. package/src/agent/prompts.ts +80 -0
  25. package/src/agent/session-types.ts +397 -0
  26. package/src/agent/sessions.ts +197 -0
  27. package/src/agent/skills.ts +89 -0
  28. package/src/agent/tools.ts +53 -0
  29. package/src/agent/types.ts +362 -0
  30. package/src/auth/index.ts +111 -0
  31. package/src/auth/me.ts +46 -0
  32. package/src/auth/organizations.ts +128 -0
  33. package/src/auth/platform-entities.ts +78 -0
  34. package/src/auth/roles.ts +213 -0
  35. package/src/auth/types.ts +294 -0
  36. package/src/auth/users.ts +226 -0
  37. package/src/client.ts +441 -0
  38. package/src/connector/index.ts +120 -0
  39. package/src/connector/types.ts +150 -0
  40. package/src/conversation/index.ts +297 -0
  41. package/src/conversation/types.ts +590 -0
  42. package/src/conversation/voice.ts +123 -0
  43. package/src/data/index.ts +53 -0
  44. package/src/data/queries.ts +66 -0
  45. package/src/data/records.ts +122 -0
  46. package/src/data/types.ts +89 -0
  47. package/src/errors.ts +148 -0
  48. package/src/events/index.ts +172 -0
  49. package/src/events/types.ts +77 -0
  50. package/src/functions/actions.ts +95 -0
  51. package/src/functions/index.ts +32 -0
  52. package/src/functions/types.ts +71 -0
  53. package/src/http/index.ts +2 -0
  54. package/src/http/query-params.ts +106 -0
  55. package/src/index.ts +598 -0
  56. package/src/iterator.ts +183 -0
  57. package/src/knowledge/graph.ts +35 -0
  58. package/src/knowledge/index.ts +104 -0
  59. package/src/knowledge/labels.ts +70 -0
  60. package/src/knowledge/links.ts +65 -0
  61. package/src/knowledge/nodes.ts +198 -0
  62. package/src/knowledge/record-links.ts +66 -0
  63. package/src/knowledge/types.ts +569 -0
  64. package/src/meta/apps.ts +107 -0
  65. package/src/meta/components.ts +124 -0
  66. package/src/meta/currency/index.ts +202 -0
  67. package/src/meta/entities.ts +193 -0
  68. package/src/meta/filters.ts +76 -0
  69. package/src/meta/index.ts +227 -0
  70. package/src/meta/layout/common-props.ts +93 -0
  71. package/src/meta/layout/control-registry.json +70 -0
  72. package/src/meta/layout/control-registry.ts +92 -0
  73. package/src/meta/layout/elements.ts +203 -0
  74. package/src/meta/layout/index.ts +41 -0
  75. package/src/meta/layout/page-layout.ts +35 -0
  76. package/src/meta/layout/size-value.ts +27 -0
  77. package/src/meta/list-views.ts +109 -0
  78. package/src/meta/lists.ts +104 -0
  79. package/src/meta/menu-configurations.ts +128 -0
  80. package/src/meta/modules.ts +159 -0
  81. package/src/meta/pages.ts +106 -0
  82. package/src/meta/types.ts +1115 -0
  83. package/src/meta/variables.ts +98 -0
  84. package/src/storage/files.ts +183 -0
  85. package/src/storage/index.ts +33 -0
  86. package/src/storage/types.ts +70 -0
  87. package/src/types/common.ts +143 -0
  88. package/src/types/index.ts +28 -0
  89. package/src/types/options.ts +95 -0
  90. package/src/workflow/executions.ts +99 -0
  91. package/src/workflow/index.ts +109 -0
  92. package/src/workflow/node-types.ts +50 -0
  93. package/src/workflow/types.ts +658 -0
  94. package/src/workflow/workflows.ts +152 -0
@@ -0,0 +1,152 @@
1
+ import type { ProteosClient } from '../client.js'
2
+ import { PageIterator } from '../iterator.js'
3
+ import type { ListOptions, ListResult } from '../types/common.js'
4
+ import type {
5
+ CreateWorkflowRequest,
6
+ ListWorkflowsOptions,
7
+ RunWorkflowRequest,
8
+ TestNodeRequest,
9
+ TestNodeResponse,
10
+ UpdateWorkflowRequest,
11
+ Workflow,
12
+ WorkflowExecution,
13
+ WorkflowVersion,
14
+ WorkflowVersionSummary,
15
+ } from './types.js'
16
+
17
+ const WORKFLOWS_BASE_PATH = '/workflows/v1/workflows'
18
+
19
+ /**
20
+ * Service for managing Workflows — n8n-shaped automation definitions keyed by an
21
+ * immutable kebab-case `key`. Run/pause/unpause drive the Temporal-backed runtime.
22
+ */
23
+ export interface WorkflowService {
24
+ /** Lists workflows, auto-paginating. */
25
+ list(options?: ListWorkflowsOptions): PageIterator<Workflow, ListWorkflowsOptions>
26
+ /** Fetches a single page of workflows with pagination metadata. */
27
+ listPage(options?: ListWorkflowsOptions): Promise<ListResult<Workflow>>
28
+ /** Gets a single workflow by key. @throws {ProteosError} 404 if not found. */
29
+ get(key: string): Promise<Workflow>
30
+ /** Creates a new workflow. @throws {ProteosError} 400/409. */
31
+ create(request: CreateWorkflowRequest): Promise<Workflow>
32
+ /** Fully replaces a workflow's metadata + graph (version bumped server-side). */
33
+ update(key: string, request: UpdateWorkflowRequest): Promise<Workflow>
34
+ /** Deletes a workflow. @throws {ProteosError} 404 if not found. */
35
+ delete(key: string): Promise<void>
36
+ /**
37
+ * Triggers one manual run; returns the pending execution. Pass
38
+ * `destination_node_id` for a partial "run until here" execution (only the
39
+ * destination's ancestors run).
40
+ */
41
+ run(key: string, request?: RunWorkflowRequest): Promise<WorkflowExecution>
42
+ /**
43
+ * Runs ONE node ephemerally against its last-known (or pinned) input and
44
+ * blocks for the result — the editor's "Run this node". No execution rows
45
+ * are written; side effects are real.
46
+ */
47
+ testNode(key: string, nodeId: string, request: TestNodeRequest): Promise<TestNodeResponse>
48
+ /** Pauses scheduled/triggered firings. */
49
+ pause(key: string): Promise<Workflow>
50
+ /** Resumes a paused workflow. */
51
+ unpause(key: string): Promise<Workflow>
52
+ /** Lists a workflow's version history (newest first), auto-paginating. */
53
+ listVersions(
54
+ key: string,
55
+ options?: ListOptions,
56
+ ): PageIterator<WorkflowVersionSummary, ListOptions>
57
+ /** Fetches a single page of a workflow's version history (newest first). */
58
+ listVersionsPage(key: string, options?: ListOptions): Promise<ListResult<WorkflowVersionSummary>>
59
+ /** Gets one immutable version of a workflow, graph included. @throws {ProteosError} 404. */
60
+ getVersion(key: string, version: number): Promise<WorkflowVersion>
61
+ /**
62
+ * Restores an old version by saving its graph as a NEW bumped version;
63
+ * returns the updated workflow (its `.version` is the new current version).
64
+ * @throws {ProteosError} 400 when restoring the current version.
65
+ */
66
+ restoreVersion(key: string, version: number): Promise<Workflow>
67
+ }
68
+
69
+ export class WorkflowServiceImpl implements WorkflowService {
70
+ constructor(private readonly client: ProteosClient) {}
71
+
72
+ list(options: ListWorkflowsOptions = {}): PageIterator<Workflow, ListWorkflowsOptions> {
73
+ return new PageIterator((opts) => this.listPage(opts), options)
74
+ }
75
+
76
+ async listPage(options: ListWorkflowsOptions = {}): Promise<ListResult<Workflow>> {
77
+ return this.client.requestWithQuery<ListResult<Workflow>>('GET', WORKFLOWS_BASE_PATH, options)
78
+ }
79
+
80
+ async get(key: string): Promise<Workflow> {
81
+ return this.client.request<Workflow>('GET', `${WORKFLOWS_BASE_PATH}/${key}`)
82
+ }
83
+
84
+ async create(request: CreateWorkflowRequest): Promise<Workflow> {
85
+ return this.client.request<Workflow>('POST', WORKFLOWS_BASE_PATH, request)
86
+ }
87
+
88
+ async update(key: string, request: UpdateWorkflowRequest): Promise<Workflow> {
89
+ return this.client.request<Workflow>('PATCH', `${WORKFLOWS_BASE_PATH}/${key}`, request)
90
+ }
91
+
92
+ async delete(key: string): Promise<void> {
93
+ await this.client.request<void>('DELETE', `${WORKFLOWS_BASE_PATH}/${key}`)
94
+ }
95
+
96
+ async run(key: string, request: RunWorkflowRequest = {}): Promise<WorkflowExecution> {
97
+ return this.client.request<WorkflowExecution>(
98
+ 'POST',
99
+ `${WORKFLOWS_BASE_PATH}/${key}/run`,
100
+ request,
101
+ )
102
+ }
103
+
104
+ async testNode(key: string, nodeId: string, request: TestNodeRequest): Promise<TestNodeResponse> {
105
+ return this.client.request<TestNodeResponse>(
106
+ 'POST',
107
+ `${WORKFLOWS_BASE_PATH}/${key}/nodes/${nodeId}/test`,
108
+ request,
109
+ )
110
+ }
111
+
112
+ async pause(key: string): Promise<Workflow> {
113
+ return this.client.request<Workflow>('POST', `${WORKFLOWS_BASE_PATH}/${key}/pause`, {})
114
+ }
115
+
116
+ async unpause(key: string): Promise<Workflow> {
117
+ return this.client.request<Workflow>('POST', `${WORKFLOWS_BASE_PATH}/${key}/unpause`, {})
118
+ }
119
+
120
+ listVersions(
121
+ key: string,
122
+ options: ListOptions = {},
123
+ ): PageIterator<WorkflowVersionSummary, ListOptions> {
124
+ return new PageIterator((opts) => this.listVersionsPage(key, opts), options)
125
+ }
126
+
127
+ async listVersionsPage(
128
+ key: string,
129
+ options: ListOptions = {},
130
+ ): Promise<ListResult<WorkflowVersionSummary>> {
131
+ return this.client.requestWithQuery<ListResult<WorkflowVersionSummary>>(
132
+ 'GET',
133
+ `${WORKFLOWS_BASE_PATH}/${key}/versions`,
134
+ options,
135
+ )
136
+ }
137
+
138
+ async getVersion(key: string, version: number): Promise<WorkflowVersion> {
139
+ return this.client.request<WorkflowVersion>(
140
+ 'GET',
141
+ `${WORKFLOWS_BASE_PATH}/${key}/versions/${version}`,
142
+ )
143
+ }
144
+
145
+ async restoreVersion(key: string, version: number): Promise<Workflow> {
146
+ return this.client.request<Workflow>(
147
+ 'POST',
148
+ `${WORKFLOWS_BASE_PATH}/${key}/versions/${version}/restore`,
149
+ {},
150
+ )
151
+ }
152
+ }