@teleporthq/teleport-plugin-next-workflows 0.43.38 → 0.43.39
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/__tests__/resolve-handler-entry-name.test.ts +130 -0
- package/dist/cjs/nodes/types.d.ts.map +1 -1
- package/dist/cjs/nodes/types.js +51 -7
- package/dist/cjs/nodes/types.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/nodes/types.d.ts.map +1 -1
- package/dist/esm/nodes/types.js +51 -7
- package/dist/esm/nodes/types.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/nodes/types.ts +50 -7
package/dist/esm/nodes/types.js
CHANGED
|
@@ -25,13 +25,57 @@ export function resolveHandlerEntryName(source, nodeType) {
|
|
|
25
25
|
if (conventionNameUsed) {
|
|
26
26
|
return conventionName;
|
|
27
27
|
}
|
|
28
|
-
// `source` came from `handlerToString(fn)` on a real,
|
|
29
|
-
// function
|
|
30
|
-
//
|
|
31
|
-
// the
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
// `source` came from `handlerToString(fn)`/`fn.toString()` on a real,
|
|
29
|
+
// possibly-minified function, and may be concatenated with OTHER
|
|
30
|
+
// `.toString()`'d functions:
|
|
31
|
+
// - payment-charge-user.ts puts the entry FIRST, its own helpers after
|
|
32
|
+
// (`handlerToString(payment_charge_user) + '\n' + chargeWithStripe.toString() + ...`).
|
|
33
|
+
// - ai-custom-prompt.ts puts shared AI-provider utils BEFORE the entry
|
|
34
|
+
// (`generateAIProviderUtils() + '\n\n' + ai_custom_prompt.toString()`),
|
|
35
|
+
// where each util is `wrapWithGuard`-wrapped: `var X = typeof X !==
|
|
36
|
+
// 'undefined' ? X : function Y() {...};` — a function EXPRESSION
|
|
37
|
+
// embedded in a ternary, not a statement-level declaration.
|
|
38
|
+
// So the entry is not reliably first or last by position across handlers,
|
|
39
|
+
// and helper functions can outnumber (or precede) the entry. What IS
|
|
40
|
+
// reliable: every real entry point has exactly the HandlerFn signature —
|
|
41
|
+
// 2 params (config, context) or 3 (config, context, streamCallback) — by
|
|
42
|
+
// contract, while a handler's OWN internal helpers only coincidentally
|
|
43
|
+
// share that arity (e.g. general-rate-limiter's __checkRateLimit takes 3
|
|
44
|
+
// params too). So: collect every statement-level function declaration
|
|
45
|
+
// (skipping ternary-embedded expressions like wrapWithGuard's), and prefer
|
|
46
|
+
// an exactly-2-param candidate, then an exactly-3-param one, falling back
|
|
47
|
+
// to positional order only if nothing matches the entry-point arity.
|
|
48
|
+
const declPattern = /(?:async\s+)?function\s+([A-Za-z0-9_$]+)\s*\(([^)]*)\)/g;
|
|
49
|
+
const candidates = [];
|
|
50
|
+
let twoParamCandidate;
|
|
51
|
+
let threeParamCandidate;
|
|
52
|
+
let declMatch = declPattern.exec(source);
|
|
53
|
+
while (declMatch !== null) {
|
|
54
|
+
const precedingNonSpace = source.slice(0, declMatch.index).trimEnd().slice(-1);
|
|
55
|
+
if (precedingNonSpace === ':' || precedingNonSpace === '?') {
|
|
56
|
+
declMatch = declPattern.exec(source);
|
|
57
|
+
continue; // function EXPRESSION embedded in a ternary (e.g. wrapWithGuard's re-declaration guard)
|
|
58
|
+
}
|
|
59
|
+
const name = declMatch[1];
|
|
60
|
+
candidates.push(name);
|
|
61
|
+
const params = declMatch[2].trim();
|
|
62
|
+
const paramCount = params === '' ? 0 : params.split(',').length;
|
|
63
|
+
if (paramCount === 2 && twoParamCandidate === undefined) {
|
|
64
|
+
twoParamCandidate = name;
|
|
65
|
+
}
|
|
66
|
+
else if (paramCount === 3 && threeParamCandidate === undefined) {
|
|
67
|
+
threeParamCandidate = name;
|
|
68
|
+
}
|
|
69
|
+
declMatch = declPattern.exec(source);
|
|
70
|
+
}
|
|
71
|
+
if (twoParamCandidate !== undefined) {
|
|
72
|
+
return twoParamCandidate;
|
|
73
|
+
}
|
|
74
|
+
if (threeParamCandidate !== undefined) {
|
|
75
|
+
return threeParamCandidate;
|
|
76
|
+
}
|
|
77
|
+
if (candidates.length > 0) {
|
|
78
|
+
return candidates[0];
|
|
35
79
|
}
|
|
36
80
|
throw new Error(`Could not resolve the entry function for workflow node type "${nodeType}" — ` +
|
|
37
81
|
`expected a "${conventionName}" declaration or a single toString()'d function, found neither.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/nodes/types.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,EAAa;IAC3C,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAA;AACtB,CAAC;AAED,4EAA4E;AAC5E,sDAAsD;AACtD,iDAAiD;AACjD,EAAE;AACF,qEAAqE;AACrE,0EAA0E;AAC1E,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,4EAA4E;AAC5E,wEAAwE;AACxE,gEAAgE;AAChE,yDAAyD;AACzD,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,4EAA4E;AAC5E,MAAM,UAAU,uBAAuB,CAAC,MAAc,EAAE,QAAgB;IACtE,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAClD,MAAM,kBAAkB,GAAG,IAAI,MAAM,CAAC,gBAAgB,cAAc,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3F,IAAI,kBAAkB,EAAE;QACtB,OAAO,cAAc,CAAA;KACtB;IAED,wEAAwE;IACxE,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/nodes/types.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,EAAa;IAC3C,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAA;AACtB,CAAC;AAED,4EAA4E;AAC5E,sDAAsD;AACtD,iDAAiD;AACjD,EAAE;AACF,qEAAqE;AACrE,0EAA0E;A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