0pflow 0.1.0-dev.b4bf1ab → 0.1.0-dev.bdfaa95

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 (254) hide show
  1. package/dist/__tests__/discover.integration.test.d.ts +2 -0
  2. package/dist/__tests__/discover.integration.test.d.ts.map +1 -0
  3. package/dist/__tests__/discover.integration.test.js +137 -0
  4. package/dist/__tests__/discover.integration.test.js.map +1 -0
  5. package/dist/__tests__/factory.test.js +13 -0
  6. package/dist/__tests__/factory.test.js.map +1 -1
  7. package/dist/__tests__/integration.e2e.test.js +2 -1
  8. package/dist/__tests__/integration.e2e.test.js.map +1 -1
  9. package/dist/__tests__/integration.test.js +87 -82
  10. package/dist/__tests__/integration.test.js.map +1 -1
  11. package/dist/agent.d.ts +7 -0
  12. package/dist/agent.d.ts.map +1 -1
  13. package/dist/agent.js +75 -10
  14. package/dist/agent.js.map +1 -1
  15. package/dist/cli/__tests__/discovery.test.js +1 -1
  16. package/dist/cli/__tests__/discovery.test.js.map +1 -1
  17. package/dist/cli/app.d.ts +6 -0
  18. package/dist/cli/app.d.ts.map +1 -1
  19. package/dist/cli/app.js +27 -0
  20. package/dist/cli/app.js.map +1 -1
  21. package/dist/cli/deploy.d.ts +27 -0
  22. package/dist/cli/deploy.d.ts.map +1 -0
  23. package/dist/cli/deploy.js +332 -0
  24. package/dist/cli/deploy.js.map +1 -0
  25. package/dist/cli/discovery.d.ts +10 -0
  26. package/dist/cli/discovery.d.ts.map +1 -1
  27. package/dist/cli/discovery.js +42 -0
  28. package/dist/cli/discovery.js.map +1 -1
  29. package/dist/cli/env.js +1 -1
  30. package/dist/cli/env.js.map +1 -1
  31. package/dist/cli/index.d.ts.map +1 -1
  32. package/dist/cli/index.js +142 -11
  33. package/dist/cli/index.js.map +1 -1
  34. package/dist/cli/install.d.ts +4 -0
  35. package/dist/cli/install.d.ts.map +1 -1
  36. package/dist/cli/install.js +63 -32
  37. package/dist/cli/install.js.map +1 -1
  38. package/dist/cli/mcp/config.d.ts +0 -1
  39. package/dist/cli/mcp/config.d.ts.map +1 -1
  40. package/dist/cli/mcp/config.js +2 -4
  41. package/dist/cli/mcp/config.js.map +1 -1
  42. package/dist/cli/mcp/lib/scaffolding.d.ts +33 -0
  43. package/dist/cli/mcp/lib/scaffolding.d.ts.map +1 -0
  44. package/dist/cli/mcp/lib/scaffolding.js +231 -0
  45. package/dist/cli/mcp/lib/scaffolding.js.map +1 -0
  46. package/dist/cli/mcp/lib/templates.d.ts +1 -0
  47. package/dist/cli/mcp/lib/templates.d.ts.map +1 -1
  48. package/dist/cli/mcp/lib/templates.js.map +1 -1
  49. package/dist/cli/mcp/tools/createApp.d.ts +1 -0
  50. package/dist/cli/mcp/tools/createApp.d.ts.map +1 -1
  51. package/dist/cli/mcp/tools/createApp.js +12 -55
  52. package/dist/cli/mcp/tools/createApp.js.map +1 -1
  53. package/dist/cli/mcp/tools/createDatabase.d.ts.map +1 -1
  54. package/dist/cli/mcp/tools/createDatabase.js +2 -41
  55. package/dist/cli/mcp/tools/createDatabase.js.map +1 -1
  56. package/dist/cli/mcp/tools/getConnectionInfo.d.ts +19 -0
  57. package/dist/cli/mcp/tools/getConnectionInfo.d.ts.map +1 -0
  58. package/dist/cli/mcp/tools/getConnectionInfo.js +111 -0
  59. package/dist/cli/mcp/tools/getConnectionInfo.js.map +1 -0
  60. package/dist/cli/mcp/tools/getRun.d.ts +22 -0
  61. package/dist/cli/mcp/tools/getRun.d.ts.map +1 -0
  62. package/dist/cli/mcp/tools/getRun.js +80 -0
  63. package/dist/cli/mcp/tools/getRun.js.map +1 -0
  64. package/dist/cli/mcp/tools/getTrace.d.ts +32 -0
  65. package/dist/cli/mcp/tools/getTrace.d.ts.map +1 -0
  66. package/dist/cli/mcp/tools/getTrace.js +104 -0
  67. package/dist/cli/mcp/tools/getTrace.js.map +1 -0
  68. package/dist/cli/mcp/tools/index.d.ts +94 -1
  69. package/dist/cli/mcp/tools/index.d.ts.map +1 -1
  70. package/dist/cli/mcp/tools/index.js +16 -0
  71. package/dist/cli/mcp/tools/index.js.map +1 -1
  72. package/dist/cli/mcp/tools/listIntegrations.d.ts +14 -0
  73. package/dist/cli/mcp/tools/listIntegrations.d.ts.map +1 -0
  74. package/dist/cli/mcp/tools/listIntegrations.js +53 -0
  75. package/dist/cli/mcp/tools/listIntegrations.js.map +1 -0
  76. package/dist/cli/mcp/tools/listRuns.d.ts +21 -0
  77. package/dist/cli/mcp/tools/listRuns.d.ts.map +1 -0
  78. package/dist/cli/mcp/tools/listRuns.js +72 -0
  79. package/dist/cli/mcp/tools/listRuns.js.map +1 -0
  80. package/dist/cli/mcp/tools/listWorkflows.d.ts +15 -0
  81. package/dist/cli/mcp/tools/listWorkflows.d.ts.map +1 -0
  82. package/dist/cli/mcp/tools/listWorkflows.js +45 -0
  83. package/dist/cli/mcp/tools/listWorkflows.js.map +1 -0
  84. package/dist/cli/mcp/tools/runNode.d.ts +17 -0
  85. package/dist/cli/mcp/tools/runNode.d.ts.map +1 -0
  86. package/dist/cli/mcp/tools/runNode.js +74 -0
  87. package/dist/cli/mcp/tools/runNode.js.map +1 -0
  88. package/dist/cli/mcp/tools/runWorkflow.d.ts +16 -0
  89. package/dist/cli/mcp/tools/runWorkflow.d.ts.map +1 -0
  90. package/dist/cli/mcp/tools/runWorkflow.js +66 -0
  91. package/dist/cli/mcp/tools/runWorkflow.js.map +1 -0
  92. package/dist/cli/mcp/tools/setupAppSchema.d.ts +1 -1
  93. package/dist/cli/mcp/tools/setupAppSchema.d.ts.map +1 -1
  94. package/dist/cli/mcp/tools/setupAppSchema.js +11 -129
  95. package/dist/cli/mcp/tools/setupAppSchema.js.map +1 -1
  96. package/dist/cli/mcp/tools/utils.d.ts +7 -0
  97. package/dist/cli/mcp/tools/utils.d.ts.map +1 -0
  98. package/dist/cli/mcp/tools/utils.js +28 -0
  99. package/dist/cli/mcp/tools/utils.js.map +1 -0
  100. package/dist/cli/run.d.ts +2 -0
  101. package/dist/cli/run.d.ts.map +1 -0
  102. package/dist/cli/run.js +560 -0
  103. package/dist/cli/run.js.map +1 -0
  104. package/dist/cli/trace.d.ts +5 -0
  105. package/dist/cli/trace.d.ts.map +1 -1
  106. package/dist/cli/trace.js +1 -1
  107. package/dist/cli/trace.js.map +1 -1
  108. package/dist/connections/cloud-auth.d.ts +46 -0
  109. package/dist/connections/cloud-auth.d.ts.map +1 -0
  110. package/dist/connections/cloud-auth.js +247 -0
  111. package/dist/connections/cloud-auth.js.map +1 -0
  112. package/dist/connections/cloud-client.d.ts +25 -0
  113. package/dist/connections/cloud-client.d.ts.map +1 -0
  114. package/dist/connections/cloud-client.js +59 -0
  115. package/dist/connections/cloud-client.js.map +1 -0
  116. package/dist/connections/cloud-integration-provider.d.ts +22 -0
  117. package/dist/connections/cloud-integration-provider.d.ts.map +1 -0
  118. package/dist/connections/cloud-integration-provider.js +41 -0
  119. package/dist/connections/cloud-integration-provider.js.map +1 -0
  120. package/dist/connections/connection-labels.d.ts +14 -0
  121. package/dist/connections/connection-labels.d.ts.map +1 -0
  122. package/dist/connections/connection-labels.js +46 -0
  123. package/dist/connections/connection-labels.js.map +1 -0
  124. package/dist/connections/index.d.ts +12 -0
  125. package/dist/connections/index.d.ts.map +1 -0
  126. package/dist/connections/index.js +10 -0
  127. package/dist/connections/index.js.map +1 -0
  128. package/dist/connections/integration-provider.d.ts +39 -0
  129. package/dist/connections/integration-provider.d.ts.map +1 -0
  130. package/dist/connections/integration-provider.js +20 -0
  131. package/dist/connections/integration-provider.js.map +1 -0
  132. package/dist/connections/local-integration-provider.d.ts +29 -0
  133. package/dist/connections/local-integration-provider.d.ts.map +1 -0
  134. package/dist/connections/local-integration-provider.js +70 -0
  135. package/dist/connections/local-integration-provider.js.map +1 -0
  136. package/dist/connections/nango-client.d.ts +14 -0
  137. package/dist/connections/nango-client.d.ts.map +1 -0
  138. package/dist/connections/nango-client.js +50 -0
  139. package/dist/connections/nango-client.js.map +1 -0
  140. package/dist/connections/resolver.d.ts +26 -0
  141. package/dist/connections/resolver.d.ts.map +1 -0
  142. package/dist/connections/resolver.js +48 -0
  143. package/dist/connections/resolver.js.map +1 -0
  144. package/dist/connections/schema.d.ts +8 -0
  145. package/dist/connections/schema.d.ts.map +1 -0
  146. package/dist/connections/schema.js +31 -0
  147. package/dist/connections/schema.js.map +1 -0
  148. package/dist/context.d.ts.map +1 -1
  149. package/dist/context.js +4 -0
  150. package/dist/context.js.map +1 -1
  151. package/dist/dev-ui/api.d.ts +18 -0
  152. package/dist/dev-ui/api.d.ts.map +1 -0
  153. package/dist/dev-ui/api.js +273 -0
  154. package/dist/dev-ui/api.js.map +1 -0
  155. package/dist/dev-ui/dag/extractor.d.ts +19 -0
  156. package/dist/dev-ui/dag/extractor.d.ts.map +1 -0
  157. package/dist/dev-ui/dag/extractor.js +716 -0
  158. package/dist/dev-ui/dag/extractor.js.map +1 -0
  159. package/dist/dev-ui/dag/types.d.ts +42 -0
  160. package/dist/dev-ui/dag/types.d.ts.map +1 -0
  161. package/dist/dev-ui/dag/types.js +2 -0
  162. package/dist/dev-ui/dag/types.js.map +1 -0
  163. package/dist/dev-ui/deploy-api.d.ts +14 -0
  164. package/dist/dev-ui/deploy-api.d.ts.map +1 -0
  165. package/dist/dev-ui/deploy-api.js +112 -0
  166. package/dist/dev-ui/deploy-api.js.map +1 -0
  167. package/dist/dev-ui/dev-server.d.ts +18 -0
  168. package/dist/dev-ui/dev-server.d.ts.map +1 -0
  169. package/dist/dev-ui/dev-server.js +273 -0
  170. package/dist/dev-ui/dev-server.js.map +1 -0
  171. package/dist/dev-ui/index.d.ts +3 -0
  172. package/dist/dev-ui/index.d.ts.map +1 -0
  173. package/dist/dev-ui/index.js +2 -0
  174. package/dist/dev-ui/index.js.map +1 -0
  175. package/dist/dev-ui/pty.d.ts +16 -0
  176. package/dist/dev-ui/pty.d.ts.map +1 -0
  177. package/dist/dev-ui/pty.js +87 -0
  178. package/dist/dev-ui/pty.js.map +1 -0
  179. package/dist/dev-ui/watcher.d.ts +12 -0
  180. package/dist/dev-ui/watcher.d.ts.map +1 -0
  181. package/dist/dev-ui/watcher.js +166 -0
  182. package/dist/dev-ui/watcher.js.map +1 -0
  183. package/dist/dev-ui/ws.d.ts +52 -0
  184. package/dist/dev-ui/ws.d.ts.map +1 -0
  185. package/dist/dev-ui/ws.js +32 -0
  186. package/dist/dev-ui/ws.js.map +1 -0
  187. package/dist/dev-ui-client/assets/index-CFhxfKAk.js +176 -0
  188. package/dist/dev-ui-client/assets/index-D9wFwfPp.css +32 -0
  189. package/dist/dev-ui-client/assets/index-DAKTQEvj.js +1 -0
  190. package/dist/dev-ui-client/index.html +13 -0
  191. package/dist/discover.d.ts +15 -0
  192. package/dist/discover.d.ts.map +1 -0
  193. package/dist/discover.js +32 -0
  194. package/dist/discover.js.map +1 -0
  195. package/dist/factory.d.ts.map +1 -1
  196. package/dist/factory.js +37 -13
  197. package/dist/factory.js.map +1 -1
  198. package/dist/index.d.ts +6 -1
  199. package/dist/index.d.ts.map +1 -1
  200. package/dist/index.js +6 -0
  201. package/dist/index.js.map +1 -1
  202. package/dist/node.d.ts +1 -0
  203. package/dist/node.d.ts.map +1 -1
  204. package/dist/node.js +1 -0
  205. package/dist/node.js.map +1 -1
  206. package/dist/nodes/agent/executor.d.ts +2 -0
  207. package/dist/nodes/agent/executor.d.ts.map +1 -1
  208. package/dist/nodes/agent/executor.js +11 -1
  209. package/dist/nodes/agent/executor.js.map +1 -1
  210. package/dist/registry-gen.d.ts +6 -0
  211. package/dist/registry-gen.d.ts.map +1 -0
  212. package/dist/registry-gen.js +146 -0
  213. package/dist/registry-gen.js.map +1 -0
  214. package/dist/types.d.ts +21 -3
  215. package/dist/types.d.ts.map +1 -1
  216. package/dist/workflow.d.ts +22 -0
  217. package/dist/workflow.d.ts.map +1 -1
  218. package/dist/workflow.js +113 -3
  219. package/dist/workflow.js.map +1 -1
  220. package/package.json +30 -6
  221. package/templates/app/.dockerignore +6 -0
  222. package/templates/app/.env.example +13 -0
  223. package/templates/app/Dockerfile +34 -0
  224. package/templates/app/README.md +29 -0
  225. package/templates/app/biome.jsonc +81 -0
  226. package/templates/app/dbos-config.yaml +6 -0
  227. package/templates/app/drizzle.config.ts +12 -0
  228. package/templates/app/generated/registry.ts +8 -0
  229. package/templates/app/next.config.js +13 -0
  230. package/templates/app/package.json +57 -0
  231. package/templates/app/postcss.config.js +5 -0
  232. package/templates/app/public/favicon.ico +0 -0
  233. package/templates/app/src/app/_components/.gitkeep +0 -0
  234. package/templates/app/src/app/api/trpc/[trpc]/route.ts +34 -0
  235. package/templates/app/src/app/api/workflow/[name]/route.ts +37 -0
  236. package/templates/app/src/app/layout.tsx +29 -0
  237. package/templates/app/src/app/page.tsx +18 -0
  238. package/templates/app/src/env.js +46 -0
  239. package/templates/app/src/instrumentation.ts +6 -0
  240. package/templates/app/src/lib/pflow.ts +28 -0
  241. package/templates/app/src/server/api/root.ts +21 -0
  242. package/templates/app/src/server/api/routers/.gitkeep +0 -0
  243. package/templates/app/src/server/api/trpc.ts +106 -0
  244. package/templates/app/src/server/db/index.ts +18 -0
  245. package/templates/app/src/server/db/schema.ts +14 -0
  246. package/templates/app/src/styles/globals.css +6 -0
  247. package/templates/app/src/styles/globals.css.orange +126 -0
  248. package/templates/app/src/trpc/query-client.ts +25 -0
  249. package/templates/app/src/trpc/react.tsx +78 -0
  250. package/templates/app/src/trpc/server.ts +30 -0
  251. package/templates/app/tsconfig.check.json +23 -0
  252. package/templates/app/tsconfig.json +42 -0
  253. package/templates/app/tsconfig.server.json +5 -0
  254. package/templates/app/tsconfig.test.json +21 -0
