assistsx-js 0.2.2 → 0.2.3
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/README.md +46 -0
- package/dist/index.cjs +52 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +580 -1752
- package/dist/index.d.ts +580 -1752
- package/dist/index.global.js +3 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +51 -10
- package/dist/index.js.map +1 -1
- package/dist/step-DnFA4DEb.d.mts +1196 -0
- package/dist/step-DnFA4DEb.d.ts +1196 -0
- package/dist/step-flow/index.cjs +4367 -0
- package/dist/step-flow/index.cjs.map +1 -0
- package/dist/step-flow/index.d.mts +83 -0
- package/dist/step-flow/index.d.ts +83 -0
- package/dist/step-flow/index.js +4331 -0
- package/dist/step-flow/index.js.map +1 -0
- package/package.json +6 -1
- package/src/index.ts +1 -0
- package/src/log/log.ts +20 -0
- package/src/pinia-ensure.ts +15 -0
- package/src/step-flow/index.ts +5 -0
- package/src/step-flow/legacy-handoff.ts +50 -0
- package/src/step-flow/outcome.ts +16 -0
- package/src/step-flow/payload.ts +23 -0
- package/src/step-flow/runner.ts +128 -0
- package/src/step-flow/types.ts +41 -0
- package/src/step.ts +48 -14
package/dist/index.js
CHANGED
|
@@ -1407,6 +1407,17 @@ var useStepStore = defineStore("step", {
|
|
|
1407
1407
|
}
|
|
1408
1408
|
});
|
|
1409
1409
|
|
|
1410
|
+
// src/pinia-ensure.ts
|
|
1411
|
+
import { createPinia, getActivePinia, setActivePinia } from "pinia";
|
|
1412
|
+
var fallbackPinia = null;
|
|
1413
|
+
function ensureAssistsXPinia() {
|
|
1414
|
+
if (getActivePinia() !== void 0) return;
|
|
1415
|
+
if (fallbackPinia === null) {
|
|
1416
|
+
fallbackPinia = createPinia();
|
|
1417
|
+
}
|
|
1418
|
+
setActivePinia(fallbackPinia);
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1410
1421
|
// src/step-error.ts
|
|
1411
1422
|
var StepError = class extends Error {
|
|
1412
1423
|
constructor(message, data, impl, tag, originalError, currentStep) {
|
|
@@ -1768,13 +1779,31 @@ var _Step = class _Step {
|
|
|
1768
1779
|
this.delayMs = _Step.delayMsDefault;
|
|
1769
1780
|
this.tag = tag;
|
|
1770
1781
|
this.stepId = stepId;
|
|
1771
|
-
this.data = data
|
|
1782
|
+
this.data = _Step.resolveStepData(data);
|
|
1772
1783
|
this.impl = impl;
|
|
1773
1784
|
this.delayMs = delayMs;
|
|
1774
1785
|
this.repeatCountMax = repeatCountMax;
|
|
1775
1786
|
this.exceptionRetryCountMax = exceptionRetryCountMax;
|
|
1776
1787
|
this.isEnd = isEnd;
|
|
1777
1788
|
}
|
|
1789
|
+
/**
|
|
1790
|
+
* 判断步骤数据是否有效(非空且为普通对象)
|
|
1791
|
+
*/
|
|
1792
|
+
static isValidStepData(data) {
|
|
1793
|
+
return data !== null && data !== void 0 && typeof data === "object" && !Array.isArray(data);
|
|
1794
|
+
}
|
|
1795
|
+
/**
|
|
1796
|
+
* 解析步骤数据:优先使用传入值,否则使用当前值,均无效时返回空对象
|
|
1797
|
+
*/
|
|
1798
|
+
static resolveStepData(provided, fallback) {
|
|
1799
|
+
if (provided !== void 0 && _Step.isValidStepData(provided)) {
|
|
1800
|
+
return provided;
|
|
1801
|
+
}
|
|
1802
|
+
if (fallback !== void 0 && _Step.isValidStepData(fallback)) {
|
|
1803
|
+
return fallback;
|
|
1804
|
+
}
|
|
1805
|
+
return {};
|
|
1806
|
+
}
|
|
1778
1807
|
/**
|
|
1779
1808
|
* 运行步骤实现
|
|
1780
1809
|
* @param impl 步骤实现函数
|
|
@@ -1791,7 +1820,9 @@ var _Step = class _Step {
|
|
|
1791
1820
|
} = {}) {
|
|
1792
1821
|
var _a2, _b, _c, _d, _e, _f;
|
|
1793
1822
|
this.exception = void 0;
|
|
1823
|
+
ensureAssistsXPinia();
|
|
1794
1824
|
const stepStore = useStepStore();
|
|
1825
|
+
const resolvedData = _Step.resolveStepData(data);
|
|
1795
1826
|
let implnName = impl.name;
|
|
1796
1827
|
let currentStep;
|
|
1797
1828
|
let nextStep;
|
|
@@ -1807,12 +1838,12 @@ var _Step = class _Step {
|
|
|
1807
1838
|
console.log(`\u751F\u6210\u6B65\u9AA4ID: ${this._stepId}`);
|
|
1808
1839
|
}
|
|
1809
1840
|
}
|
|
1810
|
-
stepStore.startStep(this._stepId, tag,
|
|
1841
|
+
stepStore.startStep(this._stepId, tag, resolvedData);
|
|
1811
1842
|
currentStep = new _Step({
|
|
1812
1843
|
stepId: this._stepId,
|
|
1813
1844
|
impl,
|
|
1814
1845
|
tag,
|
|
1815
|
-
data,
|
|
1846
|
+
data: resolvedData,
|
|
1816
1847
|
delayMs,
|
|
1817
1848
|
exceptionRetryCountMax
|
|
1818
1849
|
});
|
|
@@ -1921,7 +1952,7 @@ var _Step = class _Step {
|
|
|
1921
1952
|
const errorMsg = JSON.stringify({
|
|
1922
1953
|
impl: implnName,
|
|
1923
1954
|
tag,
|
|
1924
|
-
data,
|
|
1955
|
+
data: resolvedData,
|
|
1925
1956
|
error: (_f = e == null ? void 0 : e.message) != null ? _f : String(e)
|
|
1926
1957
|
});
|
|
1927
1958
|
stepStore.setError(errorMsg);
|
|
@@ -2064,13 +2095,12 @@ var _Step = class _Step {
|
|
|
2064
2095
|
repeatCountMax = _Step.repeatCountMaxDefault,
|
|
2065
2096
|
exceptionRetryCountMax = _Step.exceptionRetryCountMaxDefault
|
|
2066
2097
|
} = {}) {
|
|
2067
|
-
var _a2;
|
|
2068
2098
|
_Step.assert(this.stepId);
|
|
2069
2099
|
return new _Step({
|
|
2070
2100
|
stepId: this.stepId,
|
|
2071
2101
|
impl,
|
|
2072
2102
|
tag,
|
|
2073
|
-
data: (
|
|
2103
|
+
data: _Step.resolveStepData(data, this.data),
|
|
2074
2104
|
delayMs,
|
|
2075
2105
|
repeatCountMax,
|
|
2076
2106
|
exceptionRetryCountMax
|
|
@@ -2083,13 +2113,12 @@ var _Step = class _Step {
|
|
|
2083
2113
|
repeatCountMax = _Step.repeatCountMaxDefault,
|
|
2084
2114
|
exceptionRetryCountMax = _Step.exceptionRetryCountMaxDefault
|
|
2085
2115
|
} = {}) {
|
|
2086
|
-
var _a2;
|
|
2087
2116
|
_Step.assert(this.stepId);
|
|
2088
2117
|
return new _Step({
|
|
2089
2118
|
stepId: this.stepId,
|
|
2090
2119
|
impl: void 0,
|
|
2091
2120
|
tag,
|
|
2092
|
-
data: (
|
|
2121
|
+
data: _Step.resolveStepData(data, this.data),
|
|
2093
2122
|
delayMs,
|
|
2094
2123
|
repeatCountMax,
|
|
2095
2124
|
exceptionRetryCountMax,
|
|
@@ -2107,7 +2136,7 @@ var _Step = class _Step {
|
|
|
2107
2136
|
repeat({
|
|
2108
2137
|
stepId = this.stepId,
|
|
2109
2138
|
tag = this.tag,
|
|
2110
|
-
data
|
|
2139
|
+
data,
|
|
2111
2140
|
delayMs = this.delayMs,
|
|
2112
2141
|
repeatCountMax = this.repeatCountMax,
|
|
2113
2142
|
exceptionRetryCountMax = this.exceptionRetryCountMax
|
|
@@ -2116,7 +2145,7 @@ var _Step = class _Step {
|
|
|
2116
2145
|
this.repeatCount++;
|
|
2117
2146
|
this.stepId = stepId;
|
|
2118
2147
|
this.tag = tag;
|
|
2119
|
-
this.data = data;
|
|
2148
|
+
this.data = _Step.resolveStepData(data, this.data);
|
|
2120
2149
|
this.delayMs = delayMs;
|
|
2121
2150
|
this.repeatCountMax = repeatCountMax;
|
|
2122
2151
|
this.exceptionRetryCountMax = exceptionRetryCountMax;
|
|
@@ -7736,6 +7765,17 @@ var Log = class {
|
|
|
7736
7765
|
);
|
|
7737
7766
|
return res.isSuccess();
|
|
7738
7767
|
}
|
|
7768
|
+
/**
|
|
7769
|
+
* 追加日志(appendTimestampedEntry / appendLine 简写)。
|
|
7770
|
+
* 默认带时间戳;`timestamped: false` 时走 appendLine。
|
|
7771
|
+
*/
|
|
7772
|
+
async append(text, options) {
|
|
7773
|
+
const { timestamped = true, maxLength, timeout } = options != null ? options : {};
|
|
7774
|
+
if (timestamped) {
|
|
7775
|
+
return this.appendTimestampedEntry(text, timeout);
|
|
7776
|
+
}
|
|
7777
|
+
return this.appendLine(text, maxLength, timeout);
|
|
7778
|
+
}
|
|
7739
7779
|
/** 替换全部内容 */
|
|
7740
7780
|
async replaceAll(content, timeout) {
|
|
7741
7781
|
const res = await this.asyncCall(
|
|
@@ -7941,6 +7981,7 @@ export {
|
|
|
7941
7981
|
barUtils,
|
|
7942
7982
|
callbacks,
|
|
7943
7983
|
decodeBase64UTF8,
|
|
7984
|
+
ensureAssistsXPinia,
|
|
7944
7985
|
fileIO,
|
|
7945
7986
|
fileUtils,
|
|
7946
7987
|
float,
|