@tailor-platform/sdk 1.44.0 → 1.44.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.
- package/CHANGELOG.md +8 -0
- package/dist/application-Cot5-3g3.mjs +4 -0
- package/dist/{application-DkVNbIuh.mjs → application-vJxYH5LE.mjs} +141 -4
- package/dist/application-vJxYH5LE.mjs.map +1 -0
- package/dist/cli/index.mjs +5 -5
- package/dist/cli/lib.d.mts +320 -1
- package/dist/cli/lib.mjs +3 -3
- package/dist/{client-DQl5NPG9.mjs → client-DcuQRqSd.mjs} +25 -12
- package/dist/client-DcuQRqSd.mjs.map +1 -0
- package/dist/{client-EI4pMzvm.mjs → client-IsYnTV5A.mjs} +1 -1
- package/dist/configure/index.d.mts +3 -3
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{crash-report-DtkFq9JF.mjs → crash-report-DQen2i_W.mjs} +1 -1
- package/dist/{crash-report-CSSrblUv.mjs → crash-report-DVZsX1bs.mjs} +2 -2
- package/dist/{crash-report-CSSrblUv.mjs.map → crash-report-DVZsX1bs.mjs.map} +1 -1
- package/dist/{index-Br4XCvX1.d.mts → index-BOfTiouP.d.mts} +5 -2
- package/dist/{runtime-l7GFD3Xg.mjs → runtime-DQqulWPm.mjs} +16 -7
- package/dist/runtime-DQqulWPm.mjs.map +1 -0
- package/dist/utils/test/index.d.mts +2 -2
- package/dist/{workflow.generated-CDCnZNkH.d.mts → workflow.generated-B7Mupf5V.d.mts} +5 -2
- package/docs/services/workflow.md +20 -0
- package/package.json +1 -1
- package/dist/application-BZRbA1pL.mjs +0 -4
- package/dist/application-DkVNbIuh.mjs.map +0 -1
- package/dist/client-DQl5NPG9.mjs.map +0 -1
- package/dist/runtime-l7GFD3Xg.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @tailor-platform/sdk
|
|
2
2
|
|
|
3
|
+
## 1.44.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1088](https://github.com/tailor-platform/sdk/pull/1088) [`6dc5318`](https://github.com/tailor-platform/sdk/commit/6dc53185418c117c65cebd92c8ee38ae406e8c9a) Thanks [@k1LoW](https://github.com/k1LoW)! - Fix workflow bundle build failure caused by dead default imports after cross-file trigger transformation
|
|
8
|
+
|
|
9
|
+
- [#1085](https://github.com/tailor-platform/sdk/pull/1085) [`0947e14`](https://github.com/tailor-platform/sdk/commit/0947e14daf39bf35b84f496984c32acb4c7bc24b) Thanks [@k1LoW](https://github.com/k1LoW)! - Add `concurrencyPolicy` option to `createWorkflow` for limiting concurrent workflow executions
|
|
10
|
+
|
|
3
11
|
## 1.44.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { u as initOAuth2Client } from "./client-
|
|
2
|
+
import { u as initOAuth2Client } from "./client-DcuQRqSd.mjs";
|
|
3
3
|
import { n as isSdkBranded } from "./brand-Ll48SMXe.mjs";
|
|
4
4
|
import { a as parseBoolean, n as logger, r as styles } from "./logger-DTNAMYGy.mjs";
|
|
5
5
|
import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "./enum-constants-C3KSpsYj.mjs";
|
|
@@ -1781,6 +1781,121 @@ function extractAuthInvokerInfo(configArg, sourceText) {
|
|
|
1781
1781
|
}
|
|
1782
1782
|
}
|
|
1783
1783
|
/**
|
|
1784
|
+
* Check if an AST binding pattern (parameter, catch clause, etc.) contains an Identifier with the given name.
|
|
1785
|
+
* @param node - AST node to inspect
|
|
1786
|
+
* @param name - Identifier name to look for
|
|
1787
|
+
* @returns True if the binding pattern contains the name
|
|
1788
|
+
*/
|
|
1789
|
+
function containsBindingName(node, name) {
|
|
1790
|
+
if (!node || typeof node !== "object") return false;
|
|
1791
|
+
if (node.type === "Identifier" && node.name === name) return true;
|
|
1792
|
+
for (const key of Object.keys(node)) {
|
|
1793
|
+
const child = node[key];
|
|
1794
|
+
if (Array.isArray(child)) {
|
|
1795
|
+
if (child.some((c) => containsBindingName(c, name))) return true;
|
|
1796
|
+
} else if (child && typeof child === "object") {
|
|
1797
|
+
if (containsBindingName(child, name)) return true;
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
return false;
|
|
1801
|
+
}
|
|
1802
|
+
/**
|
|
1803
|
+
* Build a map of reference counts for multiple identifiers in a single AST pass.
|
|
1804
|
+
* Scope-aware: references inside functions or catch clauses that shadow the name
|
|
1805
|
+
* via parameters are excluded, so only references to the original import binding
|
|
1806
|
+
* are counted.
|
|
1807
|
+
* Excludes import declarations and property names in non-computed member expressions.
|
|
1808
|
+
* @param program - The parsed AST program
|
|
1809
|
+
* @param names - Set of identifier names to count
|
|
1810
|
+
* @returns Map from identifier name to reference count
|
|
1811
|
+
*/
|
|
1812
|
+
function buildReferenceCountMap(program, names) {
|
|
1813
|
+
if (names.size === 0) return /* @__PURE__ */ new Map();
|
|
1814
|
+
const counts = /* @__PURE__ */ new Map();
|
|
1815
|
+
const shadowDepth = /* @__PURE__ */ new Map();
|
|
1816
|
+
for (const name of names) {
|
|
1817
|
+
counts.set(name, 0);
|
|
1818
|
+
shadowDepth.set(name, 0);
|
|
1819
|
+
}
|
|
1820
|
+
function walk(node, parentNode, parentKey) {
|
|
1821
|
+
if (!node || typeof node !== "object") return;
|
|
1822
|
+
const nodeType = node.type;
|
|
1823
|
+
if (nodeType === "ImportDeclaration") return;
|
|
1824
|
+
const shadowedHere = [];
|
|
1825
|
+
if (nodeType === "FunctionDeclaration" || nodeType === "FunctionExpression" || nodeType === "ArrowFunctionExpression") {
|
|
1826
|
+
const params = node.params;
|
|
1827
|
+
if (params) {
|
|
1828
|
+
for (const name of names) if (params.some((p) => containsBindingName(p, name))) {
|
|
1829
|
+
shadowDepth.set(name, (shadowDepth.get(name) ?? 0) + 1);
|
|
1830
|
+
shadowedHere.push(name);
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
if (nodeType === "CatchClause") {
|
|
1835
|
+
const param = node.param;
|
|
1836
|
+
if (param) {
|
|
1837
|
+
for (const name of names) if (containsBindingName(param, name)) {
|
|
1838
|
+
shadowDepth.set(name, (shadowDepth.get(name) ?? 0) + 1);
|
|
1839
|
+
shadowedHere.push(name);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
if (nodeType === "Identifier") {
|
|
1844
|
+
const identName = node.name;
|
|
1845
|
+
if (identName && names.has(identName) && (shadowDepth.get(identName) ?? 0) === 0) {
|
|
1846
|
+
const isMemberProperty = parentNode && parentNode.type === "MemberExpression" && parentKey === "property" && !parentNode.computed;
|
|
1847
|
+
const isObjectPropertyKey = parentNode && parentNode.type === "Property" && parentKey === "key" && !parentNode.shorthand && !parentNode.computed;
|
|
1848
|
+
if (!isMemberProperty && !isObjectPropertyKey) counts.set(identName, (counts.get(identName) ?? 0) + 1);
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
for (const key of Object.keys(node)) {
|
|
1852
|
+
const child = node[key];
|
|
1853
|
+
if (Array.isArray(child)) child.forEach((c) => walk(c, node, key));
|
|
1854
|
+
else if (child && typeof child === "object") walk(child, node, key);
|
|
1855
|
+
}
|
|
1856
|
+
for (const name of shadowedHere) shadowDepth.set(name, (shadowDepth.get(name) ?? 0) - 1);
|
|
1857
|
+
}
|
|
1858
|
+
walk(program);
|
|
1859
|
+
return counts;
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* Find the text range to remove for a dead default import.
|
|
1863
|
+
*
|
|
1864
|
+
* - Default-only import (`import wf from "..."`): returns the full declaration range.
|
|
1865
|
+
* - Mixed import (`import wf, { helper } from "..."`): returns the range covering
|
|
1866
|
+
* the default specifier and trailing comma/whitespace so the result becomes
|
|
1867
|
+
* `import { helper } from "..."`.
|
|
1868
|
+
* @param program - The parsed AST program
|
|
1869
|
+
* @param localName - The local name of the default import
|
|
1870
|
+
* @param source - The source code text (used to locate the `{` in mixed imports)
|
|
1871
|
+
* @returns Range to remove, or null if the import was not found
|
|
1872
|
+
*/
|
|
1873
|
+
function findDefaultImportRemovalRange(program, localName, source) {
|
|
1874
|
+
for (const statement of program.body) {
|
|
1875
|
+
if (statement.type !== "ImportDeclaration") continue;
|
|
1876
|
+
const importDecl = statement;
|
|
1877
|
+
const specifiers = importDecl.specifiers || [];
|
|
1878
|
+
for (const spec of specifiers) {
|
|
1879
|
+
if (spec.type !== "ImportDefaultSpecifier") continue;
|
|
1880
|
+
const defaultSpec = spec;
|
|
1881
|
+
if (defaultSpec.local?.name !== localName) continue;
|
|
1882
|
+
if (specifiers.length === 1) return {
|
|
1883
|
+
start: importDecl.start,
|
|
1884
|
+
end: importDecl.end,
|
|
1885
|
+
isFullDeclaration: true
|
|
1886
|
+
};
|
|
1887
|
+
const braceIndex = source.indexOf("{", defaultSpec.end);
|
|
1888
|
+
if (braceIndex !== -1) return {
|
|
1889
|
+
start: defaultSpec.start,
|
|
1890
|
+
end: braceIndex,
|
|
1891
|
+
isFullDeclaration: false
|
|
1892
|
+
};
|
|
1893
|
+
return null;
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
return null;
|
|
1897
|
+
}
|
|
1898
|
+
/**
|
|
1784
1899
|
* Detect .trigger() calls for known workflows and jobs
|
|
1785
1900
|
* Only detects calls where the identifier is in workflowNames or jobNames
|
|
1786
1901
|
* @param program - The parsed AST program
|
|
@@ -1866,6 +1981,7 @@ function detectExtendedTriggerCalls(program, sourceText, workflowNames, jobNames
|
|
|
1866
1981
|
function transformFunctionTriggers(source, workflowNameMap, jobNameMap, workflowFileMap, currentFilePath, authNamespace) {
|
|
1867
1982
|
const { program } = parseSync("input.ts", source);
|
|
1868
1983
|
const localWorkflowNameMap = new Map(workflowNameMap);
|
|
1984
|
+
const workflowDefaultImportNames = /* @__PURE__ */ new Set();
|
|
1869
1985
|
if (workflowFileMap && currentFilePath) {
|
|
1870
1986
|
const defaultImports = detectDefaultImports(program);
|
|
1871
1987
|
const currentDir = currentFilePath.replace(/[/\\][^/\\]+$/, "");
|
|
@@ -1873,12 +1989,16 @@ function transformFunctionTriggers(source, workflowNameMap, jobNameMap, workflow
|
|
|
1873
1989
|
if (!importSource.startsWith(".")) continue;
|
|
1874
1990
|
const resolvedPath = resolvePath(currentDir, importSource);
|
|
1875
1991
|
const workflowName = workflowFileMap.get(resolvedPath);
|
|
1876
|
-
if (workflowName)
|
|
1992
|
+
if (workflowName) {
|
|
1993
|
+
localWorkflowNameMap.set(localName, workflowName);
|
|
1994
|
+
workflowDefaultImportNames.add(localName);
|
|
1995
|
+
}
|
|
1877
1996
|
}
|
|
1878
1997
|
}
|
|
1879
1998
|
const triggerCalls = detectExtendedTriggerCalls(program, source, new Set(localWorkflowNameMap.keys()), new Set(jobNameMap.keys()));
|
|
1880
1999
|
const replacements = [];
|
|
1881
2000
|
let needsNormalizerHelper = false;
|
|
2001
|
+
const transformedCallsPerIdentifier = /* @__PURE__ */ new Map();
|
|
1882
2002
|
for (const call of triggerCalls) if (call.kind === "workflow" && call.authInvoker) {
|
|
1883
2003
|
const workflowName = localWorkflowNameMap.get(call.identifierName);
|
|
1884
2004
|
if (workflowName) {
|
|
@@ -1894,6 +2014,7 @@ function transformFunctionTriggers(source, workflowNameMap, jobNameMap, workflow
|
|
|
1894
2014
|
end: call.callRange.end,
|
|
1895
2015
|
text: transformedCall
|
|
1896
2016
|
});
|
|
2017
|
+
transformedCallsPerIdentifier.set(call.identifierName, (transformedCallsPerIdentifier.get(call.identifierName) ?? 0) + 1);
|
|
1897
2018
|
}
|
|
1898
2019
|
} else if (call.kind === "job") {
|
|
1899
2020
|
const jobName = jobNameMap.get(call.identifierName);
|
|
@@ -1905,6 +2026,20 @@ function transformFunctionTriggers(source, workflowNameMap, jobNameMap, workflow
|
|
|
1905
2026
|
end: range.end,
|
|
1906
2027
|
text: transformedCall
|
|
1907
2028
|
});
|
|
2029
|
+
transformedCallsPerIdentifier.set(call.identifierName, (transformedCallsPerIdentifier.get(call.identifierName) ?? 0) + 1);
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
const refCounts = buildReferenceCountMap(program, workflowDefaultImportNames);
|
|
2033
|
+
for (const localName of workflowDefaultImportNames) {
|
|
2034
|
+
const transformedCount = transformedCallsPerIdentifier.get(localName) ?? 0;
|
|
2035
|
+
const refCount = refCounts.get(localName) ?? 0;
|
|
2036
|
+
if (refCount === 0 || transformedCount >= refCount) {
|
|
2037
|
+
const removal = findDefaultImportRemovalRange(program, localName, source);
|
|
2038
|
+
if (removal) replacements.push({
|
|
2039
|
+
start: removal.start,
|
|
2040
|
+
end: removal.isFullDeclaration ? findStatementEnd(source, removal.end) : removal.end,
|
|
2041
|
+
text: ""
|
|
2042
|
+
});
|
|
1908
2043
|
}
|
|
1909
2044
|
}
|
|
1910
2045
|
const transformed = applyReplacements(source, replacements);
|
|
@@ -4527,10 +4662,12 @@ const RetryPolicySchema = z.object({
|
|
|
4527
4662
|
message: "initialBackoff must be greater than 0",
|
|
4528
4663
|
path: ["initialBackoff"]
|
|
4529
4664
|
});
|
|
4665
|
+
const ConcurrencyPolicySchema = z.object({ maxConcurrentExecutions: z.number().int().min(1).max(1e3).describe("Maximum number of concurrent executions (1-1000)") });
|
|
4530
4666
|
const WorkflowSchema = z.object({
|
|
4531
4667
|
name: z.string().describe("Workflow name"),
|
|
4532
4668
|
mainJob: WorkflowJobSchema.describe("Main job that starts the workflow"),
|
|
4533
|
-
retryPolicy: RetryPolicySchema.optional().describe("Retry policy for the workflow")
|
|
4669
|
+
retryPolicy: RetryPolicySchema.optional().describe("Retry policy for the workflow"),
|
|
4670
|
+
concurrencyPolicy: ConcurrencyPolicySchema.optional().describe("Concurrency policy for the workflow")
|
|
4534
4671
|
});
|
|
4535
4672
|
|
|
4536
4673
|
//#endregion
|
|
@@ -5167,4 +5304,4 @@ async function loadApplication(params) {
|
|
|
5167
5304
|
|
|
5168
5305
|
//#endregion
|
|
5169
5306
|
export { loadWorkspaceId as C, writePlatformConfig as D, saveUserTokens as E, loadAccessToken as S, resolveTokens as T, getDistDir as _, WorkflowJobSchema as a, deleteUserTokens as b, ExecutorSchema as c, buildResolverOperationHookExpr as d, OAuth2ClientSchema as f, createBundleCache as g, loadFilesWithIgnores as h, resolveInlineSourcemap as i, INVOKER_EXPR as l, stringifyFunction as m, generatePluginFilesIfNeeded as n, ResolverSchema as o, TailorDBTypeSchema as p, loadApplication as r, createExecutorService as s, defineApplication as t, buildExecutorArgsExpr as u, hashFile as v, readPlatformConfig as w, fetchLatestToken as x, loadConfig as y };
|
|
5170
|
-
//# sourceMappingURL=application-
|
|
5307
|
+
//# sourceMappingURL=application-vJxYH5LE.mjs.map
|