fix: run metadata not working when using npx/pnpm dlx
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@trigger.dev/core": patch
|
||||
---
|
||||
|
||||
fix: run metadata not working when using npx/pnpm dlx
|
||||
@@ -1,11 +1,13 @@
|
||||
import { DeserializedJson } from "../../schemas/json.js";
|
||||
import { apiClientManager } from "../apiClientManager-api.js";
|
||||
import { taskContext } from "../task-context-api.js";
|
||||
import { getGlobal, registerGlobal } from "../utils/globals.js";
|
||||
import { ApiRequestOptions } from "../zodfetch.js";
|
||||
|
||||
const API_NAME = "run-metadata";
|
||||
|
||||
export class RunMetadataAPI {
|
||||
private static _instance?: RunMetadataAPI;
|
||||
private store: Record<string, DeserializedJson> | undefined;
|
||||
|
||||
private constructor() {}
|
||||
|
||||
@@ -17,8 +19,16 @@ export class RunMetadataAPI {
|
||||
return this._instance;
|
||||
}
|
||||
|
||||
get store(): Record<string, DeserializedJson> | undefined {
|
||||
return getGlobal(API_NAME);
|
||||
}
|
||||
|
||||
set store(value: Record<string, DeserializedJson> | undefined) {
|
||||
registerGlobal(API_NAME, value, true);
|
||||
}
|
||||
|
||||
public enterWithMetadata(metadata: Record<string, DeserializedJson>): void {
|
||||
this.store = metadata;
|
||||
registerGlobal(API_NAME, metadata);
|
||||
}
|
||||
|
||||
public current(): Record<string, DeserializedJson> | undefined {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DeserializedJson } from "../../schemas/json.js";
|
||||
import { ApiClientConfiguration } from "../apiClientManager/types.js";
|
||||
import { Clock } from "../clock/clock.js";
|
||||
import type { RuntimeManager } from "../runtime/manager.js";
|
||||
@@ -54,4 +55,5 @@ type TriggerDotDevGlobalAPI = {
|
||||
["task-catalog"]?: TaskCatalog;
|
||||
["task-context"]?: TaskContext;
|
||||
["api-client"]?: ApiClientConfiguration;
|
||||
["run-metadata"]?: Record<string, DeserializedJson>;
|
||||
};
|
||||
|
||||
@@ -19,6 +19,8 @@ export const runMetadataTask = task({
|
||||
export const runMetadataChildTask = task({
|
||||
id: "run-metadata-child-task",
|
||||
run: async (payload: any, { ctx }) => {
|
||||
logger.info("metadata", { metadata: metadata.current() });
|
||||
|
||||
await metadata.set("child", "task");
|
||||
|
||||
logger.info("metadata", { metadata: metadata.current() });
|
||||
|
||||
Reference in New Issue
Block a user