@helmr/sdk 0.1.0-preview.g4db36b8f.b35308518307
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/LICENSE +190 -0
- package/README.md +65 -0
- package/dist/actor.d.ts +3 -0
- package/dist/client-actor.d.ts +32 -0
- package/dist/client-deployment.d.ts +30 -0
- package/dist/client-sandbox.d.ts +26 -0
- package/dist/client-schedule.d.ts +44 -0
- package/dist/client-secret.d.ts +51 -0
- package/dist/client-session.d.ts +38 -0
- package/dist/client-workspace.d.ts +36 -0
- package/dist/client.d.ts +153 -0
- package/dist/config.d.ts +11 -0
- package/dist/contract.d.ts +341 -0
- package/dist/definitions.d.ts +42 -0
- package/dist/fuzzy.d.ts +1 -0
- package/dist/fuzzy.js +29 -0
- package/dist/image.d.ts +63 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +3029 -0
- package/dist/internal/abort.d.ts +1 -0
- package/dist/internal/definition-query.d.ts +10 -0
- package/dist/internal/id.d.ts +1 -0
- package/dist/internal/jsoncanon.d.ts +5 -0
- package/dist/internal/origin.d.ts +1 -0
- package/dist/internal/program.d.ts +10 -0
- package/dist/internal/run-failure.d.ts +2 -0
- package/dist/internal/run-handle.d.ts +3 -0
- package/dist/internal/runtime.d.ts +43 -0
- package/dist/internal/session.d.ts +5 -0
- package/dist/internal/strings.d.ts +1 -0
- package/dist/internal/timestamp.d.ts +1 -0
- package/dist/internal/utf8.d.ts +3 -0
- package/dist/internal.d.ts +13 -0
- package/dist/internal.js +994 -0
- package/dist/logger.d.ts +9 -0
- package/dist/metadata.d.ts +6 -0
- package/dist/request.d.ts +3 -0
- package/dist/schedules.d.ts +33 -0
- package/dist/schema/payload.d.ts +39 -0
- package/dist/schema/task.d.ts +3 -0
- package/dist/secret.d.ts +1 -0
- package/dist/session.d.ts +5 -0
- package/dist/task.d.ts +2 -0
- package/dist/timers.d.ts +6 -0
- package/dist/tokens.d.ts +77 -0
- package/dist/workspace.d.ts +142 -0
- package/package.json +49 -0
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JsonValue } from "./contract.js";
|
|
2
|
+
export type RunLogLevel = "debug" | "info" | "warn" | "error";
|
|
3
|
+
export type LogAttributes = Readonly<Record<string, JsonValue>>;
|
|
4
|
+
export declare const logger: Readonly<{
|
|
5
|
+
debug(message: string, attributes?: LogAttributes): Promise<void>;
|
|
6
|
+
info(message: string, attributes?: LogAttributes): Promise<void>;
|
|
7
|
+
warn(message: string, attributes?: LogAttributes): Promise<void>;
|
|
8
|
+
error(message: string, attributes?: LogAttributes): Promise<void>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RunDefaults, JsonValue, MaybePromise, Task, TaskContext } from "./contract.js";
|
|
2
|
+
import { type Sandbox, type WorkspaceSecretBinding } from "./workspace.js";
|
|
3
|
+
export type Cron = Readonly<{
|
|
4
|
+
pattern: string;
|
|
5
|
+
timezone: string;
|
|
6
|
+
}>;
|
|
7
|
+
export type ScheduledTaskInput = Readonly<{
|
|
8
|
+
scheduledAt: string;
|
|
9
|
+
lastScheduledAt?: string;
|
|
10
|
+
timezone: string;
|
|
11
|
+
scheduleId: string;
|
|
12
|
+
upcoming: readonly string[];
|
|
13
|
+
}>;
|
|
14
|
+
export interface ScheduledTaskPayload {
|
|
15
|
+
readonly scheduledAt: Date;
|
|
16
|
+
readonly lastScheduledAt?: Date;
|
|
17
|
+
readonly timezone: string;
|
|
18
|
+
readonly scheduleId: string;
|
|
19
|
+
readonly upcoming: readonly Date[];
|
|
20
|
+
}
|
|
21
|
+
export type ScheduledTaskConfig<TIdentifier extends string, TOutput extends JsonValue> = RunDefaults & Readonly<{
|
|
22
|
+
id: TIdentifier;
|
|
23
|
+
cron: Cron;
|
|
24
|
+
workspace: Readonly<{
|
|
25
|
+
sandbox: Sandbox;
|
|
26
|
+
secrets?: readonly WorkspaceSecretBinding[];
|
|
27
|
+
}>;
|
|
28
|
+
run(payload: ScheduledTaskPayload, ctx: TaskContext): MaybePromise<TOutput>;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function scheduledTask<TIdentifier extends string, TOutput extends JsonValue>(config: ScheduledTaskConfig<TIdentifier, TOutput>): Task<TIdentifier, ScheduledTaskInput, TOutput>;
|
|
31
|
+
export declare const schedules: Readonly<{
|
|
32
|
+
task: typeof scheduledTask;
|
|
33
|
+
}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 parsePayloadWithSchema<TSchema extends StandardSchemaV1<any, any>>(schema: TSchema, payload: unknown, label: string): Promise<PayloadSchemaOutput<TSchema>>;
|
package/dist/secret.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function validateSecretName(value: string): void;
|
package/dist/task.d.ts
ADDED
package/dist/timers.d.ts
ADDED
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Duration, HelmrError, JsonValue, Metadata, WaitTimeoutError } from "./contract.js";
|
|
2
|
+
import { type PayloadSchemaOutput, type StandardSchemaV1 } from "./schema/payload.js";
|
|
3
|
+
export interface TokenCreateRequest {
|
|
4
|
+
readonly timeout?: Duration;
|
|
5
|
+
readonly metadata?: Metadata;
|
|
6
|
+
readonly tags?: readonly string[];
|
|
7
|
+
readonly idempotencyKey?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface TokenWaitOptions {
|
|
10
|
+
readonly timeout?: Duration;
|
|
11
|
+
readonly idleTimeout?: Duration;
|
|
12
|
+
readonly metadata?: Metadata;
|
|
13
|
+
readonly tags?: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
export type TokenStatus = "pending" | "completed" | "cancelled" | "expired";
|
|
16
|
+
export interface Token {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly status: TokenStatus;
|
|
19
|
+
readonly result?: JsonValue;
|
|
20
|
+
readonly metadata: Metadata;
|
|
21
|
+
readonly tags: readonly string[];
|
|
22
|
+
readonly timeoutAt: string;
|
|
23
|
+
readonly completedAt?: string;
|
|
24
|
+
readonly createdAt: string;
|
|
25
|
+
readonly updatedAt: string;
|
|
26
|
+
}
|
|
27
|
+
export interface TokenListItem {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly status: TokenStatus;
|
|
30
|
+
readonly tags: readonly string[];
|
|
31
|
+
readonly timeoutAt: string;
|
|
32
|
+
readonly completedAt?: string;
|
|
33
|
+
readonly createdAt: string;
|
|
34
|
+
readonly updatedAt: string;
|
|
35
|
+
}
|
|
36
|
+
export interface TokenListQuery {
|
|
37
|
+
readonly status?: TokenStatus;
|
|
38
|
+
readonly cursor?: string;
|
|
39
|
+
readonly limit?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface TokenCancelledError extends HelmrError {
|
|
42
|
+
readonly code: "token_cancelled";
|
|
43
|
+
}
|
|
44
|
+
export interface TokenExpiredError extends HelmrError {
|
|
45
|
+
readonly code: "token_expired";
|
|
46
|
+
}
|
|
47
|
+
export type TokenWaitError = WaitTimeoutError | TokenCancelledError | TokenExpiredError;
|
|
48
|
+
export type TokenWaitResult<T> = Readonly<{
|
|
49
|
+
ok: true;
|
|
50
|
+
data: T;
|
|
51
|
+
unwrap(): T;
|
|
52
|
+
}> | Readonly<{
|
|
53
|
+
ok: false;
|
|
54
|
+
error: TokenWaitError;
|
|
55
|
+
unwrap(): never;
|
|
56
|
+
}>;
|
|
57
|
+
export interface TokenWait<T> extends PromiseLike<TokenWaitResult<T>> {
|
|
58
|
+
unwrap(): Promise<T>;
|
|
59
|
+
}
|
|
60
|
+
export interface TokenCreateResult extends Token {
|
|
61
|
+
readonly status: "pending";
|
|
62
|
+
readonly callbackUrl: string;
|
|
63
|
+
readonly publicAccessToken: string;
|
|
64
|
+
}
|
|
65
|
+
export interface TokenRef {
|
|
66
|
+
readonly id: string;
|
|
67
|
+
wait(options?: TokenWaitOptions): TokenWait<JsonValue>;
|
|
68
|
+
wait<TSchema extends StandardSchemaV1<any, any>>(options: TokenWaitOptions & Readonly<{
|
|
69
|
+
schema: TSchema;
|
|
70
|
+
}>): TokenWait<PayloadSchemaOutput<TSchema>>;
|
|
71
|
+
}
|
|
72
|
+
interface Tokens {
|
|
73
|
+
create(request?: TokenCreateRequest): Promise<TokenCreateResult & TokenRef>;
|
|
74
|
+
ref(id: string): TokenRef;
|
|
75
|
+
}
|
|
76
|
+
export declare const tokens: Tokens;
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { Duration, WorkspaceAddress } from "./contract.js";
|
|
2
|
+
import { type ImageBuilder, type InternalImage } from "./image.js";
|
|
3
|
+
import type { RequestOptions } from "./request.js";
|
|
4
|
+
declare const sandboxTypeBrand: unique symbol;
|
|
5
|
+
export type WorkspaceMemory = `${bigint}MiB` | `${bigint}GiB`;
|
|
6
|
+
export interface WorkspaceResources {
|
|
7
|
+
readonly cpu: number;
|
|
8
|
+
readonly memory: WorkspaceMemory;
|
|
9
|
+
}
|
|
10
|
+
export interface SandboxConfig {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
}
|
|
13
|
+
export interface SandboxBuilder {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
image(value: ImageBuilder): SandboxResourceBuilder;
|
|
16
|
+
}
|
|
17
|
+
export interface SandboxResourceBuilder {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
resources(value: WorkspaceResources): Sandbox;
|
|
20
|
+
}
|
|
21
|
+
export type WorkspaceStatus = "available" | "recovery_required" | "deleting";
|
|
22
|
+
/** A fixed Workspace binding. Protected material rotates per HTTP request;
|
|
23
|
+
* raw values resolve per execution admission and remain unchanged in restored memory.
|
|
24
|
+
*/
|
|
25
|
+
export type WorkspaceSecretBinding = Readonly<{
|
|
26
|
+
secret: string;
|
|
27
|
+
}> & (Readonly<{
|
|
28
|
+
env: Readonly<{
|
|
29
|
+
name: string;
|
|
30
|
+
mode: "raw";
|
|
31
|
+
allowedOrigins?: never;
|
|
32
|
+
}>;
|
|
33
|
+
file?: never;
|
|
34
|
+
}> | Readonly<{
|
|
35
|
+
env: Readonly<{
|
|
36
|
+
name: string;
|
|
37
|
+
mode: "protected";
|
|
38
|
+
allowedOrigins: readonly string[];
|
|
39
|
+
}>;
|
|
40
|
+
file?: never;
|
|
41
|
+
}> | Readonly<{
|
|
42
|
+
file: Readonly<{
|
|
43
|
+
path: string;
|
|
44
|
+
}>;
|
|
45
|
+
env?: never;
|
|
46
|
+
}>);
|
|
47
|
+
export interface WorkspaceCreateRequest {
|
|
48
|
+
readonly key?: string;
|
|
49
|
+
readonly secrets?: readonly WorkspaceSecretBinding[];
|
|
50
|
+
readonly idempotencyKey?: string;
|
|
51
|
+
}
|
|
52
|
+
export type EncodedWorkspaceSecret = Readonly<{
|
|
53
|
+
secret: string;
|
|
54
|
+
}> & (Readonly<{
|
|
55
|
+
env: Readonly<{
|
|
56
|
+
name: string;
|
|
57
|
+
mode: "raw" | "protected";
|
|
58
|
+
allowed_origins?: readonly string[];
|
|
59
|
+
}>;
|
|
60
|
+
file?: never;
|
|
61
|
+
}> | Readonly<{
|
|
62
|
+
file: Readonly<{
|
|
63
|
+
path: string;
|
|
64
|
+
}>;
|
|
65
|
+
env?: never;
|
|
66
|
+
}>);
|
|
67
|
+
/**
|
|
68
|
+
* The Session or Run that currently owns a Workspace. Absent on an unowned
|
|
69
|
+
* Workspace.
|
|
70
|
+
*/
|
|
71
|
+
export type WorkspaceOwner = Readonly<{
|
|
72
|
+
sessionId: string;
|
|
73
|
+
runId?: never;
|
|
74
|
+
}> | Readonly<{
|
|
75
|
+
runId: string;
|
|
76
|
+
sessionId?: never;
|
|
77
|
+
}>;
|
|
78
|
+
export interface Workspace {
|
|
79
|
+
readonly id: string;
|
|
80
|
+
readonly key?: string;
|
|
81
|
+
readonly sandboxId: string;
|
|
82
|
+
readonly deploymentId: string;
|
|
83
|
+
readonly status: WorkspaceStatus;
|
|
84
|
+
readonly owner?: WorkspaceOwner;
|
|
85
|
+
readonly secrets: readonly WorkspaceSecretBinding[];
|
|
86
|
+
readonly lastActivityAt: string;
|
|
87
|
+
readonly createdAt: string;
|
|
88
|
+
readonly updatedAt: string;
|
|
89
|
+
}
|
|
90
|
+
export interface WorkspaceExecRequest {
|
|
91
|
+
readonly command: readonly string[];
|
|
92
|
+
readonly cwd?: string;
|
|
93
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
94
|
+
readonly stdin?: Uint8Array;
|
|
95
|
+
readonly timeout?: Duration;
|
|
96
|
+
readonly idempotencyKey: string;
|
|
97
|
+
}
|
|
98
|
+
export interface WorkspaceExecResult {
|
|
99
|
+
readonly exitCode: number;
|
|
100
|
+
readonly stdout: Uint8Array;
|
|
101
|
+
readonly stderr: Uint8Array;
|
|
102
|
+
}
|
|
103
|
+
export interface WorkspaceDeleteRequest {
|
|
104
|
+
readonly idempotencyKey?: string;
|
|
105
|
+
}
|
|
106
|
+
export interface WorkspaceDeleteReceipt {
|
|
107
|
+
readonly workspaceId: string;
|
|
108
|
+
}
|
|
109
|
+
export interface WorkspaceRef extends WorkspaceAddress {
|
|
110
|
+
retrieve(options?: RequestOptions): Promise<Workspace>;
|
|
111
|
+
exec(request: WorkspaceExecRequest, options?: RequestOptions): Promise<WorkspaceExecResult>;
|
|
112
|
+
delete(request?: WorkspaceDeleteRequest, options?: RequestOptions): Promise<WorkspaceDeleteReceipt>;
|
|
113
|
+
}
|
|
114
|
+
export interface Sandbox {
|
|
115
|
+
readonly [sandboxTypeBrand]: true;
|
|
116
|
+
readonly id: string;
|
|
117
|
+
createWorkspace(request?: WorkspaceCreateRequest, options?: RequestOptions): Promise<WorkspaceRef>;
|
|
118
|
+
}
|
|
119
|
+
interface Workspaces {
|
|
120
|
+
ref(id: string): WorkspaceRef;
|
|
121
|
+
}
|
|
122
|
+
export interface InternalSandboxDefinition {
|
|
123
|
+
readonly kind: "sandbox";
|
|
124
|
+
readonly id: string;
|
|
125
|
+
readonly image: InternalImage;
|
|
126
|
+
readonly resources: WorkspaceResources;
|
|
127
|
+
}
|
|
128
|
+
export declare function sandbox(config: SandboxConfig): SandboxBuilder;
|
|
129
|
+
export declare const workspaces: Workspaces;
|
|
130
|
+
export declare function inspectWorkspaceAddress(value: unknown): WorkspaceAddress | undefined;
|
|
131
|
+
export declare function workspaceRefID(value: unknown): string;
|
|
132
|
+
export declare function encodeWorkspaceSecrets(inputs: readonly WorkspaceSecretBinding[] | undefined): readonly EncodedWorkspaceSecret[];
|
|
133
|
+
export declare function inspectSandboxDefinition(value: unknown): InternalSandboxDefinition | undefined;
|
|
134
|
+
export declare function createWorkspaceRef(id: string): WorkspaceRef;
|
|
135
|
+
export declare function brandWorkspaceAddress<T extends {
|
|
136
|
+
readonly id: string;
|
|
137
|
+
}>(value: T): T & WorkspaceAddress;
|
|
138
|
+
export declare function parseWorkspace(value: unknown): Workspace;
|
|
139
|
+
export declare function parseWorkspaceOwner(value: unknown, label: string): WorkspaceOwner | undefined;
|
|
140
|
+
export declare function parseWorkspaceExecResult(value: unknown): WorkspaceExecResult;
|
|
141
|
+
export declare function parseWorkspaceDeleteReceipt(value: unknown): WorkspaceDeleteReceipt;
|
|
142
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@helmr/sdk",
|
|
3
|
+
"version": "0.1.0-preview.g4db36b8f.b35308518307",
|
|
4
|
+
"description": "TypeScript SDK for authoring and starting Helmr tasks.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/helmrdotdev/helmr.git",
|
|
12
|
+
"directory": "sdk/typescript"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/helmrdotdev/helmr/issues"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://helmr.dev",
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./internal": {
|
|
27
|
+
"types": "./dist/internal.d.ts",
|
|
28
|
+
"import": "./dist/internal.js"
|
|
29
|
+
},
|
|
30
|
+
"./internal/fuzzy": {
|
|
31
|
+
"types": "./dist/fuzzy.d.ts",
|
|
32
|
+
"import": "./dist/fuzzy.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"LICENSE",
|
|
38
|
+
"README.md"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@bufbuild/protobuf": "^2.11.0",
|
|
42
|
+
"@helmr/proto": "0.1.0-preview.g4db36b8f.b35308518307"
|
|
43
|
+
},
|
|
44
|
+
"helmr": {
|
|
45
|
+
"formatVersion": 0,
|
|
46
|
+
"sourceCommit": "4db36b8f10d59cefa39075e8502762a460c1e3f6",
|
|
47
|
+
"buildId": "35308518307"
|
|
48
|
+
}
|
|
49
|
+
}
|