Skip to content

Commit 24465c9

Browse files
committed
Add back in Job.toJSON to fix the testing package
1 parent 42022b6 commit 24465c9

File tree

1 file changed

+35
-0
lines changed
  • packages/trigger-sdk/src

1 file changed

+35
-0
lines changed

packages/trigger-sdk/src/job.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,41 @@ export class Job<
117117
return this.options.logLevel;
118118
}
119119

120+
get integrations(): Record<string, IntegrationConfig> {
121+
return Object.keys(this.options.integrations ?? {}).reduce(
122+
(acc: Record<string, IntegrationConfig>, key) => {
123+
const integration = this.options.integrations![key];
124+
125+
acc[key] = {
126+
id: integration.id,
127+
metadata: integration.metadata,
128+
authSource: integration.authSource,
129+
};
130+
131+
return acc;
132+
},
133+
{}
134+
);
135+
}
136+
137+
toJSON(): JobMetadata {
138+
// @ts-ignore
139+
const internal = this.options.__internal as JobMetadata["internal"];
140+
141+
return {
142+
id: this.id,
143+
name: this.name,
144+
version: this.version,
145+
event: this.trigger.event,
146+
trigger: this.trigger.toJSON(),
147+
integrations: this.integrations,
148+
startPosition: "latest", // this is deprecated, leaving this for now to make sure newer clients work with older servers
149+
enabled: this.enabled,
150+
preprocessRuns: this.trigger.preprocessRuns,
151+
internal,
152+
};
153+
}
154+
120155
// Make sure the id is valid (must only contain alphanumeric characters and dashes)
121156
// Make sure the version is valid (must be a valid semver version)
122157
#validate() {

0 commit comments

Comments
 (0)