@alienplatform/commands 1.14.1-dev.e74fae6cd01b61e77a285276f264b5480977f41a
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/dist/client.d.ts +137 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/errors.d.ts +302 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5072 -0
- package/dist/presigned.d.ts +29 -0
- package/dist/presigned.d.ts.map +1 -0
- package/dist/protocol.d.ts +31 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/receiver.d.ts +186 -0
- package/dist/receiver.d.ts.map +1 -0
- package/dist/wire.d.ts +32 -0
- package/dist/wire.d.ts.map +1 -0
- package/package.json +62 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command sender — invoke commands on remote Alien deployments.
|
|
3
|
+
*
|
|
4
|
+
* Migrated from the former `@alienplatform/sdk/commands` subpath. Pure `fetch`; no gRPC, no
|
|
5
|
+
* bindings. Handles:
|
|
6
|
+
* - Base64 encoding/decoding of input and responses
|
|
7
|
+
* - Large payload download via storage presigned transfers
|
|
8
|
+
* - Polling with exponential backoff
|
|
9
|
+
* - Error handling and timeout
|
|
10
|
+
*
|
|
11
|
+
* `.target(name)` returns a {@link TargetedCommands} bound sender that presets
|
|
12
|
+
* `targetResourceId` on every invoke — mirroring the Rust
|
|
13
|
+
* `CommandsClient::target(...)` builder. The builder's target wins over any
|
|
14
|
+
* `options.targetResourceId` the caller also passes.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for {@link CommandsClient}.
|
|
18
|
+
*/
|
|
19
|
+
export interface CommandsClientConfig {
|
|
20
|
+
/** Manager URL (e.g. "https://manager.example.com"). Trailing slashes are stripped. */
|
|
21
|
+
managerUrl: string;
|
|
22
|
+
/** Deployment ID to invoke commands on. */
|
|
23
|
+
deploymentId: string;
|
|
24
|
+
/** Bearer token (deployment token or workspace token). */
|
|
25
|
+
token: string;
|
|
26
|
+
/** Default invoke timeout in milliseconds (default: 60000). */
|
|
27
|
+
timeoutMs?: number;
|
|
28
|
+
/** Allow reading local files for storage responses (default: false, local dev only). */
|
|
29
|
+
allowLocalStorage?: boolean;
|
|
30
|
+
/** `fetch` implementation (defaults to the global `fetch`). */
|
|
31
|
+
fetch?: typeof fetch;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Per-invoke options.
|
|
35
|
+
*/
|
|
36
|
+
export interface InvokeOptions {
|
|
37
|
+
/** Wall-clock timeout in milliseconds (default: the client's `timeoutMs`). */
|
|
38
|
+
timeoutMs?: number;
|
|
39
|
+
/** Optional server-side deadline for command completion. */
|
|
40
|
+
deadline?: Date;
|
|
41
|
+
/** Optional idempotency key — the server dedupes retried creates by this key. */
|
|
42
|
+
idempotencyKey?: string;
|
|
43
|
+
/** Target command-capable resource id; a `.target(name)` builder overrides this. */
|
|
44
|
+
targetResourceId?: string;
|
|
45
|
+
/** Initial polling interval in milliseconds (default: 500). */
|
|
46
|
+
pollIntervalMs?: number;
|
|
47
|
+
/** Maximum polling interval in milliseconds (default: 5000). */
|
|
48
|
+
maxPollIntervalMs?: number;
|
|
49
|
+
/** Polling backoff multiplier (default: 1.5). */
|
|
50
|
+
pollBackoff?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Command sender for invoking deployment commands.
|
|
54
|
+
*/
|
|
55
|
+
export declare class CommandsClient {
|
|
56
|
+
private readonly managerUrl;
|
|
57
|
+
private readonly deploymentId;
|
|
58
|
+
private readonly token;
|
|
59
|
+
private readonly defaultTimeout;
|
|
60
|
+
private readonly allowLocalStorage;
|
|
61
|
+
private readonly fetchImpl;
|
|
62
|
+
constructor(config: CommandsClientConfig);
|
|
63
|
+
/**
|
|
64
|
+
* Scope this client to one target command-capable resource: every `invoke`
|
|
65
|
+
* made through the returned builder presets `targetResourceId` to `name`,
|
|
66
|
+
* mirroring the Rust `CommandsClient::target(...)` shorthand.
|
|
67
|
+
*
|
|
68
|
+
* If the caller also passes `options.targetResourceId`, the builder's target
|
|
69
|
+
* silently wins — passing two different targets is a programmer error, not a
|
|
70
|
+
* runtime conflict this builder tries to detect.
|
|
71
|
+
*/
|
|
72
|
+
target(name: string): TargetedCommands;
|
|
73
|
+
/**
|
|
74
|
+
* Invoke a command on the deployment and wait for its response.
|
|
75
|
+
*
|
|
76
|
+
* @param command - Command name (e.g. "generate-report").
|
|
77
|
+
* @param input - Command input (JSON-serializable).
|
|
78
|
+
* @param options - Invocation options.
|
|
79
|
+
* @returns Decoded response data.
|
|
80
|
+
*/
|
|
81
|
+
invoke<TResponse = unknown>(command: string, input: unknown, options?: InvokeOptions): Promise<TResponse>;
|
|
82
|
+
/**
|
|
83
|
+
* Fetch `path` on the manager, raise {@link ManagerHttpError} on a non-2xx
|
|
84
|
+
* status, and validate the 2xx JSON body against `schema` (a malformed body
|
|
85
|
+
* raises {@link MalformedResponseError}). AlienErrors — both of those — pass
|
|
86
|
+
* through untouched; any other (network/transport) error is wrapped with the
|
|
87
|
+
* caller-supplied context. Only 2xx responses carry a body, so `schema` is
|
|
88
|
+
* always applied.
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* Build a request URL by appending `path` to the configured manager base URL.
|
|
92
|
+
*
|
|
93
|
+
* Uses URL-based construction rather than a naive `base + path` concat so a
|
|
94
|
+
* base URL carrying a query string — e.g. `https://h/v1?token=x` — keeps its
|
|
95
|
+
* query correctly at the end (`https://h/v1/commands?token=x`) instead of
|
|
96
|
+
* corrupting it into `https://h/v1?token=x/commands`. Twin of the receiver's
|
|
97
|
+
* `buildLeaseEndpoint`, which appends path segments while leaving the query
|
|
98
|
+
* untouched.
|
|
99
|
+
*/
|
|
100
|
+
private buildManagerUrl;
|
|
101
|
+
private managerFetch;
|
|
102
|
+
/**
|
|
103
|
+
* Create a command.
|
|
104
|
+
*/
|
|
105
|
+
private createCommand;
|
|
106
|
+
/**
|
|
107
|
+
* Get a command's status.
|
|
108
|
+
*/
|
|
109
|
+
private getCommandStatus;
|
|
110
|
+
/**
|
|
111
|
+
* Handle a terminal state and return the response.
|
|
112
|
+
*/
|
|
113
|
+
private handleTerminalState;
|
|
114
|
+
/**
|
|
115
|
+
* Sleep helper.
|
|
116
|
+
*/
|
|
117
|
+
private sleep;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A {@link CommandsClient} scoped to one target command-capable resource.
|
|
121
|
+
*
|
|
122
|
+
* Obtained via {@link CommandsClient.target}. Every `invoke` presets
|
|
123
|
+
* `targetResourceId` to this builder's resource id, overriding any
|
|
124
|
+
* `options.targetResourceId` the caller passes (builder wins — same rule as the
|
|
125
|
+
* Rust `TargetedCommands`).
|
|
126
|
+
*/
|
|
127
|
+
export declare class TargetedCommands {
|
|
128
|
+
private readonly client;
|
|
129
|
+
private readonly resourceId;
|
|
130
|
+
constructor(client: CommandsClient, resourceId: string);
|
|
131
|
+
/**
|
|
132
|
+
* Invoke a command against this builder's target and wait for the result.
|
|
133
|
+
* The builder's target overrides any `options.targetResourceId`.
|
|
134
|
+
*/
|
|
135
|
+
invoke<TResponse = unknown>(command: string, input: unknown, options?: InvokeOptions): Promise<TResponse>;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA2BH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,uFAAuF;IACvF,UAAU,EAAE,MAAM,CAAA;IAClB,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAA;IACpB,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAA;IACb,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wFAAwF;IACxF,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,+DAA+D;IAC/D,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,IAAI,CAAA;IACf,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,oFAAoF;IACpF,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAwGD;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAQ;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAQ;IACvC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;gBAE5B,MAAM,EAAE,oBAAoB;IAWxC;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB;IAItC;;;;;;;OAOG;IACG,MAAM,CAAC,SAAS,GAAG,OAAO,EAC9B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,SAAS,CAAC;IAsCrB;;;;;;;OAOG;IACH;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;YAQT,YAAY;IA4C1B;;OAEG;IACH,OAAO,CAAC,aAAa;IAuBrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;OAEG;YACW,mBAAmB;IA4DjC;;OAEG;IACH,OAAO,CAAC,KAAK;CAGd;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,MAAM;IAGrC;;;OAGG;IACH,MAAM,CAAC,SAAS,GAAG,OAAO,EACxB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,SAAS,CAAC;CAMtB"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command sender error definitions.
|
|
3
|
+
*
|
|
4
|
+
* Migrated from the former `@alienplatform/sdk/commands` subpath — the seven `defineError`
|
|
5
|
+
* definitions the sender raises. Each is built with `defineError` from
|
|
6
|
+
* `@alienplatform/core` so it carries the shared `AlienError` identity.
|
|
7
|
+
*/
|
|
8
|
+
import * as z from "zod/v4";
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when command creation fails.
|
|
11
|
+
*/
|
|
12
|
+
export declare const CommandCreationFailedError: {
|
|
13
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
14
|
+
deploymentId: z.ZodString;
|
|
15
|
+
command: z.ZodString;
|
|
16
|
+
reason: z.ZodString;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
contextSchema: z.ZodObject<{
|
|
19
|
+
deploymentId: z.ZodString;
|
|
20
|
+
command: z.ZodString;
|
|
21
|
+
reason: z.ZodString;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
create: (context: {
|
|
24
|
+
deploymentId: string;
|
|
25
|
+
command: string;
|
|
26
|
+
reason: string;
|
|
27
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
28
|
+
deploymentId: z.ZodString;
|
|
29
|
+
command: z.ZodString;
|
|
30
|
+
reason: z.ZodString;
|
|
31
|
+
}, z.core.$strip>>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Error thrown when fetching a command's status fails (network/transport error,
|
|
35
|
+
* not an HTTP error status — those raise {@link ManagerHttpError}).
|
|
36
|
+
*/
|
|
37
|
+
export declare const CommandStatusFailedError: {
|
|
38
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
39
|
+
commandId: z.ZodString;
|
|
40
|
+
reason: z.ZodString;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
contextSchema: z.ZodObject<{
|
|
43
|
+
commandId: z.ZodString;
|
|
44
|
+
reason: z.ZodString;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
create: (context: {
|
|
47
|
+
commandId: string;
|
|
48
|
+
reason: string;
|
|
49
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
50
|
+
commandId: z.ZodString;
|
|
51
|
+
reason: z.ZodString;
|
|
52
|
+
}, z.core.$strip>>;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Error thrown when command execution times out.
|
|
56
|
+
*/
|
|
57
|
+
export declare const CommandTimeoutError: {
|
|
58
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
59
|
+
commandId: z.ZodString;
|
|
60
|
+
command: z.ZodString;
|
|
61
|
+
timeoutMs: z.ZodNumber;
|
|
62
|
+
lastState: z.ZodString;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
contextSchema: z.ZodObject<{
|
|
65
|
+
commandId: z.ZodString;
|
|
66
|
+
command: z.ZodString;
|
|
67
|
+
timeoutMs: z.ZodNumber;
|
|
68
|
+
lastState: z.ZodString;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
create: (context: {
|
|
71
|
+
commandId: string;
|
|
72
|
+
command: string;
|
|
73
|
+
timeoutMs: number;
|
|
74
|
+
lastState: string;
|
|
75
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
76
|
+
commandId: z.ZodString;
|
|
77
|
+
command: z.ZodString;
|
|
78
|
+
timeoutMs: z.ZodNumber;
|
|
79
|
+
lastState: z.ZodString;
|
|
80
|
+
}, z.core.$strip>>;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Error thrown when the deployment returns an error response.
|
|
84
|
+
*/
|
|
85
|
+
export declare const DeploymentCommandError: {
|
|
86
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
87
|
+
commandId: z.ZodString;
|
|
88
|
+
command: z.ZodString;
|
|
89
|
+
errorCode: z.ZodString;
|
|
90
|
+
errorMessage: z.ZodString;
|
|
91
|
+
errorDetails: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
contextSchema: z.ZodObject<{
|
|
94
|
+
commandId: z.ZodString;
|
|
95
|
+
command: z.ZodString;
|
|
96
|
+
errorCode: z.ZodString;
|
|
97
|
+
errorMessage: z.ZodString;
|
|
98
|
+
errorDetails: z.ZodOptional<z.ZodString>;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
create: (context: {
|
|
101
|
+
commandId: string;
|
|
102
|
+
command: string;
|
|
103
|
+
errorCode: string;
|
|
104
|
+
errorMessage: string;
|
|
105
|
+
errorDetails?: string | undefined;
|
|
106
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
107
|
+
commandId: z.ZodString;
|
|
108
|
+
command: z.ZodString;
|
|
109
|
+
errorCode: z.ZodString;
|
|
110
|
+
errorMessage: z.ZodString;
|
|
111
|
+
errorDetails: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, z.core.$strip>>;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Error thrown when command expires before completion.
|
|
116
|
+
*/
|
|
117
|
+
export declare const CommandExpiredError: {
|
|
118
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
119
|
+
commandId: z.ZodString;
|
|
120
|
+
command: z.ZodString;
|
|
121
|
+
}, z.core.$strip>>;
|
|
122
|
+
contextSchema: z.ZodObject<{
|
|
123
|
+
commandId: z.ZodString;
|
|
124
|
+
command: z.ZodString;
|
|
125
|
+
}, z.core.$strip>;
|
|
126
|
+
create: (context: {
|
|
127
|
+
commandId: string;
|
|
128
|
+
command: string;
|
|
129
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
130
|
+
commandId: z.ZodString;
|
|
131
|
+
command: z.ZodString;
|
|
132
|
+
}, z.core.$strip>>;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Error thrown when storage upload/download fails.
|
|
136
|
+
*/
|
|
137
|
+
export declare const StorageOperationFailedError: {
|
|
138
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
139
|
+
operation: z.ZodEnum<{
|
|
140
|
+
upload: "upload";
|
|
141
|
+
download: "download";
|
|
142
|
+
}>;
|
|
143
|
+
url: z.ZodString;
|
|
144
|
+
reason: z.ZodString;
|
|
145
|
+
}, z.core.$strip>>;
|
|
146
|
+
contextSchema: z.ZodObject<{
|
|
147
|
+
operation: z.ZodEnum<{
|
|
148
|
+
upload: "upload";
|
|
149
|
+
download: "download";
|
|
150
|
+
}>;
|
|
151
|
+
url: z.ZodString;
|
|
152
|
+
reason: z.ZodString;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
create: (context: {
|
|
155
|
+
operation: "upload" | "download";
|
|
156
|
+
url: string;
|
|
157
|
+
reason: string;
|
|
158
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
159
|
+
operation: z.ZodEnum<{
|
|
160
|
+
upload: "upload";
|
|
161
|
+
download: "download";
|
|
162
|
+
}>;
|
|
163
|
+
url: z.ZodString;
|
|
164
|
+
reason: z.ZodString;
|
|
165
|
+
}, z.core.$strip>>;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Error thrown when response decoding fails.
|
|
169
|
+
*/
|
|
170
|
+
export declare const ResponseDecodingFailedError: {
|
|
171
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
172
|
+
commandId: z.ZodString;
|
|
173
|
+
command: z.ZodString;
|
|
174
|
+
reason: z.ZodString;
|
|
175
|
+
}, z.core.$strip>>;
|
|
176
|
+
contextSchema: z.ZodObject<{
|
|
177
|
+
commandId: z.ZodString;
|
|
178
|
+
command: z.ZodString;
|
|
179
|
+
reason: z.ZodString;
|
|
180
|
+
}, z.core.$strip>;
|
|
181
|
+
create: (context: {
|
|
182
|
+
commandId: string;
|
|
183
|
+
command: string;
|
|
184
|
+
reason: string;
|
|
185
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
186
|
+
commandId: z.ZodString;
|
|
187
|
+
command: z.ZodString;
|
|
188
|
+
reason: z.ZodString;
|
|
189
|
+
}, z.core.$strip>>;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Error thrown when a command envelope (or a param/response body it carries)
|
|
193
|
+
* fails to decode or validate — malformed inline base64, a storage-mode body
|
|
194
|
+
* missing its presigned request, or an envelope that fails schema validation.
|
|
195
|
+
*
|
|
196
|
+
* The Rust twin (`alien_commands::error::ErrorData::InvalidEnvelope`) raises
|
|
197
|
+
* the identical code (`INVALID_ENVELOPE`) for the same failures, so envelope
|
|
198
|
+
* decode failures stay aligned across both receivers.
|
|
199
|
+
*/
|
|
200
|
+
export declare const InvalidEnvelopeError: {
|
|
201
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
202
|
+
field: z.ZodOptional<z.ZodString>;
|
|
203
|
+
reason: z.ZodString;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
contextSchema: z.ZodObject<{
|
|
206
|
+
field: z.ZodOptional<z.ZodString>;
|
|
207
|
+
reason: z.ZodString;
|
|
208
|
+
}, z.core.$strip>;
|
|
209
|
+
create: (context: {
|
|
210
|
+
reason: string;
|
|
211
|
+
field?: string | undefined;
|
|
212
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
213
|
+
field: z.ZodOptional<z.ZodString>;
|
|
214
|
+
reason: z.ZodString;
|
|
215
|
+
}, z.core.$strip>>;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Error thrown when the pull receiver's environment configuration is missing or
|
|
219
|
+
* invalid. Fails fast (synchronously, from `createCommandReceiver`) and names
|
|
220
|
+
* the offending variable in `context.envVar`.
|
|
221
|
+
*
|
|
222
|
+
* The Rust twin (`alien_commands::Receiver::from_env`) raises the identical code
|
|
223
|
+
* (`COMMAND_RECEIVER_CONFIG_INVALID`) for the same identity, token-source, and
|
|
224
|
+
* tuning variables, so the two receivers reject the same misconfigurations.
|
|
225
|
+
*/
|
|
226
|
+
export declare const CommandReceiverConfigInvalidError: {
|
|
227
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
228
|
+
envVar: z.ZodString;
|
|
229
|
+
reason: z.ZodString;
|
|
230
|
+
}, z.core.$strip>>;
|
|
231
|
+
contextSchema: z.ZodObject<{
|
|
232
|
+
envVar: z.ZodString;
|
|
233
|
+
reason: z.ZodString;
|
|
234
|
+
}, z.core.$strip>;
|
|
235
|
+
create: (context: {
|
|
236
|
+
envVar: string;
|
|
237
|
+
reason: string;
|
|
238
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
239
|
+
envVar: z.ZodString;
|
|
240
|
+
reason: z.ZodString;
|
|
241
|
+
}, z.core.$strip>>;
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* Error thrown when Manager returns an HTTP error.
|
|
245
|
+
*/
|
|
246
|
+
export declare const ManagerHttpError: {
|
|
247
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
248
|
+
method: z.ZodString;
|
|
249
|
+
url: z.ZodString;
|
|
250
|
+
status: z.ZodNumber;
|
|
251
|
+
statusText: z.ZodString;
|
|
252
|
+
body: z.ZodOptional<z.ZodString>;
|
|
253
|
+
}, z.core.$strip>>;
|
|
254
|
+
contextSchema: z.ZodObject<{
|
|
255
|
+
method: z.ZodString;
|
|
256
|
+
url: z.ZodString;
|
|
257
|
+
status: z.ZodNumber;
|
|
258
|
+
statusText: z.ZodString;
|
|
259
|
+
body: z.ZodOptional<z.ZodString>;
|
|
260
|
+
}, z.core.$strip>;
|
|
261
|
+
create: (context: {
|
|
262
|
+
method: string;
|
|
263
|
+
url: string;
|
|
264
|
+
status: number;
|
|
265
|
+
statusText: string;
|
|
266
|
+
body?: string | undefined;
|
|
267
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
268
|
+
method: z.ZodString;
|
|
269
|
+
url: z.ZodString;
|
|
270
|
+
status: z.ZodNumber;
|
|
271
|
+
statusText: z.ZodString;
|
|
272
|
+
body: z.ZodOptional<z.ZodString>;
|
|
273
|
+
}, z.core.$strip>>;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Error thrown when a 2xx response body from the command server fails to parse
|
|
277
|
+
* or validate against its wire schema — a malformed/unexpected JSON shape
|
|
278
|
+
* surfaces here as a typed error instead of a downstream `TypeError` when a
|
|
279
|
+
* missing field is dereferenced.
|
|
280
|
+
*/
|
|
281
|
+
export declare const MalformedResponseError: {
|
|
282
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
283
|
+
method: z.ZodString;
|
|
284
|
+
url: z.ZodString;
|
|
285
|
+
reason: z.ZodString;
|
|
286
|
+
}, z.core.$strip>>;
|
|
287
|
+
contextSchema: z.ZodObject<{
|
|
288
|
+
method: z.ZodString;
|
|
289
|
+
url: z.ZodString;
|
|
290
|
+
reason: z.ZodString;
|
|
291
|
+
}, z.core.$strip>;
|
|
292
|
+
create: (context: {
|
|
293
|
+
method: string;
|
|
294
|
+
url: string;
|
|
295
|
+
reason: string;
|
|
296
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
297
|
+
method: z.ZodString;
|
|
298
|
+
url: z.ZodString;
|
|
299
|
+
reason: z.ZodString;
|
|
300
|
+
}, z.core.$strip>>;
|
|
301
|
+
};
|
|
302
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAA;AAE3B;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;CAYrC,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;CAWnC,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;CAa9B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAcjC,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;CAU9B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWtC,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;CAWtC,CAAA;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;CAU/B,CAAA;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;CAU5C,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAc3B,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;CAWjC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@alienplatform/commands` — the public command package for TypeScript.
|
|
3
|
+
*
|
|
4
|
+
* Pure `fetch` over the command wire protocol: the command **sender**
|
|
5
|
+
* ({@link CommandsClient}, with {@link CommandsClient.target}) and the
|
|
6
|
+
* non-Worker pull **receiver** (`createCommandReceiver`).
|
|
7
|
+
* No native code, no gRPC, no bindings.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { CommandsClient } from "@alienplatform/commands"
|
|
12
|
+
*
|
|
13
|
+
* const commands = new CommandsClient({
|
|
14
|
+
* managerUrl: "https://manager.example.com",
|
|
15
|
+
* deploymentId: "deployment_123",
|
|
16
|
+
* token: "bearer_token",
|
|
17
|
+
* })
|
|
18
|
+
*
|
|
19
|
+
* const result = await commands.invoke("generate-report", {
|
|
20
|
+
* startDate: "2024-01-01",
|
|
21
|
+
* endDate: "2024-01-31",
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* // Or scoped to a specific target resource:
|
|
25
|
+
* const scoped = commands.target("container-7")
|
|
26
|
+
* await scoped.invoke("restart", {})
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export { CommandsClient, TargetedCommands } from "./client.js";
|
|
30
|
+
export type { CommandsClientConfig, InvokeOptions } from "./client.js";
|
|
31
|
+
export { createCommandReceiver } from "./receiver.js";
|
|
32
|
+
export type { CommandContext, CommandHandler, CommandReceiver, CommandReceiverOptions, } from "./receiver.js";
|
|
33
|
+
export { CommandCreationFailedError, CommandExpiredError, CommandReceiverConfigInvalidError, CommandStatusFailedError, CommandTimeoutError, DeploymentCommandError, InvalidEnvelopeError, ManagerHttpError, MalformedResponseError, ResponseDecodingFailedError, StorageOperationFailedError, } from "./errors.js";
|
|
34
|
+
export type { BodySpec, CommandResponse, CommandState, CommandStatusResponse, CommandTarget, CommandTargetType, CreateCommandRequest, CreateCommandResponse, Envelope, ErrorResponse, LeaseInfo, LeaseRequest, LeaseResponse, PresignedRequest, ReleaseRequest, ResponseHandling, StorageUpload, SubmitResponseRequest, UploadCompleteRequest, UploadCompleteResponse, } from "./protocol.js";
|
|
35
|
+
export { AlienError, defineError } from "@alienplatform/core";
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9D,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,YAAY,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,sBAAsB,GACvB,MAAM,eAAe,CAAA;AAGtB,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,iCAAiC,EACjC,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AAGpB,YAAY,EACV,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,QAAQ,EACR,aAAa,EACb,SAAS,EACT,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA"}
|