@synapseone/sdk 0.7.0 → 0.7.1-dev.56

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/workflow.js CHANGED
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // SPDX-FileCopyrightText: 2026 VKU.VIC
2
4
  /*
3
5
  * Copyright 2026 SynapseOne Contributors
4
6
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -10,6 +12,7 @@ exports.WorkflowService = void 0;
10
12
  exports.unwrapCredentialList = unwrapCredentialList;
11
13
  exports.unwrapExecutions = unwrapExecutions;
12
14
  exports.triggerWebhook = triggerWebhook;
15
+ const _http_1 = require("./_http");
13
16
  class WorkflowService {
14
17
  http;
15
18
  constructor(http) {
@@ -108,13 +111,19 @@ class WorkflowService {
108
111
  * Fire a public inbound webhook through the gateway: `ANY /webhook/:path`.
109
112
  * No auth is required; per-workflow auth/rate-limit/idempotency still apply.
110
113
  * `path` is the webhook node's `parameters.path`, not a workflow id.
114
+ *
115
+ * The gateway allows 300s for `/webhook`; this call uses that budget unless
116
+ * `init.timeoutMs` overrides it.
111
117
  */
112
118
  triggerWebhook(path, payload, init = {}) {
113
119
  const clean = String(path || '').replace(/^\/+|\/+$/g, '').split('?')[0];
114
120
  if (!clean)
115
121
  throw new Error('synapseone webhook: path required');
116
122
  const method = (init.method || (payload === undefined ? 'GET' : 'POST')).toUpperCase();
117
- return this.http.call(method, `/webhook/${clean}`, payload);
123
+ return this.http.req(`/webhook/${clean}`, {
124
+ method,
125
+ body: payload === undefined || method === 'GET' || method === 'HEAD' ? undefined : JSON.stringify(payload),
126
+ }, { timeoutMs: init.timeoutMs ?? _http_1.WEBHOOK_TIMEOUT_MS, signal: init.signal, retryable: true });
118
127
  }
119
128
  }
120
129
  exports.WorkflowService = WorkflowService;
@@ -155,14 +164,21 @@ async function triggerWebhook(webhookBaseUrl, path, payload, init) {
155
164
  const method = (init?.method || (payload === undefined ? 'GET' : 'POST')).toUpperCase();
156
165
  const url = `${base}/webhook/${clean}`;
157
166
  const ctl = new AbortController();
158
- const to = setTimeout(() => ctl.abort(), init?.timeoutMs ?? 15000);
167
+ const onAbort = () => ctl.abort();
168
+ if (init?.signal) {
169
+ if (init.signal.aborted)
170
+ ctl.abort();
171
+ else
172
+ init.signal.addEventListener('abort', onAbort, { once: true });
173
+ }
174
+ const to = setTimeout(() => ctl.abort(), init?.timeoutMs ?? _http_1.WEBHOOK_TIMEOUT_MS);
159
175
  let r;
160
176
  try {
161
177
  r = await fetch(url, {
162
178
  method,
163
179
  signal: ctl.signal,
164
180
  headers: { 'Content-Type': 'application/json' },
165
- body: payload === undefined ? undefined : JSON.stringify(payload),
181
+ body: payload === undefined || method === 'GET' || method === 'HEAD' ? undefined : JSON.stringify(payload),
166
182
  });
167
183
  }
168
184
  catch (e) {
@@ -170,6 +186,8 @@ async function triggerWebhook(webhookBaseUrl, path, payload, init) {
170
186
  }
171
187
  finally {
172
188
  clearTimeout(to);
189
+ if (init?.signal)
190
+ init.signal.removeEventListener('abort', onAbort);
173
191
  }
174
192
  const text = await r.text();
175
193
  let data = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synapseone/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.7.1-dev.56",
4
4
  "license": "Apache-2.0",
5
5
  "description": "synapseone SDK for JavaScript/TypeScript",
6
6
  "homepage": "https://synapseone.space",
@@ -64,7 +64,37 @@
64
64
  "require": "./dist/queue.js",
65
65
  "default": "./dist/queue.js"
66
66
  },
67
- "./package.json": "./package.json"
67
+ "./stream": {
68
+ "types": "./dist/stream.d.ts",
69
+ "require": "./dist/stream.js",
70
+ "default": "./dist/stream.js"
71
+ },
72
+ "./ai": {
73
+ "types": "./dist/ai.d.ts",
74
+ "require": "./dist/ai.js",
75
+ "default": "./dist/ai.js"
76
+ },
77
+ "./inference": {
78
+ "types": "./dist/inference.d.ts",
79
+ "require": "./dist/inference.js",
80
+ "default": "./dist/inference.js"
81
+ },
82
+ "./health": {
83
+ "types": "./dist/health.d.ts",
84
+ "require": "./dist/health.js",
85
+ "default": "./dist/health.js"
86
+ },
87
+ "./package.json": "./package.json",
88
+ "./storage": {
89
+ "types": "./dist/storage.d.ts",
90
+ "require": "./dist/storage.js",
91
+ "default": "./dist/storage.js"
92
+ },
93
+ "./notifications": {
94
+ "types": "./dist/notifications.d.ts",
95
+ "require": "./dist/notifications.js",
96
+ "default": "./dist/notifications.js"
97
+ }
68
98
  },
69
99
  "files": [
70
100
  "dist",
@@ -72,7 +102,7 @@
72
102
  ],
73
103
  "scripts": {
74
104
  "build": "tsc -p tsconfig.json",
75
- "test": "node --test dist/client.test.js dist/services.test.js",
105
+ "test": "node --test dist/*.test.js",
76
106
  "lint": "echo lint-ok"
77
107
  },
78
108
  "dependencies": {},