@brandboostinggmbh/observable-workflows 0.3.1 → 0.3.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/dist/index.d.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  //#region src/observableWorkflows/createStepContext.d.ts
2
- declare function createStepContext(context: StepContextOptions): Promise<(<RESULT>(step: {
3
- name: string;
4
- metadata?: Record<string, any>;
5
- }, callback: (ctx: StepCtx) => Promise<RESULT>) => Promise<RESULT>)>;
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
@@ -223,6 +226,7 @@ type WorkflowContext = {
223
226
  console: ConsoleWrapper;
224
227
  setWorkflowName: (newName: string) => Promise<void>;
225
228
  setWorkflowProperty: <T extends keyof ValueTypeMap>(key: string, valueType: T, value: ValueTypeMap[T]) => Promise<void>;
229
+ tenantId: string;
226
230
  };
227
231
  type WorkflowFunction<INPUT, TYPE extends string = string> = {
228
232
  workflowType: TYPE;
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, step$1.name, context.tenantId).first();
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(step$1.metadata || {});
221
- const stepName = step$1.name;
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: step$1.name,
241
+ stepName: stepNameParam,
240
242
  instanceId,
241
243
  message,
242
244
  timestamp,
@@ -390,7 +392,8 @@ function createWorkflowContext(options) {
390
392
  value,
391
393
  tenantId
392
394
  });
393
- }
395
+ },
396
+ tenantId
394
397
  });
395
398
  const endTime = Date.now();
396
399
  const workflowStatus = "completed";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brandboostinggmbh/observable-workflows",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "My awesome typescript library",
5
5
  "type": "module",
6
6
  "license": "MIT",