@ductape/sdk 0.1.149 → 0.1.151
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/database/actions/action-manager.d.ts +4 -0
- package/dist/database/actions/action-manager.js +47 -4
- package/dist/database/actions/action-manager.js.map +1 -1
- package/dist/database/databases.service.js +16 -10
- package/dist/database/databases.service.js.map +1 -1
- package/dist/features/feature-executor.d.ts +2 -0
- package/dist/features/feature-executor.js +34 -27
- package/dist/features/feature-executor.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +2 -2
- package/dist/resilience/fallback.service.js +1 -1
- package/dist/resilience/fallback.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vector/vector-database.service.d.ts +3 -0
- package/dist/vector/vector-database.service.js +47 -0
- package/dist/vector/vector-database.service.js.map +1 -1
- package/package.json +2 -3
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
var _a, _b, _c, _d;
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.FeatureExecutor = exports.UnresolvedInputReferenceError = void 0;
|
|
16
|
+
exports.FeatureExecutor = exports.assertSuccessfulStepOutput = exports.UnresolvedInputReferenceError = void 0;
|
|
17
17
|
const crypto_1 = require("crypto");
|
|
18
18
|
const processor_service_1 = __importDefault(require("../processor/services/processor.service"));
|
|
19
19
|
const products_service_1 = __importDefault(require("../products/services/products.service"));
|
|
@@ -110,6 +110,22 @@ const stringifyProcessorValue = (value) => {
|
|
|
110
110
|
return nested;
|
|
111
111
|
});
|
|
112
112
|
};
|
|
113
|
+
/** Convert explicit SDK failure envelopes into thrown step failures. */
|
|
114
|
+
const assertSuccessfulStepOutput = (output, stepTag) => {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
if (!output || typeof output !== 'object' || Array.isArray(output))
|
|
117
|
+
return;
|
|
118
|
+
const result = output;
|
|
119
|
+
const status = typeof result.status === 'string' ? result.status.toLowerCase() : '';
|
|
120
|
+
const failedStatus = ['fail', 'failed', 'failure', 'rolled_back', 'cancelled', 'canceled'].includes(status);
|
|
121
|
+
const explicitFailure = result.failed_execution === true || failedStatus;
|
|
122
|
+
const unsuccessfulWithError = (result.success === false || result.ok === false) && result.error != null;
|
|
123
|
+
if (!explicitFailure && !unsuccessfulWithError)
|
|
124
|
+
return;
|
|
125
|
+
const detail = (_b = (_a = result.error) !== null && _a !== void 0 ? _a : result.message) !== null && _b !== void 0 ? _b : `returned status '${status || 'failed'}'`;
|
|
126
|
+
throw new Error(`Step '${stepTag}' failed: ${String(detail)}`);
|
|
127
|
+
};
|
|
128
|
+
exports.assertSuccessfulStepOutput = assertSuccessfulStepOutput;
|
|
113
129
|
/** Normalize error to a string and extract HTTP details when present (e.g. Axios) */
|
|
114
130
|
function formatErrorDetails(error) {
|
|
115
131
|
var _a, _b, _c, _d;
|
|
@@ -927,6 +943,7 @@ class FeatureExecutor {
|
|
|
927
943
|
return value;
|
|
928
944
|
};
|
|
929
945
|
let output = asset ? await (0, context_1.withAssetSpan)(asset, runOperation) : await runOperation();
|
|
946
|
+
(0, exports.assertSuccessfulStepOutput)(output, step.tag);
|
|
930
947
|
// For action steps with no app: if step.output is a template with $ refs (e.g. $Sequence{main}{step-a}{value}-b),
|
|
931
948
|
// resolve it so downstream steps get the correct value (checkpoint / closure-style steps).
|
|
932
949
|
if (step.type === types_1.FeatureStepType.ACTION &&
|
|
@@ -1072,7 +1089,7 @@ class FeatureExecutor {
|
|
|
1072
1089
|
const action = ((_b = step.event) === null || _b === void 0 ? void 0 : _b.startsWith(`${database}:`))
|
|
1073
1090
|
? step.event.slice(database.length + 1)
|
|
1074
1091
|
: step.event;
|
|
1075
|
-
|
|
1092
|
+
const result = await db.execute({
|
|
1076
1093
|
product,
|
|
1077
1094
|
env,
|
|
1078
1095
|
database,
|
|
@@ -1080,6 +1097,17 @@ class FeatureExecutor {
|
|
|
1080
1097
|
input: input,
|
|
1081
1098
|
session: this.inheritedSession,
|
|
1082
1099
|
});
|
|
1100
|
+
if (result &&
|
|
1101
|
+
typeof result === 'object' &&
|
|
1102
|
+
'action' in result &&
|
|
1103
|
+
'resolvedTemplate' in result &&
|
|
1104
|
+
('message' in result
|
|
1105
|
+
? /actual execution|processorservice|direct adapter/i.test(String(result.message))
|
|
1106
|
+
: false)) {
|
|
1107
|
+
throw new Error(`Database action '${database}:${action}' returned an execution preview instead of a database result. ` +
|
|
1108
|
+
'Upgrade @ductape/sdk and restart the application process; previews cannot be accepted as successful Feature steps.');
|
|
1109
|
+
}
|
|
1110
|
+
return result;
|
|
1083
1111
|
}
|
|
1084
1112
|
}
|
|
1085
1113
|
/**
|
|
@@ -1245,7 +1273,7 @@ class FeatureExecutor {
|
|
|
1245
1273
|
* Execute a vector step (query, upsert, deleteVectors, or custom action via execute).
|
|
1246
1274
|
*/
|
|
1247
1275
|
async executeVectorStep(step, input) {
|
|
1248
|
-
var _a, _b, _c
|
|
1276
|
+
var _a, _b, _c;
|
|
1249
1277
|
const vectorTag = step.vector;
|
|
1250
1278
|
if (!vectorTag) {
|
|
1251
1279
|
throw new Error(`Vector step "${step.tag}" has no vector tag`);
|
|
@@ -1279,8 +1307,7 @@ class FeatureExecutor {
|
|
|
1279
1307
|
return result;
|
|
1280
1308
|
}
|
|
1281
1309
|
default: {
|
|
1282
|
-
|
|
1283
|
-
const resolved = await svc.actions.resolve({
|
|
1310
|
+
return svc.executeAction({
|
|
1284
1311
|
product,
|
|
1285
1312
|
env,
|
|
1286
1313
|
vector: vectorTag,
|
|
@@ -1288,18 +1315,6 @@ class FeatureExecutor {
|
|
|
1288
1315
|
input: input,
|
|
1289
1316
|
session: this.inheritedSession,
|
|
1290
1317
|
});
|
|
1291
|
-
const op = (_d = resolved === null || resolved === void 0 ? void 0 : resolved._operation) !== null && _d !== void 0 ? _d : resolved === null || resolved === void 0 ? void 0 : resolved.operation;
|
|
1292
|
-
const opts = Object.assign(Object.assign({ product, env, tag: vectorTag }, resolved), { session: (_e = resolved.session) !== null && _e !== void 0 ? _e : this.inheritedSession });
|
|
1293
|
-
if (op === 'query' || !op) {
|
|
1294
|
-
return svc.query(opts);
|
|
1295
|
-
}
|
|
1296
|
-
if (op === 'upsert') {
|
|
1297
|
-
return svc.upsert(opts);
|
|
1298
|
-
}
|
|
1299
|
-
if (op === 'delete' || op === 'deleteVectors') {
|
|
1300
|
-
return svc.deleteVectors(opts);
|
|
1301
|
-
}
|
|
1302
|
-
return svc.query(opts);
|
|
1303
1318
|
}
|
|
1304
1319
|
}
|
|
1305
1320
|
}
|
|
@@ -1706,7 +1721,7 @@ class FeatureExecutor {
|
|
|
1706
1721
|
* Execute a rollback handler
|
|
1707
1722
|
*/
|
|
1708
1723
|
async executeRollbackHandler(rollback, stepOutput) {
|
|
1709
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
1724
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1710
1725
|
if (!rollback)
|
|
1711
1726
|
return;
|
|
1712
1727
|
debugLog('[FeatureExecutor] executeRollbackHandler', { feature_id: this.state.feature_id, rollback_type: rollback.type });
|
|
@@ -1798,7 +1813,7 @@ class FeatureExecutor {
|
|
|
1798
1813
|
await svc.deleteVectors(Object.assign(Object.assign({ product, env, tag: vectorTag }, inp), { session: (_k = inp.session) !== null && _k !== void 0 ? _k : this.inheritedSession }));
|
|
1799
1814
|
}
|
|
1800
1815
|
else {
|
|
1801
|
-
|
|
1816
|
+
await svc.executeAction({
|
|
1802
1817
|
product,
|
|
1803
1818
|
env,
|
|
1804
1819
|
vector: vectorTag,
|
|
@@ -1806,14 +1821,6 @@ class FeatureExecutor {
|
|
|
1806
1821
|
input: inp,
|
|
1807
1822
|
session: this.inheritedSession,
|
|
1808
1823
|
});
|
|
1809
|
-
const op = (_l = resolved === null || resolved === void 0 ? void 0 : resolved._operation) !== null && _l !== void 0 ? _l : resolved === null || resolved === void 0 ? void 0 : resolved.operation;
|
|
1810
|
-
const opts = Object.assign(Object.assign({ product, env, tag: vectorTag }, resolved), { session: (_m = resolved.session) !== null && _m !== void 0 ? _m : this.inheritedSession });
|
|
1811
|
-
if (op === 'upsert')
|
|
1812
|
-
await svc.upsert(opts);
|
|
1813
|
-
else if (op === 'delete' || op === 'deleteVectors')
|
|
1814
|
-
await svc.deleteVectors(opts);
|
|
1815
|
-
else
|
|
1816
|
-
await svc.query(opts);
|
|
1817
1824
|
}
|
|
1818
1825
|
break;
|
|
1819
1826
|
}
|