@helmr/sdk 0.1.1-rc.4 → 0.1.1-rc.6
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/README.md +18 -13
- package/dist/compile.js +29 -3
- package/dist/idempotency.d.ts +30 -0
- package/dist/index.d.ts +26 -9
- package/dist/index.js +674 -202
- package/dist/internal.d.ts +131 -65
- package/dist/internal.js +263 -26
- package/dist/runtime/client.d.ts +106 -56
- package/dist/runtime/run.d.ts +32 -48
- package/dist/schedules.d.ts +28 -0
- package/dist/schema/payload.d.ts +40 -0
- package/dist/schema/task.d.ts +15 -0
- package/dist/task.d.ts +6 -3
- package/dist/trigger.d.ts +10 -20
- package/package.json +2 -2
- package/dist/runtime/source.d.ts +0 -7
package/dist/runtime/client.d.ts
CHANGED
|
@@ -1,51 +1,95 @@
|
|
|
1
|
-
import { type SecretDecls, type
|
|
2
|
-
import { type LogSnapshot, type ListRunEventsOptions, type ListRunsOptions, type
|
|
1
|
+
import { type AnyTask, type NoPayload, type SecretDecls, type TaskOutput, type TaskRunOptions, type TaskSecrets, type TaskTriggerPayload } from "../internal.js";
|
|
2
|
+
import { type LogSnapshot, type ListRunEventsOptions, type ListRunsOptions, type PendingManualWaitpoint, type PendingWaitpointResponse, type RetrieveRunOptions, type RunHandle, type RunEvent, type RunSnapshot, type RunSummary, type RunWaitOptions, type SubscribeRunEventsOptions, type WaitpointRespondOptions, type WaitpointRef } from "./run.js";
|
|
3
3
|
export interface HelmrClientOptions {
|
|
4
4
|
readonly url?: string;
|
|
5
5
|
readonly apiKey?: string;
|
|
6
6
|
}
|
|
7
|
-
export type TaskTriggerOptions<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
readonly payload: TPayload;
|
|
16
|
-
readonly workspace: WorkspaceSpec;
|
|
17
|
-
} & ([keyof TSecrets] extends [never] ? {
|
|
18
|
-
readonly secrets?: Record<never, never>;
|
|
19
|
-
} : {
|
|
20
|
-
readonly secrets: {
|
|
21
|
-
readonly [K in keyof TSecrets]: string;
|
|
22
|
-
};
|
|
23
|
-
});
|
|
7
|
+
export type TaskTriggerOptions<TSecrets extends SecretDecls> = TaskRunOptions<TSecrets>;
|
|
8
|
+
export type TasksTriggerArgs<TTask extends AnyTask> = [
|
|
9
|
+
TaskTriggerPayload<TTask>
|
|
10
|
+
] extends [NoPayload] ? [id: string, opts: TaskTriggerOptions<TaskSecrets<TTask>>] : [id: string, payload: TaskTriggerPayload<TTask>, opts: TaskTriggerOptions<TaskSecrets<TTask>>];
|
|
11
|
+
export type DirectTaskTriggerArgs<TTask extends AnyTask> = [
|
|
12
|
+
TaskTriggerPayload<TTask>
|
|
13
|
+
] extends [NoPayload] ? [opts: TaskTriggerOptions<TaskSecrets<TTask>>] : [payload: TaskTriggerPayload<TTask>, opts: TaskTriggerOptions<TaskSecrets<TTask>>];
|
|
14
|
+
export declare const triggerTaskClientMethod: unique symbol;
|
|
24
15
|
export interface WaitpointsApi {
|
|
25
|
-
readonly
|
|
26
|
-
|
|
27
|
-
(
|
|
28
|
-
|
|
29
|
-
readonly deny: {
|
|
30
|
-
(target: PendingApprovalWaitpoint, opts?: WaitpointApprovalOptions): Promise<void>;
|
|
31
|
-
(runId: string, waitpointId: string, opts?: WaitpointApprovalOptions): Promise<void>;
|
|
32
|
-
};
|
|
33
|
-
readonly reply: {
|
|
34
|
-
(target: PendingMessageWaitpoint, opts: WaitpointReplyOptions): Promise<void>;
|
|
35
|
-
(runId: string, waitpointId: string, opts: WaitpointReplyOptions): Promise<void>;
|
|
16
|
+
readonly create: (opts: WaitpointCreateOptions) => Promise<Waitpoint>;
|
|
17
|
+
readonly respond: {
|
|
18
|
+
(target: PendingManualWaitpoint | WaitpointRef, opts?: WaitpointRespondOptions): Promise<void>;
|
|
19
|
+
(waitpointId: string, opts?: WaitpointRespondOptions): Promise<void>;
|
|
36
20
|
};
|
|
37
21
|
readonly tokens: {
|
|
38
22
|
readonly create: {
|
|
39
|
-
(target:
|
|
40
|
-
(
|
|
23
|
+
(target: PendingManualWaitpoint | WaitpointRef, opts?: WaitpointTokenCreateOptions): Promise<WaitpointResponseToken>;
|
|
24
|
+
(waitpointId: string, opts?: WaitpointTokenCreateOptions): Promise<WaitpointResponseToken>;
|
|
41
25
|
};
|
|
42
|
-
readonly
|
|
43
|
-
(token: WaitpointResponseToken, opts:
|
|
44
|
-
(id: string, token: string, opts:
|
|
26
|
+
readonly respond: {
|
|
27
|
+
(token: WaitpointResponseToken, opts: WaitpointTokenRespondOptions): Promise<void>;
|
|
28
|
+
(id: string, token: string, opts: WaitpointTokenRespondOptions): Promise<void>;
|
|
45
29
|
};
|
|
46
30
|
};
|
|
47
31
|
}
|
|
48
|
-
export
|
|
32
|
+
export interface SchedulesApi {
|
|
33
|
+
readonly create: (opts: ScheduleCreateOptions) => Promise<Schedule>;
|
|
34
|
+
readonly update: (id: string, opts: ScheduleUpdateOptions & RetrieveScheduleOptions) => Promise<Schedule>;
|
|
35
|
+
readonly list: (opts?: ListSchedulesOptions) => Promise<Schedule[]>;
|
|
36
|
+
readonly retrieve: (id: string, opts?: RetrieveScheduleOptions) => Promise<Schedule>;
|
|
37
|
+
readonly activate: (id: string, opts?: RetrieveScheduleOptions) => Promise<Schedule>;
|
|
38
|
+
readonly deactivate: (id: string, opts?: RetrieveScheduleOptions) => Promise<Schedule>;
|
|
39
|
+
readonly delete: (id: string, opts?: RetrieveScheduleOptions) => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export interface ScheduleCreateOptions {
|
|
42
|
+
readonly deduplicationKey?: string;
|
|
43
|
+
readonly externalId?: string;
|
|
44
|
+
readonly projectId?: string;
|
|
45
|
+
readonly environmentId?: string;
|
|
46
|
+
readonly task: string;
|
|
47
|
+
readonly cron: string;
|
|
48
|
+
readonly timezone?: string;
|
|
49
|
+
readonly active?: boolean;
|
|
50
|
+
readonly secretBindings?: Record<string, string>;
|
|
51
|
+
readonly options?: ScheduleRunOptions;
|
|
52
|
+
}
|
|
53
|
+
export type ScheduleUpdateOptions = Omit<ScheduleCreateOptions, "deduplicationKey"> & {
|
|
54
|
+
readonly externalId?: string;
|
|
55
|
+
};
|
|
56
|
+
export interface ScheduleRunOptions {
|
|
57
|
+
readonly deploymentId?: string;
|
|
58
|
+
readonly version?: string;
|
|
59
|
+
readonly queue?: string;
|
|
60
|
+
readonly concurrencyKey?: string;
|
|
61
|
+
readonly priority?: number;
|
|
62
|
+
readonly ttl?: string;
|
|
63
|
+
readonly maxDurationSeconds?: number;
|
|
64
|
+
}
|
|
65
|
+
export interface ListSchedulesOptions {
|
|
66
|
+
readonly projectId?: string;
|
|
67
|
+
readonly environmentId?: string;
|
|
68
|
+
readonly signal?: AbortSignal;
|
|
69
|
+
}
|
|
70
|
+
export interface RetrieveScheduleOptions {
|
|
71
|
+
readonly projectId?: string;
|
|
72
|
+
readonly environmentId?: string;
|
|
73
|
+
readonly signal?: AbortSignal;
|
|
74
|
+
}
|
|
75
|
+
export interface Schedule {
|
|
76
|
+
readonly id: string;
|
|
77
|
+
readonly type: "imperative" | "declarative";
|
|
78
|
+
readonly projectId: string;
|
|
79
|
+
readonly environmentId: string;
|
|
80
|
+
readonly task: string;
|
|
81
|
+
readonly deduplicationKey?: string;
|
|
82
|
+
readonly externalId?: string;
|
|
83
|
+
readonly cron: string;
|
|
84
|
+
readonly timezone: string;
|
|
85
|
+
readonly active: boolean;
|
|
86
|
+
readonly status: "active" | "inactive" | "errored";
|
|
87
|
+
readonly lastError?: string;
|
|
88
|
+
readonly nextScheduledAt?: string;
|
|
89
|
+
readonly lastScheduledAt?: string;
|
|
90
|
+
readonly createdAt: string;
|
|
91
|
+
readonly updatedAt: string;
|
|
92
|
+
}
|
|
49
93
|
type WaitpointTokenExpirationOptions = {
|
|
50
94
|
readonly expiresInSeconds?: number;
|
|
51
95
|
readonly expiresAt?: never;
|
|
@@ -54,39 +98,44 @@ type WaitpointTokenExpirationOptions = {
|
|
|
54
98
|
readonly expiresAt?: string;
|
|
55
99
|
};
|
|
56
100
|
export type WaitpointTokenCreateOptions = WaitpointTokenExpirationOptions & {
|
|
57
|
-
readonly actions?: readonly WaitpointTokenAction[];
|
|
58
101
|
readonly metadata?: Record<string, unknown>;
|
|
59
102
|
};
|
|
60
103
|
export interface WaitpointResponseToken {
|
|
61
104
|
readonly id: string;
|
|
62
|
-
readonly runId: string;
|
|
63
105
|
readonly waitpointId: string;
|
|
64
106
|
readonly url: string;
|
|
65
107
|
readonly token: string;
|
|
66
108
|
readonly expiresAt: string | null;
|
|
67
109
|
}
|
|
68
|
-
export type
|
|
69
|
-
|
|
70
|
-
readonly
|
|
71
|
-
readonly
|
|
72
|
-
readonly
|
|
73
|
-
|
|
74
|
-
readonly
|
|
75
|
-
readonly
|
|
76
|
-
readonly
|
|
77
|
-
readonly
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
readonly
|
|
81
|
-
readonly
|
|
82
|
-
readonly
|
|
83
|
-
|
|
110
|
+
export type WaitpointTokenRespondOptions = WaitpointRespondOptions;
|
|
111
|
+
export interface WaitpointCreateOptions {
|
|
112
|
+
readonly projectId?: string;
|
|
113
|
+
readonly environmentId?: string;
|
|
114
|
+
readonly request?: unknown;
|
|
115
|
+
readonly displayText?: string;
|
|
116
|
+
readonly expiresAt: string;
|
|
117
|
+
readonly idempotencyKey?: string;
|
|
118
|
+
readonly idempotencyKeyExpiresAt?: string;
|
|
119
|
+
readonly idempotencyKeyTTLSeconds?: number;
|
|
120
|
+
}
|
|
121
|
+
export interface Waitpoint {
|
|
122
|
+
readonly id: string;
|
|
123
|
+
readonly projectId: string;
|
|
124
|
+
readonly environmentId: string;
|
|
125
|
+
readonly kind: "manual" | "delay";
|
|
126
|
+
readonly status: "pending" | "completed" | "expired" | "cancelled";
|
|
127
|
+
readonly request: unknown;
|
|
128
|
+
readonly displayText: string;
|
|
129
|
+
readonly expiresAt: string | null;
|
|
130
|
+
readonly createdAt: string;
|
|
131
|
+
}
|
|
84
132
|
export declare class HelmrClient {
|
|
85
133
|
#private;
|
|
86
134
|
constructor(options?: HelmrClientOptions);
|
|
87
135
|
readonly tasks: {
|
|
88
|
-
trigger: <
|
|
136
|
+
trigger: <TTask extends AnyTask>(...args: TasksTriggerArgs<TTask>) => Promise<RunHandle<TaskOutput<TTask>>>;
|
|
89
137
|
};
|
|
138
|
+
[triggerTaskClientMethod]<TTask extends AnyTask>(task: TTask, ...args: DirectTaskTriggerArgs<TTask>): Promise<RunHandle<TaskOutput<TTask>>>;
|
|
90
139
|
readonly runs: {
|
|
91
140
|
retrieve: <TOutput = unknown>(idOrHandle: string | RunHandle<TOutput>, opts?: RetrieveRunOptions) => Promise<RunSnapshot<TOutput>>;
|
|
92
141
|
wait: <TOutput = unknown>(idOrHandle: string | RunHandle<TOutput>, opts?: RunWaitOptions) => Promise<RunSnapshot<TOutput>>;
|
|
@@ -102,6 +151,7 @@ export declare class HelmrClient {
|
|
|
102
151
|
};
|
|
103
152
|
};
|
|
104
153
|
readonly waitpoints: WaitpointsApi;
|
|
154
|
+
readonly schedules: SchedulesApi;
|
|
105
155
|
}
|
|
106
156
|
export interface RunResponse {
|
|
107
157
|
readonly id: string;
|
|
@@ -112,7 +162,7 @@ export interface RunResponse {
|
|
|
112
162
|
readonly exit_code?: number | null;
|
|
113
163
|
readonly created_at?: string;
|
|
114
164
|
readonly updated_at?: string;
|
|
115
|
-
readonly
|
|
165
|
+
readonly pending_waitpoint?: PendingWaitpointResponse | null;
|
|
116
166
|
readonly output?: unknown;
|
|
117
167
|
}
|
|
118
168
|
export interface ListRunsResponse {
|
package/dist/runtime/run.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type RunStatus = "queued" | "running" | "waiting" | "succeeded" | "failed" | "cancelled";
|
|
1
|
+
export type RunStatus = "queued" | "running" | "waiting" | "succeeded" | "failed" | "cancelled" | "expired";
|
|
2
2
|
declare const runOutputBrand: unique symbol;
|
|
3
3
|
export interface RunHandle<TOutput = unknown> {
|
|
4
4
|
readonly id: string;
|
|
@@ -28,30 +28,29 @@ export interface RunSnapshot<TOutput = unknown> extends RunStateBooleans {
|
|
|
28
28
|
readonly output?: TOutput;
|
|
29
29
|
}
|
|
30
30
|
export type RunSummary<TOutput = unknown> = RunSnapshot<TOutput>;
|
|
31
|
-
export type PendingWaitpoint =
|
|
31
|
+
export type PendingWaitpoint = PendingManualWaitpoint | PendingDelayWaitpoint;
|
|
32
32
|
interface PendingWaitpointBase {
|
|
33
33
|
readonly runId: string;
|
|
34
34
|
readonly waitpointId: string;
|
|
35
35
|
readonly timeout: number | null;
|
|
36
36
|
readonly requestedAt: string;
|
|
37
|
+
readonly request: unknown;
|
|
38
|
+
readonly displayText: string;
|
|
37
39
|
}
|
|
38
|
-
export interface
|
|
39
|
-
readonly kind: "
|
|
40
|
-
readonly message: string;
|
|
40
|
+
export interface PendingManualWaitpoint extends PendingWaitpointBase {
|
|
41
|
+
readonly kind: "manual";
|
|
41
42
|
}
|
|
42
|
-
export interface
|
|
43
|
-
readonly kind: "
|
|
44
|
-
readonly prompt: string | null;
|
|
43
|
+
export interface PendingDelayWaitpoint extends PendingWaitpointBase {
|
|
44
|
+
readonly kind: "delay";
|
|
45
45
|
}
|
|
46
46
|
export interface WaitpointRef {
|
|
47
|
-
readonly runId: string;
|
|
48
47
|
readonly waitpointId: string;
|
|
48
|
+
readonly kind?: never;
|
|
49
49
|
}
|
|
50
|
-
export interface
|
|
51
|
-
readonly
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
readonly text: string;
|
|
50
|
+
export interface WaitpointRespondOptions {
|
|
51
|
+
readonly value?: unknown;
|
|
52
|
+
readonly externalSubject?: string;
|
|
53
|
+
readonly metadata?: Record<string, unknown>;
|
|
55
54
|
}
|
|
56
55
|
export interface RunWaitOptions {
|
|
57
56
|
readonly timeoutMs?: number;
|
|
@@ -85,31 +84,21 @@ export type RunEvent = {
|
|
|
85
84
|
readonly observed_seq: number;
|
|
86
85
|
readonly at: string;
|
|
87
86
|
} | {
|
|
88
|
-
readonly type: "
|
|
89
|
-
readonly run_id: string;
|
|
90
|
-
readonly waitpoint_id: string;
|
|
91
|
-
readonly message: string;
|
|
92
|
-
readonly timeout?: number;
|
|
93
|
-
readonly at: string;
|
|
94
|
-
} | {
|
|
95
|
-
readonly type: "approval_decided";
|
|
87
|
+
readonly type: "waitpoint_request";
|
|
96
88
|
readonly run_id: string;
|
|
97
89
|
readonly waitpoint_id: string;
|
|
98
|
-
readonly
|
|
99
|
-
readonly
|
|
100
|
-
readonly
|
|
101
|
-
} | {
|
|
102
|
-
readonly type: "message_request";
|
|
103
|
-
readonly run_id: string;
|
|
104
|
-
readonly waitpoint_id: string;
|
|
105
|
-
readonly prompt?: string;
|
|
90
|
+
readonly kind: string;
|
|
91
|
+
readonly displayText: string;
|
|
92
|
+
readonly request: unknown;
|
|
106
93
|
readonly timeout?: number;
|
|
107
94
|
readonly at: string;
|
|
108
95
|
} | {
|
|
109
|
-
readonly type: "
|
|
96
|
+
readonly type: "waitpoint_resolved";
|
|
110
97
|
readonly run_id: string;
|
|
111
98
|
readonly waitpoint_id: string;
|
|
112
|
-
readonly
|
|
99
|
+
readonly kind: string;
|
|
100
|
+
readonly resolutionKind: string;
|
|
101
|
+
readonly value: unknown;
|
|
113
102
|
readonly at: string;
|
|
114
103
|
} | {
|
|
115
104
|
readonly type: "emit";
|
|
@@ -118,7 +107,7 @@ export type RunEvent = {
|
|
|
118
107
|
readonly content: unknown;
|
|
119
108
|
readonly at: string;
|
|
120
109
|
} | {
|
|
121
|
-
readonly type: "
|
|
110
|
+
readonly type: "task_result";
|
|
122
111
|
readonly run_id: string;
|
|
123
112
|
readonly exit_code: number;
|
|
124
113
|
readonly at: string;
|
|
@@ -129,15 +118,15 @@ export type RunEvent = {
|
|
|
129
118
|
readonly detail?: unknown;
|
|
130
119
|
readonly at: string;
|
|
131
120
|
} | {
|
|
132
|
-
readonly type: "
|
|
121
|
+
readonly type: "run_cancelled";
|
|
133
122
|
readonly run_id: string;
|
|
134
|
-
readonly
|
|
135
|
-
readonly limit_secs: number;
|
|
123
|
+
readonly reason?: string;
|
|
136
124
|
readonly at: string;
|
|
137
125
|
} | {
|
|
138
|
-
readonly type: "
|
|
126
|
+
readonly type: "run_expired";
|
|
139
127
|
readonly run_id: string;
|
|
140
|
-
readonly
|
|
128
|
+
readonly ttl?: string;
|
|
129
|
+
readonly message?: string;
|
|
141
130
|
readonly at: string;
|
|
142
131
|
};
|
|
143
132
|
export interface RunEventRecord {
|
|
@@ -164,19 +153,14 @@ export interface LogSnapshot {
|
|
|
164
153
|
readonly cursor: string;
|
|
165
154
|
readonly truncated: boolean;
|
|
166
155
|
}
|
|
167
|
-
export
|
|
168
|
-
readonly kind: "
|
|
156
|
+
export interface PendingWaitpointResponse {
|
|
157
|
+
readonly kind: "manual" | "delay";
|
|
169
158
|
readonly waitpoint_id: string;
|
|
170
|
-
readonly message?: string | null;
|
|
171
159
|
readonly timeout?: number | null;
|
|
160
|
+
readonly request?: unknown;
|
|
161
|
+
readonly display_text?: string | null;
|
|
172
162
|
readonly requested_at: string;
|
|
173
|
-
}
|
|
174
|
-
readonly kind: "message";
|
|
175
|
-
readonly waitpoint_id: string;
|
|
176
|
-
readonly prompt?: string | null;
|
|
177
|
-
readonly timeout?: number | null;
|
|
178
|
-
readonly requested_at: string;
|
|
179
|
-
};
|
|
163
|
+
}
|
|
180
164
|
export declare function runHandle<TOutput = unknown>(id: string, taskId: string): RunHandle<TOutput>;
|
|
181
165
|
export declare function runSnapshot<TOutput = unknown>(snapshot: {
|
|
182
166
|
readonly id: string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type MarkedTask, type MaybePromise, type SecretDecls, type TaskContext, type TaskConfigBase } from "./internal.js";
|
|
2
|
+
import type { PayloadSchema } from "./schema/payload.js";
|
|
3
|
+
export interface ScheduledTaskPayload {
|
|
4
|
+
readonly timestamp: Date;
|
|
5
|
+
readonly lastTimestamp?: Date;
|
|
6
|
+
readonly timezone: string;
|
|
7
|
+
readonly scheduleId: string;
|
|
8
|
+
readonly externalId?: string;
|
|
9
|
+
readonly upcoming: readonly Date[];
|
|
10
|
+
}
|
|
11
|
+
export type ScheduleCron = string | {
|
|
12
|
+
readonly pattern: string;
|
|
13
|
+
readonly timezone?: string;
|
|
14
|
+
};
|
|
15
|
+
type DeclarativeScheduleFields = {
|
|
16
|
+
readonly cron: ScheduleCron;
|
|
17
|
+
readonly secretBindings?: Record<string, string>;
|
|
18
|
+
} | {
|
|
19
|
+
readonly cron?: undefined;
|
|
20
|
+
readonly secretBindings?: undefined;
|
|
21
|
+
};
|
|
22
|
+
export type ScheduledTaskConfig<TOutput = unknown, TSecrets extends SecretDecls = Record<never, never>> = Omit<TaskConfigBase<TSecrets>, "payload"> & DeclarativeScheduleFields & {
|
|
23
|
+
readonly payload?: never;
|
|
24
|
+
readonly run: (payload: ScheduledTaskPayload, ctx: TaskContext) => MaybePromise<TOutput>;
|
|
25
|
+
};
|
|
26
|
+
export declare function task<TOutput = unknown, TSecrets extends SecretDecls = Record<never, never>>(config: ScheduledTaskConfig<TOutput, TSecrets>): MarkedTask<ScheduledTaskPayload, Awaited<TOutput>, TSecrets, typeof scheduledTaskPayloadSchema>;
|
|
27
|
+
declare const scheduledTaskPayloadSchema: PayloadSchema<unknown, ScheduledTaskPayload>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
2
|
+
readonly "~standard": {
|
|
3
|
+
readonly version: 1;
|
|
4
|
+
readonly vendor: string;
|
|
5
|
+
validate(value: unknown): StandardSchemaV1.Result<Output> | PromiseLike<StandardSchemaV1.Result<Output>>;
|
|
6
|
+
readonly types?: StandardSchemaV1.Types<Input, Output> | undefined;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare namespace StandardSchemaV1 {
|
|
10
|
+
interface Types<Input = unknown, Output = Input> {
|
|
11
|
+
readonly input: Input;
|
|
12
|
+
readonly output: Output;
|
|
13
|
+
}
|
|
14
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
15
|
+
interface SuccessResult<Output> {
|
|
16
|
+
readonly value: Output;
|
|
17
|
+
readonly issues?: undefined;
|
|
18
|
+
}
|
|
19
|
+
interface FailureResult {
|
|
20
|
+
readonly issues: readonly Issue[];
|
|
21
|
+
}
|
|
22
|
+
interface Issue {
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly path?: readonly (PropertyKey | PathSegment)[];
|
|
25
|
+
}
|
|
26
|
+
interface PathSegment {
|
|
27
|
+
readonly key: PropertyKey;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export type PayloadSchema<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>;
|
|
31
|
+
export type PayloadSchemaInput<TSchema> = TSchema extends StandardSchemaV1<infer Input, any> ? Input : unknown;
|
|
32
|
+
export type PayloadSchemaOutput<TSchema> = TSchema extends StandardSchemaV1<any, infer Output> ? Output : unknown;
|
|
33
|
+
export declare class PayloadSchemaValidationError extends Error {
|
|
34
|
+
readonly issues: readonly StandardSchemaV1.Issue[];
|
|
35
|
+
constructor(label: string, issues: readonly StandardSchemaV1.Issue[]);
|
|
36
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare function assertPayloadSchema(value: unknown, label?: string): asserts value is PayloadSchema;
|
|
39
|
+
export declare function assertStandardSchema(value: unknown, label?: string): asserts value is StandardSchemaV1;
|
|
40
|
+
export declare function parsePayloadWithSchema<TSchema extends StandardSchemaV1<any, any>>(schema: TSchema, payload: unknown, label: string): Promise<PayloadSchemaOutput<TSchema>>;
|
package/dist/schema/task.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export declare const TASK_ID_MAX_LENGTH = 128;
|
|
|
3
3
|
export declare const DEFAULT_MAX_DURATION_SECONDS = 900;
|
|
4
4
|
export declare const MIN_MAX_DURATION_SECONDS = 5;
|
|
5
5
|
export declare const MAX_DURATION_SECONDS = 86400;
|
|
6
|
+
export declare const QUEUE_NAME_PATTERN: "^[A-Za-z0-9][A-Za-z0-9._/-]{0,255}$";
|
|
7
|
+
export declare const QUEUE_NAME_MAX_LENGTH = 256;
|
|
6
8
|
export declare class TaskIdError extends Error {
|
|
7
9
|
readonly name = "TaskIdError";
|
|
8
10
|
readonly value: string;
|
|
@@ -18,3 +20,16 @@ export declare class TaskMaxDurationError extends Error {
|
|
|
18
20
|
}
|
|
19
21
|
export declare function readOptionalMaxDurationSeconds(value: unknown, label?: string): number;
|
|
20
22
|
export declare function validateOptionalMaxDurationSeconds(value: unknown, label?: string): void;
|
|
23
|
+
export declare class TaskQueueNameError extends Error {
|
|
24
|
+
readonly name = "TaskQueueNameError";
|
|
25
|
+
readonly value: string;
|
|
26
|
+
constructor(value: string);
|
|
27
|
+
}
|
|
28
|
+
export declare class TaskQueueConcurrencyLimitError extends Error {
|
|
29
|
+
readonly name = "TaskQueueConcurrencyLimitError";
|
|
30
|
+
readonly value: unknown;
|
|
31
|
+
constructor(value: unknown);
|
|
32
|
+
}
|
|
33
|
+
export declare function validateQueueName(value: string): void;
|
|
34
|
+
export declare function isValidQueueName(value: string): boolean;
|
|
35
|
+
export declare function validateOptionalQueueConcurrencyLimit(value: unknown): void;
|
package/dist/task.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import { type SecretDecls, type Task, type TaskConfig, type TaskOutput, type TaskPayload } from "./internal.js";
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import { type NoPayload, type SecretDecls, type Task, type TaskConfig, type TaskQueueConfig, type TaskConfigWithPayload, type TaskConfigWithoutPayload, type TaskRunOptions, type TaskOutput, type TaskPayload, type TaskTriggerPayload } from "./internal.js";
|
|
2
|
+
import type { PayloadSchema, PayloadSchemaInput, PayloadSchemaOutput } from "./schema/payload.js";
|
|
3
|
+
export declare function task<TPayloadSchema extends PayloadSchema<any, any>, TOutput, TSecrets extends SecretDecls = Record<never, never>>(config: TaskConfigWithPayload<TPayloadSchema, TOutput, TSecrets>): Task<PayloadSchemaOutput<TPayloadSchema>, Awaited<TOutput>, TSecrets, PayloadSchemaInput<TPayloadSchema>>;
|
|
4
|
+
export declare function task<TOutput = unknown, TSecrets extends SecretDecls = Record<never, never>>(config: TaskConfigWithoutPayload<TOutput, TSecrets>): Task<NoPayload, Awaited<TOutput>, TSecrets, NoPayload>;
|
|
5
|
+
export declare function queue(config: TaskQueueConfig): TaskQueueConfig;
|
|
6
|
+
export type { NoPayload, Task, TaskConfig, TaskOutput, TaskPayload, TaskQueueConfig, TaskRunOptions, TaskTriggerPayload };
|
package/dist/trigger.d.ts
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
import type { SecretDecls,
|
|
1
|
+
import type { AnyTask, NoPayload, SecretDecls, TaskOutput, TaskRunOptions, TaskSecrets, TaskTriggerPayload } from "./internal.js";
|
|
2
2
|
import { HelmrClient } from "./runtime/client.js";
|
|
3
3
|
import type { RunHandle } from "./runtime/run.js";
|
|
4
4
|
export declare function getDefaultClient(): HelmrClient;
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* credentials, or PII) in payload; use `secrets:` instead. Use payload for
|
|
13
|
-
* business context such as PR numbers, repo names, ticket ids, and other
|
|
14
|
-
* identifiers.
|
|
15
|
-
*/
|
|
16
|
-
readonly payload: TPayload;
|
|
17
|
-
readonly workspace: WorkspaceSpec;
|
|
18
|
-
} & ([keyof TSecrets] extends [never] ? {
|
|
19
|
-
readonly secrets?: Record<never, never>;
|
|
20
|
-
} : {
|
|
21
|
-
readonly secrets: TriggerSecrets<TSecrets>;
|
|
22
|
-
});
|
|
5
|
+
export type TriggerOptions<TSecrets extends SecretDecls> = TaskRunOptions<TSecrets>;
|
|
6
|
+
export type TriggerArgs<TTask extends AnyTask> = [
|
|
7
|
+
TaskTriggerPayload<TTask>
|
|
8
|
+
] extends [NoPayload] ? [id: string, opts: TriggerOptions<TaskSecrets<TTask>>] : [id: string, payload: TaskTriggerPayload<TTask>, opts: TriggerOptions<TaskSecrets<TTask>>];
|
|
9
|
+
export type TaskTriggerArgs<TTask extends AnyTask> = [
|
|
10
|
+
TaskTriggerPayload<TTask>
|
|
11
|
+
] extends [NoPayload] ? [opts: TriggerOptions<TaskSecrets<TTask>>] : [payload: TaskTriggerPayload<TTask>, opts: TriggerOptions<TaskSecrets<TTask>>];
|
|
23
12
|
export declare const tasks: {
|
|
24
|
-
trigger<
|
|
13
|
+
trigger<TTask extends AnyTask>(...args: TriggerArgs<TTask>): Promise<RunHandle<TaskOutput<TTask>>>;
|
|
25
14
|
};
|
|
15
|
+
export declare function triggerTask<TTask extends AnyTask>(task: TTask, ...args: TaskTriggerArgs<TTask>): Promise<RunHandle<TaskOutput<TTask>>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helmr/sdk",
|
|
3
|
-
"version": "0.1.1-rc.
|
|
3
|
+
"version": "0.1.1-rc.6",
|
|
4
4
|
"description": "TypeScript SDK for authoring and triggering Helmr tasks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,6 +43,6 @@
|
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@bufbuild/protobuf": "^2.11.0",
|
|
46
|
-
"@helmr/proto": "0.1.1-rc.
|
|
46
|
+
"@helmr/proto": "0.1.1-rc.6"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/dist/runtime/source.d.ts
DELETED