@ontemper/platform 0.1.0 → 0.1.1

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
@@ -12,7 +12,6 @@
12
12
  */
13
13
  import * as restate from "@restatedev/restate-sdk";
14
14
  interface CreateWorkflowOptions {
15
- name?: string;
16
15
  handler: (ctx: TemperContext, input: unknown) => Promise<unknown>;
17
16
  }
18
17
  /**
@@ -33,7 +32,7 @@ declare class TemperContext {
33
32
  /** Set a durable state value. */
34
33
  set<T>(key: string, value: T): Promise<void>;
35
34
  }
36
- export declare function createWorkflow({ name, handler }: CreateWorkflowOptions): void;
35
+ export declare function createWorkflow({ handler }: CreateWorkflowOptions): void;
37
36
  export declare const temper: {
38
37
  createWorkflow: typeof createWorkflow;
39
38
  };
package/dist/index.js CHANGED
@@ -67,11 +67,13 @@ function writeDualStatus(executionId, status, extra) {
67
67
  body: JSON.stringify({ execution_id: executionId, status, ...extra }),
68
68
  }).catch(() => { }); // best-effort
69
69
  }
70
- export function createWorkflow({ name, handler }) {
70
+ export function createWorkflow({ handler }) {
71
+ const workflowId = process.env.WORKFLOW_ID;
72
+ if (!workflowId)
73
+ throw new Error("WORKFLOW_ID env var required");
71
74
  // Restate service names must match ^([a-zA-Z]|_[a-zA-Z0-9])[a-zA-Z0-9._-]*$
72
75
  // UUIDs start with digits, so prefix with "wf_" to make them valid.
73
- const rawName = name || process.env.WORKFLOW_ID || "WorkflowRunner";
74
- const workflowName = rawName.match(/^[a-zA-Z_]/) ? rawName : `wf_${rawName}`;
76
+ const workflowName = `wf_${workflowId}`;
75
77
  const workflow = restate.workflow({
76
78
  name: workflowName,
77
79
  handlers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ontemper/platform",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Temper platform SDK for durable workflow execution",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",