Skip to content

Commit 5a5dab2

Browse files
committed
chore(sdk-v2): use tshy
1 parent b7fb0d9 commit 5a5dab2

31 files changed

+392
-335
lines changed

.changeset/brown-lions-cross.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@systemfsoftware/trigger.dev_sdk-v2": patch
3+
---
4+
5+
use tshy for building v2 sdk

packages/trigger-sdk-v2/package.json

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,48 @@
11
{
22
"name": "@systemfsoftware/trigger.dev_sdk-v2",
3+
"type": "module",
34
"version": "2.5.0",
45
"description": "trigger.dev Node.JS SDK",
56
"license": "MIT",
6-
"main": "./dist/index.js",
7-
"types": "./dist/index.d.ts",
8-
"module": "./dist/index.mjs",
7+
"main": "./dist/commonjs/index.js",
8+
"types": "./dist/commonjs/index.d.ts",
9+
"module": "./dist/esm/index.js",
910
"publishConfig": {
1011
"access": "public"
1112
},
12-
"files": [
13-
"dist"
14-
],
1513
"exports": {
14+
"./package.json": "./package.json",
1615
".": {
1716
"import": {
18-
"types": "./dist/index.d.mts",
19-
"default": "./dist/index.mjs"
17+
"@trigger.dev/source": "./src/index.ts",
18+
"types": "./dist/esm/index.d.ts",
19+
"default": "./dist/esm/index.js"
2020
},
21-
"require": "./dist/index.js",
22-
"types": "./dist/index.d.ts"
21+
"require": {
22+
"types": "./dist/commonjs/index.d.ts",
23+
"default": "./dist/commonjs/index.js"
24+
}
25+
}
26+
},
27+
"files": [
28+
"dist"
29+
],
30+
"tshy": {
31+
"project": "./tsconfig.build.json",
32+
"exports": {
33+
"./package.json": "./package.json",
34+
".": "./src/index.ts"
2335
},
24-
"./package.json": "./package.json"
36+
"sourceDialects": [
37+
"@trigger.dev/source"
38+
]
2539
},
2640
"scripts": {
2741
"prepare": "pnpm turbo build",
28-
"clean": "rimraf dist",
29-
"build": "pnpm run clean && pnpm run build:tsup",
30-
"build:tsup": "tsup --dts-resolve",
31-
"typecheck": "tsc --noEmit"
42+
"clean": "rimraf dist .tshy .tshy-build",
43+
"build": "pnpm run clean && tshy",
44+
"typecheck": "tsc --noEmit",
45+
"test": "echo 'no tests'"
3246
},
3347
"dependencies": {
3448
"@systemfsoftware/trigger.dev_core-v2": "workspace:^",
@@ -38,8 +52,7 @@
3852
"debug": "^4.3.4",
3953
"slug": "^6.0.0",
4054
"terminal-link": "^3.0.0",
41-
"ws": "^8.11.0",
42-
"typed-emitter": "^2.1.0"
55+
"ws": "^8.11.0"
4356
},
4457
"peerDependencies": {
4558
"zod": "3.x",

packages/trigger-sdk-v2/src/apiClient.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
import {
22
API_VERSIONS,
3-
ApiEventLog,
3+
type ApiEventLog,
44
ApiEventLogSchema,
55
CancelRunsForEventSchema,
66
CancelRunsForJobSchema,
7-
CompleteTaskBodyV2Input,
7+
type CompleteTaskBodyV2Input,
88
ConnectionAuthSchema,
9-
EphemeralEventDispatcherRequestBody,
9+
type EphemeralEventDispatcherRequestBody,
1010
EphemeralEventDispatcherResponseBodySchema,
11-
FailTaskBodyInput,
11+
type FailTaskBodyInput,
1212
GetEventSchema,
13-
GetRunOptionsWithTaskDetails,
13+
type GetRunOptionsWithTaskDetails,
1414
GetRunSchema,
1515
GetRunStatusesSchema,
16-
GetRunsOptions,
16+
type GetRunsOptions,
1717
GetRunsSchema,
18-
InvokeJobRequestBody,
18+
type InvokeJobRequestBody,
1919
InvokeJobResponseSchema,
20-
InvokeOptions,
20+
type InvokeOptions,
2121
JobRunStatusRecordSchema,
22-
KeyValueStoreResponseBody,
22+
type KeyValueStoreResponseBody,
2323
KeyValueStoreResponseBodySchema,
2424
RegisterScheduleResponseBodySchema,
2525
RegisterSourceEventSchemaV2,
26-
RegisterSourceEventV2,
27-
RegisterTriggerBodyV2,
28-
RunTaskBodyInput,
26+
type RegisterSourceEventV2,
27+
type RegisterTriggerBodyV2,
28+
type RunTaskBodyInput,
2929
RunTaskResponseWithCachedTasksBodySchema,
30-
ScheduleMetadata,
31-
SendEvent,
32-
SendEventOptions,
30+
type ScheduleMetadata,
31+
type SendEvent,
32+
type SendEventOptions,
3333
ServerTaskSchema,
34-
StatusUpdate,
35-
TriggerSource,
34+
type StatusUpdate,
35+
type TriggerSource,
3636
TriggerSourceSchema,
37-
UpdateTriggerSourceBodyV2,
38-
UpdateWebhookBody,
37+
type UpdateTriggerSourceBodyV2,
38+
type UpdateWebhookBody,
3939
assertExhaustive,
4040
urlWithSearchParams,
4141
} from "@systemfsoftware/trigger.dev_core";
42-
import { LogLevel, Logger } from "@systemfsoftware/trigger.dev_core-backend";
42+
import { type LogLevel, Logger } from "@systemfsoftware/trigger.dev_core-backend";
4343
import { env } from "node:process";
4444

4545
import { z } from "zod";
46-
import { KeyValueStoreClient } from "./store/keyValueStoreClient";
47-
import { AutoYieldRateLimitError } from "./errors";
46+
import { KeyValueStoreClient } from "./store/keyValueStoreClient.js";
47+
import { AutoYieldRateLimitError } from "./errors.js";
4848

4949
export type ApiClientOptions = {
5050
apiKey?: string;

packages/trigger-sdk-v2/src/errors.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
import { DisplayProperty } from "@systemfsoftware/trigger.dev_core";
2-
import { ErrorWithStack, SchemaError, type ServerTask } from "@systemfsoftware/trigger.dev_core";
1+
import { type DisplayProperty } from "@systemfsoftware/trigger.dev_core";
2+
import { type ErrorWithStack, type SchemaError, type ServerTask } from "@systemfsoftware/trigger.dev_core";
33
import { Data } from "effect";
44

55
export class ResumeWithTaskError extends Data.TaggedError("ResumeWithTaskError")<{
6-
task: ServerTask;
6+
readonly task: ServerTask;
77
}> {
8-
constructor(readonly task: ServerTask) {
8+
constructor(task: ServerTask) {
99
super({ task });
1010
}
1111
}
1212

1313
export class ResumeWithParallelTaskError extends Data.TaggedError("ResumeWithTaskError")<{
14-
task: ServerTask;
15-
childErrors: ReadonlyArray<TriggerInternalError>;
14+
readonly task: ServerTask;
15+
readonly childErrors: ReadonlyArray<TriggerInternalError>;
1616
}> {
1717
constructor(
18-
readonly task: ServerTask,
19-
readonly childErrors: ReadonlyArray<TriggerInternalError>
18+
task: ServerTask,
19+
childErrors: ReadonlyArray<TriggerInternalError>
2020
) {
2121
super({ task, childErrors });
2222
}
2323
}
2424

2525
export class RetryWithTaskError extends Data.TaggedError("RetryWithTaskError")<{
26-
cause: ErrorWithStack;
27-
task: ServerTask;
28-
retryAt: Date;
26+
readonly cause: ErrorWithStack;
27+
readonly task: ServerTask;
28+
readonly retryAt: Date;
2929
}> {
3030
constructor(
31-
readonly cause: ErrorWithStack,
32-
readonly task: ServerTask,
33-
readonly retryAt: Date
31+
cause: ErrorWithStack,
32+
task: ServerTask,
33+
retryAt: Date
3434
) {
3535
super({ cause, task, retryAt });
3636
}
3737
}
3838

3939
export class CanceledWithTaskError extends Data.TaggedError("CanceledWithTaskError")<{
40-
task: ServerTask;
40+
readonly task: ServerTask;
4141
}> {
42-
constructor(readonly task: ServerTask) {
42+
constructor(task: ServerTask) {
4343
super({ task });
4444
}
4545
}
4646

4747
export class YieldExecutionError extends Data.TaggedError("YieldExecutionError")<{
48-
key: string;
48+
readonly key: string;
4949
}> {
50-
constructor(readonly key: string) {
50+
constructor(key: string) {
5151
super({ key });
5252
}
5353
}
5454

5555
export class AutoYieldExecutionError extends Data.TaggedError("YieldExecutionError")<{
56-
location: string;
57-
timeRemaining: number;
58-
timeElapsed: number;
56+
readonly location: string;
57+
readonly timeRemaining: number;
58+
readonly timeElapsed: number;
5959
}> {
6060
constructor(
61-
readonly location: string,
62-
readonly timeRemaining: number,
63-
readonly timeElapsed: number
61+
location: string,
62+
timeRemaining: number,
63+
timeElapsed: number
6464
) {
6565
super({ location, timeRemaining, timeElapsed });
6666
}
@@ -69,33 +69,33 @@ export class AutoYieldExecutionError extends Data.TaggedError("YieldExecutionErr
6969
export class AutoYieldWithCompletedTaskExecutionError extends Data.TaggedError(
7070
"AutoYieldWithCompletedTaskExecutionError"
7171
)<{
72-
id: string;
73-
properties?: DisplayProperty[];
74-
data: { location: string; timeRemaining: number; timeElapsed: number };
75-
output?: string;
72+
readonly id: string;
73+
readonly properties?: DisplayProperty[];
74+
readonly data: { location: string; timeRemaining: number; timeElapsed: number };
75+
readonly output?: string;
7676
}> {
7777
constructor(
78-
readonly id: string,
79-
readonly properties: DisplayProperty[] | undefined,
80-
readonly data: { location: string; timeRemaining: number; timeElapsed: number },
81-
readonly output?: string
78+
id: string,
79+
properties: DisplayProperty[] | undefined,
80+
data: { location: string; timeRemaining: number; timeElapsed: number },
81+
output?: string
8282
) {
8383
super({ id, properties, data, output });
8484
}
8585
}
8686

8787
export class AutoYieldRateLimitError extends Data.TaggedError("AutoYieldRateLimitError")<{
88-
resetAtTimestamp: number;
88+
readonly resetAtTimestamp: number;
8989
}> {
90-
constructor(readonly resetAtTimestamp: number) {
90+
constructor(resetAtTimestamp: number) {
9191
super({ resetAtTimestamp });
9292
}
9393
}
9494

9595
export class ParsedPayloadSchemaError extends Data.TaggedError("ParsedPayloadSchemaError")<{
96-
schemaErrors: ReadonlyArray<SchemaError>;
96+
readonly schemaErrors: ReadonlyArray<SchemaError>;
9797
}> {
98-
constructor(readonly schemaErrors: ReadonlyArray<SchemaError>) {
98+
constructor(schemaErrors: ReadonlyArray<SchemaError>) {
9999
super({ schemaErrors });
100100
}
101101
}
@@ -131,12 +131,12 @@ export function isTriggerError(err: unknown): err is TriggerInternalError {
131131

132132
// This error isn't an internal error but it can be used by the user to figure out which task caused the error
133133
export class ErrorWithTask extends Data.TaggedError("ErrorWithTask")<{
134-
cause: ServerTask;
135-
message: string;
134+
readonly cause: ServerTask;
135+
readonly message: string;
136136
}> {
137137
constructor(
138-
readonly cause: ServerTask,
139-
readonly message: string
138+
cause: ServerTask,
139+
message: string
140140
) {
141141
super({ cause, message });
142142
}

packages/trigger-sdk-v2/src/httpEndpoint.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import {
2-
DisplayProperty,
3-
EventFilter,
4-
HttpEndpointMetadata,
5-
RequestFilter,
2+
type DisplayProperty,
3+
type EventFilter,
4+
type HttpEndpointMetadata,
5+
type RequestFilter,
66
RequestWithRawBodySchema,
7-
TriggerMetadata,
7+
type TriggerMetadata,
88
} from "@systemfsoftware/trigger.dev_core";
9-
import { ParsedPayloadSchemaError } from "./errors";
10-
import { Job } from "./job";
11-
import { TriggerClient } from "./triggerClient";
12-
import { EventSpecification, EventSpecificationExample, Trigger, VerifyResult } from "./types";
13-
import { formatSchemaErrors } from "./utils/formatSchemaErrors";
14-
import { slugifyId } from "./utils";
9+
import { ParsedPayloadSchemaError } from "./errors.js";
10+
import { Job } from "./job.js";
11+
import { TriggerClient } from "./triggerClient.js";
12+
import type { EventSpecification, EventSpecificationExample, Trigger, VerifyResult } from "./types.js";
13+
import { formatSchemaErrors } from "./utils/formatSchemaErrors.js";
14+
import { slugifyId } from "./utils.js";
1515

1616
type HttpEndpointOptions<TEventSpecification extends EventSpecification<any>> = {
1717
id: string;

packages/trigger-sdk-v2/src/index.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@ if (TRIGGER_DOT_DEV_MARKER in globalThis) {
44
}
55
(globalThis as any)[TRIGGER_DOT_DEV_MARKER] = true;
66

7-
export * from "./job";
8-
export * from "./triggerClient";
9-
export * from "./integrations";
10-
export * from "./triggers/eventTrigger";
11-
export * from "./triggers/externalSource";
12-
export * from "./triggers/dynamic";
13-
export * from "./triggers/scheduled";
14-
export * from "./triggers/notifications";
15-
export * from "./triggers/invokeTrigger";
16-
export * from "./triggers/webhook";
17-
export * from "./io";
18-
export * from "./types";
19-
export * from "./utils";
20-
export * from "./security";
7+
export * from "./job.js";
8+
export * from "./triggerClient.js";
9+
export * from "./integrations.js";
10+
export * from "./triggers/eventTrigger.js";
11+
export * from "./triggers/externalSource.js";
12+
export * from "./triggers/dynamic.js";
13+
export * from "./triggers/scheduled.js";
14+
export * from "./triggers/notifications.js";
15+
export * from "./triggers/invokeTrigger.js";
16+
export * from "./triggers/webhook.js";
17+
export * from "./io.js";
18+
export * from "./types.js";
19+
export * from "./utils.js";
20+
export * from "./security.js";
2121

22-
import { ServerTask } from "@systemfsoftware/trigger.dev_core";
23-
import { RedactString } from "./types";
24-
export { isTriggerError } from "./errors";
25-
export { retry } from "./retry";
22+
import type { ServerTask } from "@systemfsoftware/trigger.dev_core";
23+
import type { RedactString } from "./types.js";
24+
export { isTriggerError } from "./errors.js";
25+
export { retry } from "./retry.js";
2626

2727
export type { NormalizedRequest, EventFilter } from "@systemfsoftware/trigger.dev_core";
2828

2929
export type Task = ServerTask;
3030

31-
import { ApiEventLog } from "@systemfsoftware/trigger.dev_core";
31+
import type { ApiEventLog } from "@systemfsoftware/trigger.dev_core";
3232
export type SentEvent = ApiEventLog;
3333

3434
/*

packages/trigger-sdk-v2/src/integrations.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { ConnectionAuth, IntegrationMetadata } from "@systemfsoftware/trigger.dev_core";
2-
import { IO } from "./io";
3-
import { Prettify } from "@systemfsoftware/trigger.dev_core";
1+
import type { ConnectionAuth, IntegrationMetadata } from "@systemfsoftware/trigger.dev_core";
2+
import { IO } from "./io.js";
43
export type { ConnectionAuth } from "@systemfsoftware/trigger.dev_core";
54

65
export interface TriggerIntegration {

0 commit comments

Comments
 (0)