@@ -0,0 +1,29 @@
1
+ import type { IntegrationProvider } from "./integration-provider.js";
2
+ import type { ConnectionCredentials } from "../types.js";
3
+ /**
4
+ * IntegrationProvider backed by a direct Nango connection (self-hosted mode).
5
+ * Requires NANGO_SECRET_KEY.
6
+ */
7
+ export declare class LocalIntegrationProvider implements IntegrationProvider {
8
+ private nango;
9
+ constructor(nangoInstance: any);
10
+ fetchCredentials(integrationId: string, connectionId: string): Promise<ConnectionCredentials>;
11
+ listIntegrations(): Promise<Array<{
12
+ id: string;
13
+ provider: string;
14
+ }>>;
15
+ listConnections(integrationId: string): Promise<Array<{
16
+ connection_id: string;
17
+ provider_config_key: string;
18
+ display_name: string;
19
+ }>>;
20
+ createConnectSession(integrationId: string, endUserId?: string): Promise<{
21
+ token: string;
22
+ }>;
23
+ }
24
+ /**
25
+ * Create a LocalIntegrationProvider from a Nango secret key.
26
+ * Uses dynamic import to avoid hard dependency on @nangohq/node.
27
+ */
28
+ export declare function createLocalIntegrationProvider(secretKey: string): Promise<LocalIntegrationProvider>;
29
+ //# sourceMappingURL=local-integration-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-integration-provider.d.ts","sourceRoot":"","sources":["../../src/connections/local-integration-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,mBAAmB;IAElE,OAAO,CAAC,KAAK,CAAM;gBAGP,aAAa,EAAE,GAAG;IAIxB,gBAAgB,CACpB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,qBAAqB,CAAC;IAkB3B,gBAAgB,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAUpE,eAAe,CACnB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,KAAK,CAAC;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,mBAAmB,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAwBzF,oBAAoB,CACxB,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAO9B;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,wBAAwB,CAAC,CAInC"}
@@ -0,0 +1,70 @@
1
+ import { getConnectionDisplayName } from "./connection-labels.js";
2
+ /**
3
+ * IntegrationProvider backed by a direct Nango connection (self-hosted mode).
4
+ * Requires NANGO_SECRET_KEY.
5
+ */
6
+ export class LocalIntegrationProvider {
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ nango;
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ constructor(nangoInstance) {
11
+ this.nango = nangoInstance;
12
+ }
13
+ async fetchCredentials(integrationId, connectionId) {
14
+ const connection = await this.nango.getConnection(integrationId, connectionId);
15
+ const creds = connection.credentials ?? {};
16
+ const token = creds.access_token ??
17
+ creds.api_key ??
18
+ creds.apiKey ??
19
+ creds.token ??
20
+ "";
21
+ return {
22
+ token,
23
+ connectionConfig: connection.connection_config ?? {},
24
+ raw: creds,
25
+ };
26
+ }
27
+ async listIntegrations() {
28
+ const result = await this.nango.listIntegrations();
29
+ return (result.configs ?? []).map((c) => ({
30
+ id: c.unique_key,
31
+ provider: c.provider,
32
+ }));
33
+ }
34
+ async listConnections(integrationId) {
35
+ const result = await this.nango.listConnections();
36
+ const filtered = (result.connections ?? []).filter((c) => c.provider_config_key === integrationId);
37
+ return Promise.all(filtered.map(async (c) => {
38
+ let displayName = c.connection_id;
39
+ try {
40
+ const conn = await this.nango.getConnection(integrationId, c.connection_id);
41
+ displayName = await getConnectionDisplayName(integrationId, c.connection_id, conn.credentials);
42
+ }
43
+ catch {
44
+ // Fall back to connection_id if fetch fails
45
+ }
46
+ return {
47
+ connection_id: c.connection_id,
48
+ provider_config_key: c.provider_config_key,
49
+ display_name: displayName,
50
+ };
51
+ }));
52
+ }
53
+ async createConnectSession(integrationId, endUserId) {
54
+ const session = await this.nango.createConnectSession({
55
+ end_user: { id: endUserId ?? "dev-ui-user" },
56
+ allowed_integrations: [integrationId],
57
+ });
58
+ return { token: session.data.token };
59
+ }
60
+ }
61
+ /**
62
+ * Create a LocalIntegrationProvider from a Nango secret key.
63
+ * Uses dynamic import to avoid hard dependency on @nangohq/node.
64
+ */
65
+ export async function createLocalIntegrationProvider(secretKey) {
66
+ const { Nango } = await import("@nangohq/node");
67
+ const nango = new Nango({ secretKey });
68
+ return new LocalIntegrationProvider(nango);
69
+ }
70
+ //# sourceMappingURL=local-integration-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-integration-provider.js","sourceRoot":"","sources":["../../src/connections/local-integration-provider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAElE;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IACnC,8DAA8D;IACtD,KAAK,CAAM;IAEnB,8DAA8D;IAC9D,YAAY,aAAkB;QAC5B,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,aAAqB,EACrB,YAAoB;QAEpB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;QAE/E,MAAM,KAAK,GAAG,UAAU,CAAC,WAAW,IAAI,EAAE,CAAC;QAC3C,MAAM,KAAK,GACT,KAAK,CAAC,YAAY;YAClB,KAAK,CAAC,OAAO;YACb,KAAK,CAAC,MAAM;YACZ,KAAK,CAAC,KAAK;YACX,EAAE,CAAC;QAEL,OAAO;YACL,KAAK;YACL,gBAAgB,EAAE,UAAU,CAAC,iBAAiB,IAAI,EAAE;YACpD,GAAG,EAAE,KAAK;SACX,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,C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EAAE,EAAE,EAAE,EAAE,SAAS,IAAI,aAAa,EAAE;YAC5C,oBAAoB,EAAE,CAAC,aAAa,CAAC;SACtC,CAAC,CAAC;QACH,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,SAAiB;IAEjB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IACvC,OAAO,IAAI,wBAAwB,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { ConnectionCredentials } from "../types.js";
2
+ /**
3
+ * Initialize the Nango client singleton.
4
+ */
5
+ export declare function initNango(secretKey: string): Promise<void>;
6
+ /**
7
+ * Get the Nango client instance, or null if not initialized.
8
+ */
9
+ export declare function getNango(): any | null;
10
+ /**
11
+ * Fetch credentials for an integration connection from Nango.
12
+ */
13
+ export declare function fetchCredentials(integrationId: string, connectionId: string): Promise<ConnectionCredentials>;
14
+ //# sourceMappingURL=nango-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nango-client.d.ts","sourceRoot":"","sources":["../../src/connections/nango-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAkBzD;;GAEG;AACH,wBAAsB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhE;AAED;;GAEG;AAEH,wBAAgB,QAAQ,IAAI,GAAG,GAAG,IAAI,CAErC;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,qBAAqB,CAAC,CAwBhC"}
@@ -0,0 +1,50 @@
1
+ // Use dynamic import to avoid hard dependency when Nango isn't configured.
2
+ // Stored on globalThis so it's shared across module instances (jiti vs compiled).
3
+ const NANGO_KEY = Symbol.for("opflow.nangoInstance");
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ function getNangoInstance() {
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ return globalThis[NANGO_KEY] ?? null;
8
+ }
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ function setNangoInstance(instance) {
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ globalThis[NANGO_KEY] = instance;
13
+ }
14
+ /**
15
+ * Initialize the Nango client singleton.
16
+ */
17
+ export async function initNango(secretKey) {
18
+ const { Nango } = await import("@nangohq/node");
19
+ setNangoInstance(new Nango({ secretKey }));
20
+ }
21
+ /**
22
+ * Get the Nango client instance, or null if not initialized.
23
+ */
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+ export function getNango() {
26
+ return getNangoInstance();
27
+ }
28
+ /**
29
+ * Fetch credentials for an integration connection from Nango.
30
+ */
31
+ export async function fetchCredentials(integrationId, connectionId) {
32
+ const nango = getNangoInstance();
33
+ if (!nango) {
34
+ throw new Error("Nango not initialized. Set NANGO_SECRET_KEY environment variable or nangoSecretKey in config.");
35
+ }
36
+ const connection = await nango.getConnection(integrationId, connectionId);
37
+ // Extract token from credentials based on auth type
38
+ const creds = connection.credentials ?? {};
39
+ const token = creds.access_token ??
40
+ creds.api_key ??
41
+ creds.apiKey ??
42
+ creds.token ??
43
+ "";
44
+ return {
45
+ token,
46
+ connectionConfig: connection.connection_config ?? {},
47
+ raw: creds,
48
+ };
49
+ }
50
+ //# sourceMappingURL=nango-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nango-client.js","sourceRoot":"","sources":["../../src/connections/nango-client.ts"],"names":[],"mappings":"AAEA,2EAA2E;AAC3E,kFAAkF;AAClF,MAAM,SAAS,GAAG,MAAM,CAA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@ -0,0 +1,26 @@
1
+ import pg from "pg";
2
+ export interface ConnectionMapping {
3
+ workflow_name: string;
4
+ node_name: string;
5
+ integration_id: string;
6
+ connection_id: string;
7
+ updated_at?: Date;
8
+ }
9
+ /**
10
+ * Resolve a connection ID for a given workflow/node/integration.
11
+ * Checks for an exact match first, then falls back to global defaults (* / *).
12
+ */
13
+ export declare function resolveConnectionId(pool: pg.Pool, workflowName: string, nodeName: string, integrationId: string, schema: string): Promise<string | null>;
14
+ /**
15
+ * Upsert a connection mapping.
16
+ */
17
+ export declare function upsertConnection(pool: pg.Pool, mapping: Omit<ConnectionMapping, "updated_at">, schema: string): Promise<void>;
18
+ /**
19
+ * List all connection mappings.
20
+ */
21
+ export declare function listConnections(pool: pg.Pool, schema: string): Promise<ConnectionMapping[]>;
22
+ /**
23
+ * Delete a connection mapping.
24
+ */
25
+ export declare function deleteConnection(pool: pg.Pool, workflowName: string, nodeName: string, integrationId: string, schema: string): Promise<void>;
26
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/connections/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB;AAOD;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAcxB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,EAC9C,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAQf;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAOjG;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAQf"}
@@ -0,0 +1,48 @@
1
+ /** Schema-qualified table reference for opflow_connections */
2
+ function table(schema) {
3
+ return `"${schema}".opflow_connections`;
4
+ }
5
+ /**
6
+ * Resolve a connection ID for a given workflow/node/integration.
7
+ * Checks for an exact match first, then falls back to global defaults (* / *).
8
+ */
9
+ export async function resolveConnectionId(pool, workflowName, nodeName, integrationId, schema) {
10
+ const result = await pool.query(`SELECT connection_id FROM ${table(schema)}
11
+ WHERE integration_id = $1
12
+ AND (
13
+ (workflow_name = $2 AND node_name = $3)
14
+ OR (workflow_name = '*' AND node_name = '*')
15
+ )
16
+ ORDER BY
17
+ CASE WHEN workflow_name = '*' AND node_name = '*' THEN 1 ELSE 0 END
18
+ LIMIT 1`, [integrationId, workflowName, nodeName]);
19
+ return result.rows.length > 0 ? result.rows[0].connection_id : null;
20
+ }
21
+ /**
22
+ * Upsert a connection mapping.
23
+ */
24
+ export async function upsertConnection(pool, mapping, schema) {
25
+ await pool.query(`INSERT INTO ${table(schema)} (workflow_name, node_name, integration_id, connection_id, updated_at)
26
+ VALUES ($1, $2, $3, $4, NOW())
27
+ ON CONFLICT (workflow_name, node_name, integration_id)
28
+ DO UPDATE SET connection_id = EXCLUDED.connection_id, updated_at = NOW()`, [mapping.workflow_name, mapping.node_name, mapping.integration_id, mapping.connection_id]);
29
+ }
30
+ /**
31
+ * List all connection mappings.
32
+ */
33
+ export async function listConnections(pool, schema) {
34
+ const result = await pool.query(`SELECT workflow_name, node_name, integration_id, connection_id, updated_at
35
+ FROM ${table(schema)}
36
+ ORDER BY workflow_name, node_name, integration_id`);
37
+ return result.rows;
38
+ }
39
+ /**
40
+ * Delete a connection mapping.
41
+ */
42
+ export async function deleteConnection(pool, workflowName, nodeName, integrationId, schema) {
43
+ await pool.query(`DELETE FROM ${table(schema)}
44
+ WHERE workflow_name = $1
45
+ AND node_name = $2
46
+ AND integration_id = $3`, [workflowName, nodeName, integrationId]);
47
+ }
48
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/connections/resolver.ts"],"names":[],"mappings":"AAUA,8DAA8D;AAC9D,SAAS,KAAK,CAAC,MAAc;IAC3B,OAAO,IAAI,MAAM,sBAAsB,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,IAAa,EACb,YAAoB,EACpB,QAAgB,EAChB,aAAqB,EACrB,MAAc;IAEd,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAC7B,6BAA6B,KAAK,CAAC,MAAM,CAAC;;;;;;;;YAQlC,EACR,CAAC,aAAa,EAAE,YAAY,EAAE,QAAQ,CAAC,CACxC,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAwB,CAAC,CAAC,CAAC,IAAI,CAAC;AAClF,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAa,EACb,OAA8C,EAC9C,MAAc;IAEd,MAAM,IAAI,CAAC,KAAK,CACd,eAAe,KAAK,CAAC,MAAM,CAAC;;;6EAG6C,EACzE,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,aAAa,CAAC,CAC1F,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAa,EAAE,MAAc;IACjE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAC7B;WACO,KAAK,CAAC,MAAM,CAAC;sDAC8B,CACnD,CAAC;IACF,OAAO,MAAM,CAAC,IAA2B,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAa,EACb,YAAoB,EACpB,QAAgB,EAChB,aAAqB,EACrB,MAAc;IAEd,MAAM,IAAI,CAAC,KAAK,CACd,eAAe,KAAK,CAAC,MAAM,CAAC;;;8BAGF,EAC1B,CAAC,YAAY,EAAE,QAAQ,EAAE,aAAa,CAAC,CACxC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Ensure the opflow_connections table exists.
3
+ * Creates a short-lived connection, runs the DDL, then closes it.
4
+ * When schema is provided, the table is created in that schema explicitly
5
+ * (avoids permission issues when a same-named table exists in public).
6
+ */
7
+ export declare function ensureConnectionsTable(databaseUrl: string, schema: string): Promise<void>;
8
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/connections/schema.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAS/F"}
@@ -0,0 +1,31 @@
1
+ import pg from "pg";
2
+ function createTableSQL(schema) {
3
+ const table = `"${schema}".opflow_connections`;
4
+ return `
5
+ CREATE TABLE IF NOT EXISTS ${table} (
6
+ workflow_name TEXT NOT NULL,
7
+ node_name TEXT NOT NULL,
8
+ integration_id TEXT NOT NULL,
9
+ connection_id TEXT NOT NULL,
10
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
11
+ PRIMARY KEY (workflow_name, node_name, integration_id)
12
+ )`;
13
+ }
14
+ /**
15
+ * Ensure the opflow_connections table exists.
16
+ * Creates a short-lived connection, runs the DDL, then closes it.
17
+ * When schema is provided, the table is created in that schema explicitly
18
+ * (avoids permission issues when a same-named table exists in public).
19
+ */
20
+ export async function ensureConnectionsTable(databaseUrl, schema) {
21
+ const client = new pg.Client({ connectionString: databaseUrl });
22
+ try {
23
+ await client.connect();
24
+ await client.query(`CREATE SCHEMA IF NOT EXISTS "${schema}"`);
25
+ await client.query(createTableSQL(schema));
26
+ }
27
+ finally {
28
+ await client.end();
29
+ }
30
+ }
31
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/connections/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,SAAS,cAAc,CAAC,MAAc;IACpC,MAAM,KAAK,GAAG,IAAI,MAAM,sBAAsB,CAAC;IAC/C,OAAO;6BACoB,KAAK;;;;;;;EAOhC,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,WAAmB,EAAE,MAAc;IAC9E,MAAM,MAAM,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAC,CAAC;IAChE,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,MAAM,MAAM,CAAC,KAAK,CAAC,gCAAgC,MAAM,GAAG,CAAC,CAAC;QAC9D,MAAM,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7C,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAExE,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;CACrD;AAQD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,cAAmB,GAAG,eAAe,CAqBnF"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAExE,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;CACrD;AAQD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,cAAmB,GAAG,eAAe,CA6BnF"}
package/dist/context.js CHANGED
@@ -10,12 +10,16 @@ const defaultLogger = (message, level) => {
10
10
  export function createWorkflowContext(options = {}) {
11
11
  const logger = options.logger ?? defaultLogger;
12
12
  const ctx = {
13
+ workflowName: "*",
13
14
  run: async (executable, inputs) => {
14
15
  // Validate inputs against schema
15
16
  const validated = executable.inputSchema.parse(inputs);
16
17
  // Execute (DBOS wrapping will be added in factory integration)
17
18
  return executable.execute(ctx, validated);
18
19
  },
20
+ getConnection: async () => {
21
+ throw new Error("getConnection is not available in this context. Use create0pflow() for connection management.");
22
+ },
19
23
  log: (message, level = "info") => {
20
24
  logger(message, level);
21
25
  },
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAOA,M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jB,GAAG,EAAE,KAAK,EACR,UAAuC,EACvC,MAAc,EACI,EAAE;YACpB,iCAAiC;YACjC,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAEvD,+DAA+D;YAC/D,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC5C,CAAC;QAED,aAAa,EAAE,KAAK,IAAI,EAAE;YACxB,MAAM,IAAI,KAAK,CACb,+FAA+F,CAChG,CAAC;QACJ,CAAC;QAED,GAAG,EAAE,CAAC,OAAe,EAAE,QAAkB,MAAM,EAAE,EAAE;YACjD,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACzB,CAAC;KACF,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
+ import type pg from "pg";
3
+ import type { IntegrationProvider } from "../connections/integration-provider.js";
4
+ export interface ApiContext {
5
+ pool: pg.Pool;
6
+ integrationProvider: IntegrationProvider;
7
+ /** DBOS system schema (e.g. my_app_dbos) for workflow_status queries */
8
+ schema: string;
9
+ /** App schema where opflow_connections lives (e.g. my_app) */
10
+ appSchema: string;
11
+ /** Project root directory for CLI subprocess execution */
12
+ projectRoot: string;
13
+ }
14
+ /**
15
+ * Handle API requests. Returns true if the request was handled, false otherwise.
16
+ */
17
+ export declare function handleApiRequest(req: IncomingMessage, res: ServerResponse, ctx: ApiContext): Promise<boolean>;
18
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/dev-ui/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAGjE,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAMzB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAKlF,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IACd,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAC;CACrB;AA0BD;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,OAAO,CAAC,CAsRlB"}
@@ -0,0 +1,273 @@
1
+ import { execFile } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import { listConnections, upsertConnection, deleteConnection, } from "../connections/index.js";
4
+ import { parseOutput } from "../cli/trace.js";
5
+ const execFileAsync = promisify(execFile);
6
+ function jsonResponse(res, status, data) {
7
+ res.writeHead(status, {
8
+ "Content-Type": "application/json",
9
+ "Access-Control-Allow-Origin": "*",
10
+ });
11
+ res.end(JSON.stringify(data));
12
+ }
13
+ function parseBody(req) {
14
+ return new Promise((resolve, reject) => {
15
+ const chunks = [];
16
+ req.on("data", (chunk) => chunks.push(chunk));
17
+ req.on("end", () => {
18
+ try {
19
+ const body = Buffer.concat(chunks).toString("utf-8");
20
+ resolve(body ? JSON.parse(body) : {});
21
+ }
22
+ catch (err) {
23
+ reject(err);
24
+ }
25
+ });
26
+ req.on("error", reject);
27
+ });
28
+ }
29
+ /**
30
+ * Handle API requests. Returns true if the request was handled, false otherwise.
31
+ */
32
+ export async function handleApiRequest(req, res, ctx) {
33
+ const url = req.url ?? "";
34
+ const method = req.method ?? "GET";
35
+ // CORS preflight
36
+ if (method === "OPTIONS" && url.startsWith("/api/")) {
37
+ res.writeHead(204, {
38
+ "Access-Control-Allow-Origin": "*",
39
+ "Access-Control-Allow-Methods": "GET, PUT, DELETE, POST, OPTIONS",
40
+ "Access-Control-Allow-Headers": "Content-Type",
41
+ });
42
+ res.end();
43
+ return true;
44
+ }
45
+ // GET /api/connections
46
+ if (url === "/api/connections" && method === "GET") {
47
+ const connections = await listConnections(ctx.pool, ctx.appSchema);
48
+ jsonResponse(res, 200, connections);
49
+ return true;
50
+ }
51
+ // PUT /api/connections
52
+ if (url === "/api/connections" && method === "PUT") {
53
+ const body = (await parseBody(req));
54
+ if (!body.integration_id || !body.connection_id) {
55
+ jsonResponse(res, 400, { error: "integration_id and connection_id are required" });
56
+ return true;
57
+ }
58
+ await upsertConnection(ctx.pool, {
59
+ workflow_name: body.workflow_name ?? "*",
60
+ node_name: body.node_name ?? "*",
61
+ integration_id: body.integration_id,
62
+ connection_id: body.connection_id,
63
+ }, ctx.appSchema);
64
+ jsonResponse(res, 200, { ok: true });
65
+ return true;
66
+ }
67
+ // DELETE /api/connections
68
+ if (url === "/api/connections" && method === "DELETE") {
69
+ const body = (await parseBody(req));
70
+ if (!body.integration_id) {
71
+ jsonResponse(res, 400, { error: "integration_id is required" });
72
+ return true;
73
+ }
74
+ await deleteConnection(ctx.pool, body.workflow_name ?? "*", body.node_name ?? "*", body.integration_id, ctx.appSchema);
75
+ jsonResponse(res, 200, { ok: true });
76
+ return true;
77
+ }
78
+ // GET /api/nango/integrations — list available integrations
79
+ if (url === "/api/nango/integrations" && method === "GET") {
80
+ try {
81
+ const integrations = await ctx.integrationProvider.listIntegrations();
82
+ jsonResponse(res, 200, integrations);
83
+ }
84
+ catch (err) {
85
+ jsonResponse(res, 500, {
86
+ error: err instanceof Error ? err.message : "Failed to list integrations",
87
+ });
88
+ }
89
+ return true;
90
+ }
91
+ // GET /api/nango/connections/:integrationId
92
+ const nangoConnectionsMatch = url.match(/^\/api\/nango\/connections\/([^/]+)$/);
93
+ if (nangoConnectionsMatch && method === "GET") {
94
+ const integrationId = decodeURIComponent(nangoConnectionsMatch[1]);
95
+ try {
96
+ const connections = await ctx.integrationProvider.listConnections(integrationId);
97
+ jsonResponse(res, 200, connections);
98
+ }
99
+ catch (err) {
100
+ jsonResponse(res, 500, {
101
+ error: err instanceof Error ? err.message : "Failed to list connections",
102
+ });
103
+ }
104
+ return true;
105
+ }
106
+ // POST /api/nango/connect-session
107
+ if (url === "/api/nango/connect-session" && method === "POST") {
108
+ const body = (await parseBody(req));
109
+ if (!body.integration_id) {
110
+ jsonResponse(res, 400, { error: "integration_id is required" });
111
+ return true;
112
+ }
113
+ try {
114
+ const session = await ctx.integrationProvider.createConnectSession(body.integration_id);
115
+ jsonResponse(res, 200, session);
116
+ }
117
+ catch (err) {
118
+ jsonResponse(res, 500, {
119
+ error: err instanceof Error ? err.message : "Failed to create connect session",
120
+ });
121
+ }
122
+ return true;
123
+ }
124
+ // ---- Run History endpoints ----
125
+ /** Unwrap a superjson-wrapped error into a clean string (stack trace if available, else message) */
126
+ function parseError(raw) {
127
+ if (!raw)
128
+ return null;
129
+ const parsed = parseOutput(raw);
130
+ if (parsed && typeof parsed === "object") {
131
+ const obj = parsed;
132
+ // Stack already includes the message as its first line
133
+ if (typeof obj.stack === "string")
134
+ return obj.stack;
135
+ if (typeof obj.message === "string")
136
+ return obj.message;
137
+ }
138
+ if (typeof parsed === "string")
139
+ return parsed;
140
+ if (typeof raw === "string")
141
+ return raw;
142
+ return null;
143
+ }
144
+ // GET /api/runs?workflow=NAME&limit=N
145
+ if (url.startsWith("/api/runs") && method === "GET") {
146
+ const fullUrl = req.url ?? "";
147
+ // GET /api/runs/:runId/trace
148
+ const traceMatch = fullUrl.match(/^\/api\/runs\/([^/]+)\/trace/);
149
+ if (traceMatch) {
150
+ const runId = decodeURIComponent(traceMatch[1]);
151
+ try {
152
+ // Get workflow metadata
153
+ const workflowResult = await ctx.pool.query(`SELECT
154
+ workflow_uuid, name, status, created_at, updated_at,
155
+ (updated_at - created_at) as duration_ms,
156
+ output::text, error
157
+ FROM ${ctx.schema}.workflow_status
158
+ WHERE workflow_uuid = $1`, [runId]);
159
+ if (workflowResult.rows.length === 0) {
160
+ jsonResponse(res, 404, { error: "Run not found" });
161
+ return true;
162
+ }
163
+ const workflow = workflowResult.rows[0];
164
+ workflow.output = parseOutput(workflow.output);
165
+ workflow.error = parseError(workflow.error);
166
+ // Get operations with hierarchy using recursive CTE
167
+ const opsResult = await ctx.pool.query(`WITH RECURSIVE workflow_tree AS (
168
+ SELECT workflow_uuid, workflow_uuid as root_uuid, 0 as depth
169
+ FROM ${ctx.schema}.workflow_status
170
+ WHERE workflow_uuid = $1
171
+ UNION
172
+ SELECT ws.workflow_uuid, wt.root_uuid, wt.depth + 1
173
+ FROM ${ctx.schema}.workflow_status ws
174
+ JOIN ${ctx.schema}.operation_outputs oo ON oo.child_workflow_id = ws.workflow_uuid
175
+ JOIN workflow_tree wt ON oo.workflow_uuid = wt.workflow_uuid
176
+ )
177
+ SELECT
178
+ oo.workflow_uuid, wt.depth, oo.function_id, oo.function_name,
179
+ oo.child_workflow_id, oo.started_at_epoch_ms, oo.completed_at_epoch_ms,
180
+ (oo.completed_at_epoch_ms - oo.started_at_epoch_ms) as duration_ms,
181
+ oo.output::text as output_preview, oo.error
182
+ FROM workflow_tree wt
183
+ JOIN ${ctx.schema}.operation_outputs oo ON oo.workflow_uuid = wt.workflow_uuid
184
+ ORDER BY oo.started_at_epoch_ms, wt.depth, oo.function_id`, [runId]);
185
+ // Unwrap superjson in operation output previews and errors
186
+ const operations = opsResult.rows.map((op) => {
187
+ if (op.output_preview) {
188
+ const parsed = parseOutput(op.output_preview);
189
+ op.output_preview = parsed !== null ? JSON.stringify(parsed) : null;
190
+ }
191
+ op.error = parseError(op.error);
192
+ return op;
193
+ });
194
+ jsonResponse(res, 200, { workflow, operations });
195
+ }
196
+ catch (err) {
197
+ jsonResponse(res, 500, {
198
+ error: err instanceof Error ? err.message : "Failed to get trace",
199
+ });
200
+ }
201
+ return true;
202
+ }
203
+ // GET /api/runs (list)
204
+ if (fullUrl.match(/^\/api\/runs(\?|$)/)) {
205
+ try {
206
+ const params = new URL(fullUrl, "http://localhost").searchParams;
207
+ const workflowName = params.get("workflow");
208
+ const limit = Math.min(parseInt(params.get("limit") ?? "50", 10), 200);
209
+ const queryParams = [];
210
+ let query = `
211
+ SELECT workflow_uuid, name, status, created_at, updated_at, output::text, error
212
+ FROM ${ctx.schema}.workflow_status
213
+ WHERE LENGTH(workflow_uuid) = 36
214
+ `;
215
+ if (workflowName) {
216
+ queryParams.push(workflowName);
217
+ query += ` AND name = $${queryParams.length}`;
218
+ }
219
+ queryParams.push(limit);
220
+ query += ` ORDER BY created_at DESC LIMIT $${queryParams.length}`;
221
+ const result = await ctx.pool.query(query, queryParams);
222
+ // Unwrap superjson output and errors for each run
223
+ const runs = result.rows.map((row) => {
224
+ row.output = parseOutput(row.output);
225
+ row.error = parseError(row.error);
226
+ return row;
227
+ });
228
+ jsonResponse(res, 200, runs);
229
+ }
230
+ catch (err) {
231
+ jsonResponse(res, 500, {
232
+ error: err instanceof Error ? err.message : "Failed to list runs",
233
+ });
234
+ }
235
+ return true;
236
+ }
237
+ }
238
+ // POST /api/workflows/:name/run — execute a workflow via subprocess
239
+ const runMatch = url.match(/^\/api\/workflows\/([^/]+)\/run$/);
240
+ if (runMatch && method === "POST") {
241
+ const workflowName = decodeURIComponent(runMatch[1]);
242
+ const body = (await parseBody(req));
243
+ const input = body.input ?? {};
244
+ const [runtime, script] = process.argv;
245
+ try {
246
+ const { stdout } = await execFileAsync(runtime, [
247
+ ...process.execArgv,
248
+ script,
249
+ "workflow", "run", workflowName,
250
+ "--json",
251
+ "-i", JSON.stringify(input),
252
+ ], { cwd: ctx.projectRoot });
253
+ jsonResponse(res, 200, JSON.parse(stdout));
254
+ }
255
+ catch (err) {
256
+ const execErr = err;
257
+ if (execErr.stdout) {
258
+ try {
259
+ jsonResponse(res, 200, JSON.parse(execErr.stdout));
260
+ return true;
261
+ }
262
+ catch { /* fall through */ }
263
+ }
264
+ jsonResponse(res, 500, {
265
+ status: "ERROR",
266
+ error: execErr.stderr?.trim() || execErr.message || String(err),
267
+ });
268
+ }
269
+ return true;
270
+ }
271
+ return false;
272
+ }
273
+ //# sourceMappingURL=api.js.map