@output.ai/core 0.1.13 → 0.1.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@output.ai/core",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "The core module of the output framework",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,5 +1,5 @@
1
1
  // THIS RUNS IN THE TEMPORAL'S SANDBOX ENVIRONMENT
2
- import { defineSignal, setHandler, proxyActivities, workflowInfo, proxySinks } from '@temporalio/workflow';
2
+ import { defineSignal, setHandler, proxyActivities, workflowInfo, proxySinks, uuid4 } from '@temporalio/workflow';
3
3
  import { ACTIVITY_SEND_WEBHOOK } from '#consts';
4
4
  import { FatalError } from '#errors';
5
5
  import { validateCreateWebhook } from './validations/static.js';
@@ -20,7 +20,7 @@ export async function createWebhook( { url, payload } ) {
20
20
  const sinks = await proxySinks();
21
21
  const resumeSignal = defineSignal( 'resume' );
22
22
 
23
- const traceId = `${workflowId}-${url}-${Date.now()}`;
23
+ const traceId = `${workflowId}-${url}-${uuid4}`;
24
24
  sinks.trace.addEventStart( { id: traceId, name: 'resume', kind: 'webhook' } );
25
25
  return new Promise( resolve =>
26
26
  setHandler( resumeSignal, responsePayload => {
@@ -1,5 +1,5 @@
1
1
  // THIS RUNS IN THE TEMPORAL'S SANDBOX ENVIRONMENT
2
- import { proxyActivities, inWorkflowContext, executeChild, workflowInfo, ParentClosePolicy } from '@temporalio/workflow';
2
+ import { proxyActivities, inWorkflowContext, executeChild, workflowInfo, uuid4, ParentClosePolicy } from '@temporalio/workflow';
3
3
  import { validateWorkflow } from './validations/static.js';
4
4
  import { validateWithSchema } from './validations/runtime.js';
5
5
  import { SHARED_STEP_PREFIX, ACTIVITY_GET_TRACE_DESTINATIONS } from '#consts';
@@ -25,10 +25,9 @@ export function workflow( { name, description, inputSchema, outputSchema, fn, op
25
25
  const steps = proxyActivities( activityOptions );
26
26
 
27
27
  const wrapper = async input => {
28
- validateWithSchema( inputSchema, input, `Workflow ${name} input` );
29
-
30
28
  // this returns a plain function, for example, in unit tests
31
29
  if ( !inWorkflowContext() ) {
30
+ validateWithSchema( inputSchema, input, `Workflow ${name} input` );
32
31
  const output = await fn( input );
33
32
  validateWithSchema( outputSchema, output, `Workflow ${name} output` );
34
33
  return output;
@@ -53,6 +52,9 @@ export function workflow( { name, description, inputSchema, outputSchema, fn, op
53
52
  activityOptions: memo.activityOptions ?? activityOptions // Also preserve the original activity options
54
53
  } );
55
54
 
55
+ // validation comes after setting memo to have that info already set for interceptor even if validations fail
56
+ validateWithSchema( inputSchema, input, `Workflow ${name} input` );
57
+
56
58
  // binds the methods called in the code that Webpack loader will add, they will exposed via "this"
57
59
  const output = await fn.call( {
58
60
  invokeStep: async ( stepName, input, options ) => steps[`${workflowPath}#${stepName}`]( input, options ),
@@ -72,7 +74,7 @@ export function workflow( { name, description, inputSchema, outputSchema, fn, op
72
74
  startWorkflow: async ( childName, input, extra = {} ) =>
73
75
  executeChild( childName, {
74
76
  args: input ? [ input ] : [],
75
- workflowId: `${workflowId}-${childName}-${Date.now()}`,
77
+ workflowId: `${workflowId}-${childName}-${uuid4()}`,
76
78
  parentClosePolicy: ParentClosePolicy[extra?.detached ? 'ABANDON' : 'TERMINATE'],
77
79
  memo: {
78
80
  executionContext,