ezlogs-nextjs 0.2.0 → 0.3.0

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.
@@ -8,6 +8,16 @@ interface QStashPublishRequest {
8
8
  body?: unknown;
9
9
  headers?: Record<string, string>;
10
10
  }
11
+ interface WorkflowClientLike {
12
+ trigger?: Function;
13
+ }
14
+ /**
15
+ * Patches `trigger` on the user's `@upstash/workflow` Client so each
16
+ * started run (single or batch) carries the current correlation id to
17
+ * every step. A caller-supplied `x-ezlogs-correlation-id` header wins.
18
+ * No-op outside a captured request. Idempotent.
19
+ */
20
+ declare function wrapWorkflowClient<T extends WorkflowClientLike>(client: T): T;
11
21
  /**
12
22
  * Patches `publishJSON` and `publish` on the user's QStash client so
13
23
  * outbound requests carry the current correlation id forward to the
@@ -25,7 +35,11 @@ declare function wrapQStashClient<T extends QStashClientLike>(client: T): T;
25
35
  * Reads runtime metadata from Upstash's request headers:
26
36
  * - Upstash-Workflow-Runid -> job_id
27
37
  * - Upstash-Retried -> retry_count
28
- * - the wrapped X-Correlation-ID (forwarded by QStash) -> correlation_id
38
+ * - x-ezlogs-correlation-id (stamped by wrapWorkflowClient /
39
+ * wrapQStashClient, agent id format only) -> correlation_id
40
+ *
41
+ * DB writes inside `work` are tagged with that correlation id and
42
+ * emitted when it finishes, so they join the same action.
29
43
  *
30
44
  * Returns the result of `work()`. Re-throws on failure so the user's
31
45
  * Workflow retry / failure-routing semantics still work.
@@ -54,4 +68,4 @@ declare function emitUpstashWorkflowEvent(input: {
54
68
  startedAt?: Date;
55
69
  }): void;
56
70
 
57
- export { captureWorkflowRequest, emitUpstashWorkflowEvent, wrapQStashClient };
71
+ export { captureWorkflowRequest, emitUpstashWorkflowEvent, wrapQStashClient, wrapWorkflowClient };
@@ -8,6 +8,16 @@ interface QStashPublishRequest {
8
8
  body?: unknown;
9
9
  headers?: Record<string, string>;
10
10
  }
11
+ interface WorkflowClientLike {
12
+ trigger?: Function;
13
+ }
14
+ /**
15
+ * Patches `trigger` on the user's `@upstash/workflow` Client so each
16
+ * started run (single or batch) carries the current correlation id to
17
+ * every step. A caller-supplied `x-ezlogs-correlation-id` header wins.
18
+ * No-op outside a captured request. Idempotent.
19
+ */
20
+ declare function wrapWorkflowClient<T extends WorkflowClientLike>(client: T): T;
11
21
  /**
12
22
  * Patches `publishJSON` and `publish` on the user's QStash client so
13
23
  * outbound requests carry the current correlation id forward to the
@@ -25,7 +35,11 @@ declare function wrapQStashClient<T extends QStashClientLike>(client: T): T;
25
35
  * Reads runtime metadata from Upstash's request headers:
26
36
  * - Upstash-Workflow-Runid -> job_id
27
37
  * - Upstash-Retried -> retry_count
28
- * - the wrapped X-Correlation-ID (forwarded by QStash) -> correlation_id
38
+ * - x-ezlogs-correlation-id (stamped by wrapWorkflowClient /
39
+ * wrapQStashClient, agent id format only) -> correlation_id
40
+ *
41
+ * DB writes inside `work` are tagged with that correlation id and
42
+ * emitted when it finishes, so they join the same action.
29
43
  *
30
44
  * Returns the result of `work()`. Re-throws on failure so the user's
31
45
  * Workflow retry / failure-routing semantics still work.
@@ -54,4 +68,4 @@ declare function emitUpstashWorkflowEvent(input: {
54
68
  startedAt?: Date;
55
69
  }): void;
56
70
 
57
- export { captureWorkflowRequest, emitUpstashWorkflowEvent, wrapQStashClient };
71
+ export { captureWorkflowRequest, emitUpstashWorkflowEvent, wrapQStashClient, wrapWorkflowClient };