@revenexx/integrations-node-sdk 1.2.0 → 1.3.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.cjs +80 -0
- package/dist/index.d.cts +62 -1
- package/dist/index.d.ts +62 -1
- package/dist/index.js +75 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -54,11 +54,14 @@ __export(index_exports, {
|
|
|
54
54
|
backoffDelay: () => backoffDelay,
|
|
55
55
|
buildManifest: () => buildManifest,
|
|
56
56
|
clampResponseBytes: () => clampResponseBytes,
|
|
57
|
+
errorPort: () => errorPort,
|
|
58
|
+
errorResult: () => errorResult,
|
|
57
59
|
evaluate: () => evaluate,
|
|
58
60
|
extractCredentialManifest: () => extractCredentialManifest,
|
|
59
61
|
extractCredentialManifests: () => extractCredentialManifests,
|
|
60
62
|
extractManifest: () => extractManifest,
|
|
61
63
|
extractManifests: () => extractManifests,
|
|
64
|
+
httpErrorResult: () => httpErrorResult,
|
|
62
65
|
isBlockedAddress: () => isBlockedAddress,
|
|
63
66
|
isNodeWithIteration: () => isNodeWithIteration,
|
|
64
67
|
isOAuthAuthorizeCredential: () => isOAuthAuthorizeCredential,
|
|
@@ -76,6 +79,8 @@ __export(index_exports, {
|
|
|
76
79
|
sleepWithSignal: () => sleepWithSignal,
|
|
77
80
|
takesValue: () => takesValue,
|
|
78
81
|
timeoutConfigField: () => timeoutConfigField,
|
|
82
|
+
toErrorOutput: () => toErrorOutput,
|
|
83
|
+
toErrorResult: () => toErrorResult,
|
|
79
84
|
withRetry: () => withRetry
|
|
80
85
|
});
|
|
81
86
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -203,6 +208,76 @@ var NodeError = class extends Error {
|
|
|
203
208
|
}
|
|
204
209
|
};
|
|
205
210
|
|
|
211
|
+
// src/nodeErrors.ts
|
|
212
|
+
function toErrorOutput(err) {
|
|
213
|
+
if (err instanceof NodeError) {
|
|
214
|
+
const raw = err.meta?.["status"];
|
|
215
|
+
const status = typeof raw === "number" && Number.isFinite(raw) ? raw : 0;
|
|
216
|
+
return { code: err.code, message: err.message, status };
|
|
217
|
+
}
|
|
218
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
219
|
+
return { code: "TIMEOUT", message: "Request timed out", status: 0 };
|
|
220
|
+
}
|
|
221
|
+
if (err instanceof Error) {
|
|
222
|
+
return { code: "REQUEST_FAILED", message: err.message, status: 0 };
|
|
223
|
+
}
|
|
224
|
+
return { code: "REQUEST_FAILED", message: String(err), status: 0 };
|
|
225
|
+
}
|
|
226
|
+
function errorResult(output, port = "error") {
|
|
227
|
+
return { outputs: { [port]: output }, branch: port };
|
|
228
|
+
}
|
|
229
|
+
function toErrorResult(err, port = "error") {
|
|
230
|
+
return errorResult(toErrorOutput(err), port);
|
|
231
|
+
}
|
|
232
|
+
function httpErrorResult(err, port = "error") {
|
|
233
|
+
const body = err instanceof NodeError ? err.meta?.["body"] ?? null : null;
|
|
234
|
+
return errorResult({ ...toErrorOutput(err), body }, port);
|
|
235
|
+
}
|
|
236
|
+
function errorPort(opts = {}) {
|
|
237
|
+
return {
|
|
238
|
+
name: "error",
|
|
239
|
+
kind: "error",
|
|
240
|
+
dataType: "object",
|
|
241
|
+
label: { en: "Error", de: "Fehler" },
|
|
242
|
+
description: {
|
|
243
|
+
en: "Taken when the attempt fails in a way the workflow can carry on from. A node that cannot run as configured fails the run instead of taking this path.",
|
|
244
|
+
de: "Wird genommen, wenn der Versuch auf eine Weise fehlschl\xE4gt, mit der der Workflow weiterarbeiten kann. Ein Node, der so konfiguriert nicht laufen kann, l\xE4sst den Run scheitern, statt diesen Pfad zu nehmen."
|
|
245
|
+
},
|
|
246
|
+
fields: {
|
|
247
|
+
code: {
|
|
248
|
+
dataType: "string",
|
|
249
|
+
description: {
|
|
250
|
+
en: "Machine-readable name of the failure \u2014 branch on this rather than on the message. A node that talks to a remote system shares `TIMEOUT` and `REQUEST_FAILED` with every other one; the remaining codes belong to this node alone.",
|
|
251
|
+
de: "Maschinenlesbarer Name des Fehlers \u2014 hierauf verzweigen, nicht auf die Meldung. Ein Node, der mit einem Fremdsystem spricht, teilt `TIMEOUT` und `REQUEST_FAILED` mit allen anderen; die \xFCbrigen Codes geh\xF6ren allein zu diesem Node."
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
message: {
|
|
255
|
+
dataType: "string",
|
|
256
|
+
description: {
|
|
257
|
+
en: "Wording for whoever reads the run afterwards, frequently the wording the far end used. It is not a stable value to branch on.",
|
|
258
|
+
de: "Wortlaut f\xFCr den, der den Run sp\xE4ter liest, h\xE4ufig der des Gegen\xFCbers. Kein stabiler Wert, auf den sich Verzweigungen st\xFCtzen sollten."
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
status: {
|
|
262
|
+
dataType: "number",
|
|
263
|
+
description: {
|
|
264
|
+
en: "How the far end answered, as an HTTP status code, where one answered with a status at all. `0` otherwise \u2014 a timeout, a refused connection, an input the node could not use, a node that never leaves the workflow, or a failure the far end reported in its own answer rather than in a status, as a bulk job that ends as failed does. So `0` means there is no status to read, not that nothing was reached.",
|
|
265
|
+
de: "Wie das Gegen\xFCber geantwortet hat, als HTTP-Statuscode \u2014 sofern eines \xFCberhaupt mit einem Status geantwortet hat. Sonst `0`: Timeout, abgelehnte Verbindung, eine unbrauchbare Eingabe, ein Node, der den Workflow nicht verl\xE4sst, oder ein Fehler, den das Gegen\xFCber in seiner Antwort statt im Status gemeldet hat \u2014 wie ein Bulk-Job, der als fehlgeschlagen endet. `0` hei\xDFt also: kein Status zu lesen, nicht: nichts erreicht."
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
...opts.body ? {
|
|
269
|
+
body: {
|
|
270
|
+
dataType: "any",
|
|
271
|
+
description: {
|
|
272
|
+
en: "The answer the far end gave, where the failure got far enough to have one: the response body, or the job the platform reported as failed.",
|
|
273
|
+
de: "Die Antwort des Gegen\xFCbers, sofern der Fehler weit genug kam, um eine zu haben: der Response-Body oder der von der Plattform als fehlgeschlagen gemeldete Job."
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
} : {}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
206
281
|
// src/extract.ts
|
|
207
282
|
function extractManifest(node) {
|
|
208
283
|
return node.description;
|
|
@@ -980,11 +1055,14 @@ function base64Url(buf) {
|
|
|
980
1055
|
backoffDelay,
|
|
981
1056
|
buildManifest,
|
|
982
1057
|
clampResponseBytes,
|
|
1058
|
+
errorPort,
|
|
1059
|
+
errorResult,
|
|
983
1060
|
evaluate,
|
|
984
1061
|
extractCredentialManifest,
|
|
985
1062
|
extractCredentialManifests,
|
|
986
1063
|
extractManifest,
|
|
987
1064
|
extractManifests,
|
|
1065
|
+
httpErrorResult,
|
|
988
1066
|
isBlockedAddress,
|
|
989
1067
|
isNodeWithIteration,
|
|
990
1068
|
isOAuthAuthorizeCredential,
|
|
@@ -1002,5 +1080,7 @@ function base64Url(buf) {
|
|
|
1002
1080
|
sleepWithSignal,
|
|
1003
1081
|
takesValue,
|
|
1004
1082
|
timeoutConfigField,
|
|
1083
|
+
toErrorOutput,
|
|
1084
|
+
toErrorResult,
|
|
1005
1085
|
withRetry
|
|
1006
1086
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -650,6 +650,67 @@ declare class NodeError extends Error {
|
|
|
650
650
|
constructor(code: string, message: string, meta?: Record<string, unknown>);
|
|
651
651
|
}
|
|
652
652
|
|
|
653
|
+
/**
|
|
654
|
+
* Canonical error-output shape emitted on a node's `error` port. It lives here
|
|
655
|
+
* rather than in a node package because all four of them were building it
|
|
656
|
+
* separately — `integrations-nodes-core` in an internal module, `deepl` in a
|
|
657
|
+
* copy of that module, Business Central in `bc-fetch.ts` and Pipedrive in
|
|
658
|
+
* `pipedrive-client.ts` — so the workflow editor's guarantee of one
|
|
659
|
+
* `{ code, message, status }` payload rested on four files agreeing by hand
|
|
660
|
+
* (PO-442; asked for by PO-134 in June and not done then).
|
|
661
|
+
*/
|
|
662
|
+
interface NodeErrorOutput {
|
|
663
|
+
/** Machine-readable error code, e.g. `HTTP_ERROR`, `TIMEOUT`, `REQUEST_FAILED`. */
|
|
664
|
+
code: string;
|
|
665
|
+
message: string;
|
|
666
|
+
/** HTTP status code, or `0` for timeouts / network / non-HTTP errors. */
|
|
667
|
+
status: number;
|
|
668
|
+
/** Optional response body — HTTP-specific. */
|
|
669
|
+
body?: unknown;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Normalize any caught value into the canonical {@link NodeErrorOutput} shape.
|
|
673
|
+
* Use this in a node's `catch` block before routing to the `error` port.
|
|
674
|
+
*/
|
|
675
|
+
declare function toErrorOutput(err: unknown): NodeErrorOutput;
|
|
676
|
+
/** Wrap an error output into an `INodeResult` routed to the `error` port. */
|
|
677
|
+
declare function errorResult(output: NodeErrorOutput, port?: string): INodeResult;
|
|
678
|
+
/**
|
|
679
|
+
* Catch-block shortcut: normalize any thrown value and route it to the failure
|
|
680
|
+
* output. The one helper every node's `catch` funnels into, so the
|
|
681
|
+
* `{ code, message, status }` mapping lives in a single place instead of being
|
|
682
|
+
* re-implemented per protocol (FTP/SFTP) or per package.
|
|
683
|
+
*
|
|
684
|
+
* `port` is the output taken, `error` unless the node declares its failure
|
|
685
|
+
* output under another name (`{ ...errorPort(), name: 'failed' }`) — pass the
|
|
686
|
+
* same name here, or the branch names a port that node does not have.
|
|
687
|
+
*/
|
|
688
|
+
declare function toErrorResult(err: unknown, port?: string): INodeResult;
|
|
689
|
+
/**
|
|
690
|
+
* Catch-block shortcut for the HTTP-style nodes whose failure output additionally
|
|
691
|
+
* declares `body`: the canonical `{ code, message, status }` mapping plus the
|
|
692
|
+
* response body a {@link NodeError} carries in `meta.body` (`null` when the
|
|
693
|
+
* failure never reached a response). `port` names the output as above.
|
|
694
|
+
*/
|
|
695
|
+
declare function httpErrorResult(err: unknown, port?: string): INodeResult;
|
|
696
|
+
/**
|
|
697
|
+
* Shared `error` output port — the uniform `{ code, message, status }` triple
|
|
698
|
+
* declared on every node that has an `error` branch. Pass `body: true` for
|
|
699
|
+
* HTTP-style nodes that additionally emit a response body on the port.
|
|
700
|
+
*
|
|
701
|
+
* The sentences travel with the port. The three values mean the same thing
|
|
702
|
+
* behind every node, so they are written here once instead of per node; a node
|
|
703
|
+
* whose failures are worth naming more precisely spreads the port and replaces
|
|
704
|
+
* only its `description` (`{ ...errorPort(), description: … }`).
|
|
705
|
+
*
|
|
706
|
+
* The second sentence of the description is the rule this port exists under,
|
|
707
|
+
* and it is promised in `specs/error-handling.md`: a fault in the author's own
|
|
708
|
+
* configuration ends the run, a fault met while running is offered here.
|
|
709
|
+
*/
|
|
710
|
+
declare function errorPort(opts?: {
|
|
711
|
+
body?: boolean;
|
|
712
|
+
}): IOutputPort;
|
|
713
|
+
|
|
653
714
|
declare function extractManifest(node: INode): INodeDescription;
|
|
654
715
|
declare function extractManifests(nodes: INode[]): INodeDescription[];
|
|
655
716
|
declare function extractCredentialManifest(credential: ICredential): ICredentialDescription;
|
|
@@ -1046,4 +1107,4 @@ declare abstract class OAuth2AuthCodeCredential extends BaseCredential implement
|
|
|
1046
1107
|
test(_ctx: ICredentialContext, config: Config): Promise<ICredentialTestResult>;
|
|
1047
1108
|
}
|
|
1048
1109
|
|
|
1049
|
-
export { ApiKeyCredential, BaseCredential, BasicAuthCredential, type ConfigType, type CredentialAuthKind, type CredentialFieldType, DEFAULT_MAX_RESPONSE_BYTES, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAY_MS, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUT_MS, type DataType, type IConfigField, type IConfigFieldBase, type IConfigOption, type IConfigValidation, type ICredential, type ICredentialContext, type ICredentialDescription, type ICredentialField, type ICredentialOAuthAuthorize, type ICredentialResolveResult, type ICredentialTestResult, type IImage, type IInputPort, type INode, type INodeAuthorContext, type INodeContext, type INodeDescription, type INodeResult, type INodeState, type INodeWithIteration, type IOutputField, type IOutputPort, type IShowIfCondition, type ITemplateDescription, type ITemplateTrigger, type ImageCategory, type LocalizedString, type LookupAddress, type LookupFn, MANIFEST_VERSION, MAX_REDIRECTS, MAX_RESPONSE_BYTES, MAX_RETRY_ATTEMPTS, MAX_TIMEOUT_MS, type NodeCategory, NodeError, type NodeManifest, type NodePackageMeta, OAuth2AuthCodeCredential, OAuth2ClientCredentialsCredential, type OAuthTokenResponse, OPERATORS, type Operator, type OutputKind, type RetryHooks, type RetryPolicy, RetryableError, type SafeFetchOptions, type SafeFetchRetry, SimpleValueCredential, type TemplateLevel, type TemplateTriggerType, VALUELESS_OPERATORS, assertPublicUrl, backoffDelay, buildManifest, clampResponseBytes, evaluate, extractCredentialManifest, extractCredentialManifests, extractManifest, extractManifests, isBlockedAddress, isNodeWithIteration, isOAuthAuthorizeCredential, isOperator, maxBytesConfigField, normalizeCredentialType, normalizeLocalized, parsePackageMeta, readArrayBuffer, readJsonOrText, readText, retryConfigFields, safeFetch, settingApplies, sleepWithSignal, takesValue, timeoutConfigField, withRetry };
|
|
1110
|
+
export { ApiKeyCredential, BaseCredential, BasicAuthCredential, type ConfigType, type CredentialAuthKind, type CredentialFieldType, DEFAULT_MAX_RESPONSE_BYTES, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAY_MS, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUT_MS, type DataType, type IConfigField, type IConfigFieldBase, type IConfigOption, type IConfigValidation, type ICredential, type ICredentialContext, type ICredentialDescription, type ICredentialField, type ICredentialOAuthAuthorize, type ICredentialResolveResult, type ICredentialTestResult, type IImage, type IInputPort, type INode, type INodeAuthorContext, type INodeContext, type INodeDescription, type INodeResult, type INodeState, type INodeWithIteration, type IOutputField, type IOutputPort, type IShowIfCondition, type ITemplateDescription, type ITemplateTrigger, type ImageCategory, type LocalizedString, type LookupAddress, type LookupFn, MANIFEST_VERSION, MAX_REDIRECTS, MAX_RESPONSE_BYTES, MAX_RETRY_ATTEMPTS, MAX_TIMEOUT_MS, type NodeCategory, NodeError, type NodeErrorOutput, type NodeManifest, type NodePackageMeta, OAuth2AuthCodeCredential, OAuth2ClientCredentialsCredential, type OAuthTokenResponse, OPERATORS, type Operator, type OutputKind, type RetryHooks, type RetryPolicy, RetryableError, type SafeFetchOptions, type SafeFetchRetry, SimpleValueCredential, type TemplateLevel, type TemplateTriggerType, VALUELESS_OPERATORS, assertPublicUrl, backoffDelay, buildManifest, clampResponseBytes, errorPort, errorResult, evaluate, extractCredentialManifest, extractCredentialManifests, extractManifest, extractManifests, httpErrorResult, isBlockedAddress, isNodeWithIteration, isOAuthAuthorizeCredential, isOperator, maxBytesConfigField, normalizeCredentialType, normalizeLocalized, parsePackageMeta, readArrayBuffer, readJsonOrText, readText, retryConfigFields, safeFetch, settingApplies, sleepWithSignal, takesValue, timeoutConfigField, toErrorOutput, toErrorResult, withRetry };
|
package/dist/index.d.ts
CHANGED
|
@@ -650,6 +650,67 @@ declare class NodeError extends Error {
|
|
|
650
650
|
constructor(code: string, message: string, meta?: Record<string, unknown>);
|
|
651
651
|
}
|
|
652
652
|
|
|
653
|
+
/**
|
|
654
|
+
* Canonical error-output shape emitted on a node's `error` port. It lives here
|
|
655
|
+
* rather than in a node package because all four of them were building it
|
|
656
|
+
* separately — `integrations-nodes-core` in an internal module, `deepl` in a
|
|
657
|
+
* copy of that module, Business Central in `bc-fetch.ts` and Pipedrive in
|
|
658
|
+
* `pipedrive-client.ts` — so the workflow editor's guarantee of one
|
|
659
|
+
* `{ code, message, status }` payload rested on four files agreeing by hand
|
|
660
|
+
* (PO-442; asked for by PO-134 in June and not done then).
|
|
661
|
+
*/
|
|
662
|
+
interface NodeErrorOutput {
|
|
663
|
+
/** Machine-readable error code, e.g. `HTTP_ERROR`, `TIMEOUT`, `REQUEST_FAILED`. */
|
|
664
|
+
code: string;
|
|
665
|
+
message: string;
|
|
666
|
+
/** HTTP status code, or `0` for timeouts / network / non-HTTP errors. */
|
|
667
|
+
status: number;
|
|
668
|
+
/** Optional response body — HTTP-specific. */
|
|
669
|
+
body?: unknown;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Normalize any caught value into the canonical {@link NodeErrorOutput} shape.
|
|
673
|
+
* Use this in a node's `catch` block before routing to the `error` port.
|
|
674
|
+
*/
|
|
675
|
+
declare function toErrorOutput(err: unknown): NodeErrorOutput;
|
|
676
|
+
/** Wrap an error output into an `INodeResult` routed to the `error` port. */
|
|
677
|
+
declare function errorResult(output: NodeErrorOutput, port?: string): INodeResult;
|
|
678
|
+
/**
|
|
679
|
+
* Catch-block shortcut: normalize any thrown value and route it to the failure
|
|
680
|
+
* output. The one helper every node's `catch` funnels into, so the
|
|
681
|
+
* `{ code, message, status }` mapping lives in a single place instead of being
|
|
682
|
+
* re-implemented per protocol (FTP/SFTP) or per package.
|
|
683
|
+
*
|
|
684
|
+
* `port` is the output taken, `error` unless the node declares its failure
|
|
685
|
+
* output under another name (`{ ...errorPort(), name: 'failed' }`) — pass the
|
|
686
|
+
* same name here, or the branch names a port that node does not have.
|
|
687
|
+
*/
|
|
688
|
+
declare function toErrorResult(err: unknown, port?: string): INodeResult;
|
|
689
|
+
/**
|
|
690
|
+
* Catch-block shortcut for the HTTP-style nodes whose failure output additionally
|
|
691
|
+
* declares `body`: the canonical `{ code, message, status }` mapping plus the
|
|
692
|
+
* response body a {@link NodeError} carries in `meta.body` (`null` when the
|
|
693
|
+
* failure never reached a response). `port` names the output as above.
|
|
694
|
+
*/
|
|
695
|
+
declare function httpErrorResult(err: unknown, port?: string): INodeResult;
|
|
696
|
+
/**
|
|
697
|
+
* Shared `error` output port — the uniform `{ code, message, status }` triple
|
|
698
|
+
* declared on every node that has an `error` branch. Pass `body: true` for
|
|
699
|
+
* HTTP-style nodes that additionally emit a response body on the port.
|
|
700
|
+
*
|
|
701
|
+
* The sentences travel with the port. The three values mean the same thing
|
|
702
|
+
* behind every node, so they are written here once instead of per node; a node
|
|
703
|
+
* whose failures are worth naming more precisely spreads the port and replaces
|
|
704
|
+
* only its `description` (`{ ...errorPort(), description: … }`).
|
|
705
|
+
*
|
|
706
|
+
* The second sentence of the description is the rule this port exists under,
|
|
707
|
+
* and it is promised in `specs/error-handling.md`: a fault in the author's own
|
|
708
|
+
* configuration ends the run, a fault met while running is offered here.
|
|
709
|
+
*/
|
|
710
|
+
declare function errorPort(opts?: {
|
|
711
|
+
body?: boolean;
|
|
712
|
+
}): IOutputPort;
|
|
713
|
+
|
|
653
714
|
declare function extractManifest(node: INode): INodeDescription;
|
|
654
715
|
declare function extractManifests(nodes: INode[]): INodeDescription[];
|
|
655
716
|
declare function extractCredentialManifest(credential: ICredential): ICredentialDescription;
|
|
@@ -1046,4 +1107,4 @@ declare abstract class OAuth2AuthCodeCredential extends BaseCredential implement
|
|
|
1046
1107
|
test(_ctx: ICredentialContext, config: Config): Promise<ICredentialTestResult>;
|
|
1047
1108
|
}
|
|
1048
1109
|
|
|
1049
|
-
export { ApiKeyCredential, BaseCredential, BasicAuthCredential, type ConfigType, type CredentialAuthKind, type CredentialFieldType, DEFAULT_MAX_RESPONSE_BYTES, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAY_MS, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUT_MS, type DataType, type IConfigField, type IConfigFieldBase, type IConfigOption, type IConfigValidation, type ICredential, type ICredentialContext, type ICredentialDescription, type ICredentialField, type ICredentialOAuthAuthorize, type ICredentialResolveResult, type ICredentialTestResult, type IImage, type IInputPort, type INode, type INodeAuthorContext, type INodeContext, type INodeDescription, type INodeResult, type INodeState, type INodeWithIteration, type IOutputField, type IOutputPort, type IShowIfCondition, type ITemplateDescription, type ITemplateTrigger, type ImageCategory, type LocalizedString, type LookupAddress, type LookupFn, MANIFEST_VERSION, MAX_REDIRECTS, MAX_RESPONSE_BYTES, MAX_RETRY_ATTEMPTS, MAX_TIMEOUT_MS, type NodeCategory, NodeError, type NodeManifest, type NodePackageMeta, OAuth2AuthCodeCredential, OAuth2ClientCredentialsCredential, type OAuthTokenResponse, OPERATORS, type Operator, type OutputKind, type RetryHooks, type RetryPolicy, RetryableError, type SafeFetchOptions, type SafeFetchRetry, SimpleValueCredential, type TemplateLevel, type TemplateTriggerType, VALUELESS_OPERATORS, assertPublicUrl, backoffDelay, buildManifest, clampResponseBytes, evaluate, extractCredentialManifest, extractCredentialManifests, extractManifest, extractManifests, isBlockedAddress, isNodeWithIteration, isOAuthAuthorizeCredential, isOperator, maxBytesConfigField, normalizeCredentialType, normalizeLocalized, parsePackageMeta, readArrayBuffer, readJsonOrText, readText, retryConfigFields, safeFetch, settingApplies, sleepWithSignal, takesValue, timeoutConfigField, withRetry };
|
|
1110
|
+
export { ApiKeyCredential, BaseCredential, BasicAuthCredential, type ConfigType, type CredentialAuthKind, type CredentialFieldType, DEFAULT_MAX_RESPONSE_BYTES, DEFAULT_RETRY_ATTEMPTS, DEFAULT_RETRY_DELAY_MS, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUT_MS, type DataType, type IConfigField, type IConfigFieldBase, type IConfigOption, type IConfigValidation, type ICredential, type ICredentialContext, type ICredentialDescription, type ICredentialField, type ICredentialOAuthAuthorize, type ICredentialResolveResult, type ICredentialTestResult, type IImage, type IInputPort, type INode, type INodeAuthorContext, type INodeContext, type INodeDescription, type INodeResult, type INodeState, type INodeWithIteration, type IOutputField, type IOutputPort, type IShowIfCondition, type ITemplateDescription, type ITemplateTrigger, type ImageCategory, type LocalizedString, type LookupAddress, type LookupFn, MANIFEST_VERSION, MAX_REDIRECTS, MAX_RESPONSE_BYTES, MAX_RETRY_ATTEMPTS, MAX_TIMEOUT_MS, type NodeCategory, NodeError, type NodeErrorOutput, type NodeManifest, type NodePackageMeta, OAuth2AuthCodeCredential, OAuth2ClientCredentialsCredential, type OAuthTokenResponse, OPERATORS, type Operator, type OutputKind, type RetryHooks, type RetryPolicy, RetryableError, type SafeFetchOptions, type SafeFetchRetry, SimpleValueCredential, type TemplateLevel, type TemplateTriggerType, VALUELESS_OPERATORS, assertPublicUrl, backoffDelay, buildManifest, clampResponseBytes, errorPort, errorResult, evaluate, extractCredentialManifest, extractCredentialManifests, extractManifest, extractManifests, httpErrorResult, isBlockedAddress, isNodeWithIteration, isOAuthAuthorizeCredential, isOperator, maxBytesConfigField, normalizeCredentialType, normalizeLocalized, parsePackageMeta, readArrayBuffer, readJsonOrText, readText, retryConfigFields, safeFetch, settingApplies, sleepWithSignal, takesValue, timeoutConfigField, toErrorOutput, toErrorResult, withRetry };
|
package/dist/index.js
CHANGED
|
@@ -131,6 +131,76 @@ var NodeError = class extends Error {
|
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
+
// src/nodeErrors.ts
|
|
135
|
+
function toErrorOutput(err) {
|
|
136
|
+
if (err instanceof NodeError) {
|
|
137
|
+
const raw = err.meta?.["status"];
|
|
138
|
+
const status = typeof raw === "number" && Number.isFinite(raw) ? raw : 0;
|
|
139
|
+
return { code: err.code, message: err.message, status };
|
|
140
|
+
}
|
|
141
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
142
|
+
return { code: "TIMEOUT", message: "Request timed out", status: 0 };
|
|
143
|
+
}
|
|
144
|
+
if (err instanceof Error) {
|
|
145
|
+
return { code: "REQUEST_FAILED", message: err.message, status: 0 };
|
|
146
|
+
}
|
|
147
|
+
return { code: "REQUEST_FAILED", message: String(err), status: 0 };
|
|
148
|
+
}
|
|
149
|
+
function errorResult(output, port = "error") {
|
|
150
|
+
return { outputs: { [port]: output }, branch: port };
|
|
151
|
+
}
|
|
152
|
+
function toErrorResult(err, port = "error") {
|
|
153
|
+
return errorResult(toErrorOutput(err), port);
|
|
154
|
+
}
|
|
155
|
+
function httpErrorResult(err, port = "error") {
|
|
156
|
+
const body = err instanceof NodeError ? err.meta?.["body"] ?? null : null;
|
|
157
|
+
return errorResult({ ...toErrorOutput(err), body }, port);
|
|
158
|
+
}
|
|
159
|
+
function errorPort(opts = {}) {
|
|
160
|
+
return {
|
|
161
|
+
name: "error",
|
|
162
|
+
kind: "error",
|
|
163
|
+
dataType: "object",
|
|
164
|
+
label: { en: "Error", de: "Fehler" },
|
|
165
|
+
description: {
|
|
166
|
+
en: "Taken when the attempt fails in a way the workflow can carry on from. A node that cannot run as configured fails the run instead of taking this path.",
|
|
167
|
+
de: "Wird genommen, wenn der Versuch auf eine Weise fehlschl\xE4gt, mit der der Workflow weiterarbeiten kann. Ein Node, der so konfiguriert nicht laufen kann, l\xE4sst den Run scheitern, statt diesen Pfad zu nehmen."
|
|
168
|
+
},
|
|
169
|
+
fields: {
|
|
170
|
+
code: {
|
|
171
|
+
dataType: "string",
|
|
172
|
+
description: {
|
|
173
|
+
en: "Machine-readable name of the failure \u2014 branch on this rather than on the message. A node that talks to a remote system shares `TIMEOUT` and `REQUEST_FAILED` with every other one; the remaining codes belong to this node alone.",
|
|
174
|
+
de: "Maschinenlesbarer Name des Fehlers \u2014 hierauf verzweigen, nicht auf die Meldung. Ein Node, der mit einem Fremdsystem spricht, teilt `TIMEOUT` und `REQUEST_FAILED` mit allen anderen; die \xFCbrigen Codes geh\xF6ren allein zu diesem Node."
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
message: {
|
|
178
|
+
dataType: "string",
|
|
179
|
+
description: {
|
|
180
|
+
en: "Wording for whoever reads the run afterwards, frequently the wording the far end used. It is not a stable value to branch on.",
|
|
181
|
+
de: "Wortlaut f\xFCr den, der den Run sp\xE4ter liest, h\xE4ufig der des Gegen\xFCbers. Kein stabiler Wert, auf den sich Verzweigungen st\xFCtzen sollten."
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
status: {
|
|
185
|
+
dataType: "number",
|
|
186
|
+
description: {
|
|
187
|
+
en: "How the far end answered, as an HTTP status code, where one answered with a status at all. `0` otherwise \u2014 a timeout, a refused connection, an input the node could not use, a node that never leaves the workflow, or a failure the far end reported in its own answer rather than in a status, as a bulk job that ends as failed does. So `0` means there is no status to read, not that nothing was reached.",
|
|
188
|
+
de: "Wie das Gegen\xFCber geantwortet hat, als HTTP-Statuscode \u2014 sofern eines \xFCberhaupt mit einem Status geantwortet hat. Sonst `0`: Timeout, abgelehnte Verbindung, eine unbrauchbare Eingabe, ein Node, der den Workflow nicht verl\xE4sst, oder ein Fehler, den das Gegen\xFCber in seiner Antwort statt im Status gemeldet hat \u2014 wie ein Bulk-Job, der als fehlgeschlagen endet. `0` hei\xDFt also: kein Status zu lesen, nicht: nichts erreicht."
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
...opts.body ? {
|
|
192
|
+
body: {
|
|
193
|
+
dataType: "any",
|
|
194
|
+
description: {
|
|
195
|
+
en: "The answer the far end gave, where the failure got far enough to have one: the response body, or the job the platform reported as failed.",
|
|
196
|
+
de: "Die Antwort des Gegen\xFCbers, sofern der Fehler weit genug kam, um eine zu haben: der Response-Body oder der von der Plattform als fehlgeschlagen gemeldete Job."
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
} : {}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
134
204
|
// src/ssrf.ts
|
|
135
205
|
import { subscribe } from "diagnostics_channel";
|
|
136
206
|
import { isIP } from "net";
|
|
@@ -866,11 +936,14 @@ export {
|
|
|
866
936
|
backoffDelay,
|
|
867
937
|
buildManifest,
|
|
868
938
|
clampResponseBytes,
|
|
939
|
+
errorPort,
|
|
940
|
+
errorResult,
|
|
869
941
|
evaluate,
|
|
870
942
|
extractCredentialManifest,
|
|
871
943
|
extractCredentialManifests,
|
|
872
944
|
extractManifest,
|
|
873
945
|
extractManifests,
|
|
946
|
+
httpErrorResult,
|
|
874
947
|
isBlockedAddress,
|
|
875
948
|
isNodeWithIteration,
|
|
876
949
|
isOAuthAuthorizeCredential,
|
|
@@ -888,5 +961,7 @@ export {
|
|
|
888
961
|
sleepWithSignal,
|
|
889
962
|
takesValue,
|
|
890
963
|
timeoutConfigField,
|
|
964
|
+
toErrorOutput,
|
|
965
|
+
toErrorResult,
|
|
891
966
|
withRetry
|
|
892
967
|
};
|