@brandboostinggmbh/observable-workflows 0.3.1 → 0.3.2
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.d.ts +7 -4
- package/dist/index.js +6 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
//#region src/observableWorkflows/createStepContext.d.ts
|
|
2
|
-
declare function createStepContext(context: StepContextOptions): Promise<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
declare function createStepContext(context: StepContextOptions): Promise<{
|
|
3
|
+
<RESULT>(stepName: string, callback: (ctx: StepCtx) => Promise<RESULT>): Promise<RESULT>;
|
|
4
|
+
<RESULT>(step: {
|
|
5
|
+
name: string;
|
|
6
|
+
metadata?: Record<string, any>;
|
|
7
|
+
}, callback: (ctx: StepCtx) => Promise<RESULT>): Promise<RESULT>;
|
|
8
|
+
}>;
|
|
6
9
|
|
|
7
10
|
//#endregion
|
|
8
11
|
//#region src/observableWorkflows/helperFunctions.d.ts
|
package/dist/index.js
CHANGED
|
@@ -192,11 +192,13 @@ async function createStepContext(context) {
|
|
|
192
192
|
const instanceId = context.instanceId;
|
|
193
193
|
await ensureTables(context.D1);
|
|
194
194
|
const step = async (step$1, callback) => {
|
|
195
|
+
const stepNameParam = typeof step$1 === "string" ? step$1 : step$1.name;
|
|
196
|
+
const stepMetadataParam = typeof step$1 === "string" ? void 0 : step$1.metadata;
|
|
195
197
|
if (context.parentInstanceId) {
|
|
196
198
|
const existingStep = await context.D1.prepare(
|
|
197
199
|
/* sql */
|
|
198
200
|
`SELECT * FROM StepTable WHERE instanceId = ? AND stepName = ? AND tenantId = ?`
|
|
199
|
-
).bind(context.parentInstanceId,
|
|
201
|
+
).bind(context.parentInstanceId, stepNameParam, context.tenantId).first();
|
|
200
202
|
if (existingStep) {
|
|
201
203
|
const row = existingStep;
|
|
202
204
|
if (row.status === "completed") {
|
|
@@ -217,8 +219,8 @@ async function createStepContext(context) {
|
|
|
217
219
|
let waitFor = [];
|
|
218
220
|
const startTime = Date.now();
|
|
219
221
|
const stepStatus = "pending";
|
|
220
|
-
const stepMetadata = context.serializer.serialize(
|
|
221
|
-
const stepName =
|
|
222
|
+
const stepMetadata = context.serializer.serialize(stepMetadataParam || {});
|
|
223
|
+
const stepName = stepNameParam;
|
|
222
224
|
const stepResult = null;
|
|
223
225
|
const stepError = null;
|
|
224
226
|
await insertStepRecordFull(context, {
|
|
@@ -236,7 +238,7 @@ async function createStepContext(context) {
|
|
|
236
238
|
logOrder++;
|
|
237
239
|
const timestamp = Date.now();
|
|
238
240
|
const logPromise = pushLogToDB(context, {
|
|
239
|
-
stepName:
|
|
241
|
+
stepName: stepNameParam,
|
|
240
242
|
instanceId,
|
|
241
243
|
message,
|
|
242
244
|
timestamp,
|