@alienplatform/sdk 1.14.1 → 2.0.0
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/dist.js +371 -275
- package/dist/index.d.ts +22 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -14356
- package/dist/native.d.ts +26 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +2 -0
- package/dist/worker-runtime/channel.d.ts +25 -0
- package/dist/worker-runtime/channel.d.ts.map +1 -0
- package/dist/worker-runtime/errors.d.ts +79 -0
- package/dist/worker-runtime/errors.d.ts.map +1 -0
- package/dist/worker-runtime/event-loop.d.ts +43 -0
- package/dist/worker-runtime/event-loop.d.ts.map +1 -0
- package/dist/{generated → worker-runtime/generated}/control.d.ts +15 -15
- package/dist/worker-runtime/generated/control.d.ts.map +1 -0
- package/dist/worker-runtime/generated/google/protobuf/duration.d.ts.map +1 -0
- package/dist/worker-runtime/generated/google/protobuf/timestamp.d.ts.map +1 -0
- package/dist/{generated → worker-runtime/generated}/wait_until.d.ts +29 -29
- package/dist/worker-runtime/generated/wait_until.d.ts.map +1 -0
- package/dist/worker-runtime/grpc-utils.d.ts +23 -0
- package/dist/worker-runtime/grpc-utils.d.ts.map +1 -0
- package/dist/worker-runtime/index.d.ts +33 -0
- package/dist/worker-runtime/index.d.ts.map +1 -0
- package/dist/{src.js → worker-runtime/index.js} +9370 -4035
- package/dist/worker-runtime/registry.d.ts +169 -0
- package/dist/worker-runtime/registry.d.ts.map +1 -0
- package/dist/worker-runtime/service-definitions.d.ts +12 -0
- package/dist/worker-runtime/service-definitions.d.ts.map +1 -0
- package/dist/worker-runtime/wait-until-manager.d.ts +34 -0
- package/dist/worker-runtime/wait-until-manager.d.ts.map +1 -0
- package/package.json +18 -38
- package/.turbo/turbo-build.log +0 -30
- package/AGENTS.md +0 -70
- package/dist/bearerTokenAuthenticationPolicy.js +0 -3028
- package/dist/bindings/artifact-registry.d.ts +0 -88
- package/dist/bindings/artifact-registry.d.ts.map +0 -1
- package/dist/bindings/build.d.ts +0 -67
- package/dist/bindings/build.d.ts.map +0 -1
- package/dist/bindings/index.d.ts +0 -13
- package/dist/bindings/index.d.ts.map +0 -1
- package/dist/bindings/kv.d.ts +0 -113
- package/dist/bindings/kv.d.ts.map +0 -1
- package/dist/bindings/postgres.d.ts +0 -90
- package/dist/bindings/postgres.d.ts.map +0 -1
- package/dist/bindings/postgres.test.d.ts +0 -2
- package/dist/bindings/postgres.test.d.ts.map +0 -1
- package/dist/bindings/queue.d.ts +0 -81
- package/dist/bindings/queue.d.ts.map +0 -1
- package/dist/bindings/service-account.d.ts +0 -46
- package/dist/bindings/service-account.d.ts.map +0 -1
- package/dist/bindings/storage.d.ts +0 -164
- package/dist/bindings/storage.d.ts.map +0 -1
- package/dist/bindings/vault.d.ts +0 -65
- package/dist/bindings/vault.d.ts.map +0 -1
- package/dist/bindings/worker.d.ts +0 -72
- package/dist/bindings/worker.d.ts.map +0 -1
- package/dist/channel.d.ts +0 -39
- package/dist/channel.d.ts.map +0 -1
- package/dist/checksum.js +0 -6176
- package/dist/commands/client.d.ts +0 -47
- package/dist/commands/client.d.ts.map +0 -1
- package/dist/commands/errors.d.ts +0 -198
- package/dist/commands/errors.d.ts.map +0 -1
- package/dist/commands/index.d.ts +0 -23
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js +0 -387
- package/dist/commands/types.d.ts +0 -40
- package/dist/commands/types.d.ts.map +0 -1
- package/dist/commands.d.ts +0 -55
- package/dist/commands.d.ts.map +0 -1
- package/dist/context.d.ts +0 -182
- package/dist/context.d.ts.map +0 -1
- package/dist/dist-cjs.js +0 -15258
- package/dist/dist2.js +0 -1239
- package/dist/errors.d.ts +0 -359
- package/dist/errors.d.ts.map +0 -1
- package/dist/es5.js +0 -1720
- package/dist/esm.js +0 -18068
- package/dist/esm2.js +0 -3166
- package/dist/event-streams.js +0 -770
- package/dist/events.d.ts +0 -163
- package/dist/events.d.ts.map +0 -1
- package/dist/generated/artifact_registry.d.ts +0 -302
- package/dist/generated/artifact_registry.d.ts.map +0 -1
- package/dist/generated/build.d.ts +0 -184
- package/dist/generated/build.d.ts.map +0 -1
- package/dist/generated/container.d.ts +0 -101
- package/dist/generated/container.d.ts.map +0 -1
- package/dist/generated/control.d.ts.map +0 -1
- package/dist/generated/google/protobuf/duration.d.ts.map +0 -1
- package/dist/generated/google/protobuf/timestamp.d.ts.map +0 -1
- package/dist/generated/kv.d.ts +0 -182
- package/dist/generated/kv.d.ts.map +0 -1
- package/dist/generated/queue.d.ts +0 -127
- package/dist/generated/queue.d.ts.map +0 -1
- package/dist/generated/service_account.d.ts +0 -112
- package/dist/generated/service_account.d.ts.map +0 -1
- package/dist/generated/storage.d.ts +0 -784
- package/dist/generated/storage.d.ts.map +0 -1
- package/dist/generated/vault.d.ts +0 -107
- package/dist/generated/vault.d.ts.map +0 -1
- package/dist/generated/wait_until.d.ts.map +0 -1
- package/dist/generated/worker.d.ts +0 -107
- package/dist/generated/worker.d.ts.map +0 -1
- package/dist/global.d.ts +0 -208
- package/dist/global.d.ts.map +0 -1
- package/dist/grpc-utils.d.ts +0 -25
- package/dist/grpc-utils.d.ts.map +0 -1
- package/dist/jws.js +0 -611
- package/dist/open.js +0 -461
- package/dist/rolldown-runtime.js +0 -44
- package/dist/src2.js +0 -114032
- package/dist/types.d.ts +0 -337
- package/dist/types.d.ts.map +0 -1
- package/dist/wait-until.d.ts +0 -115
- package/dist/wait-until.d.ts.map +0 -1
- package/scripts/generate-proto.sh +0 -46
- package/src/bindings/AGENTS.md +0 -105
- package/src/bindings/artifact-registry.ts +0 -317
- package/src/bindings/build.ts +0 -195
- package/src/bindings/index.ts +0 -13
- package/src/bindings/kv.ts +0 -240
- package/src/bindings/postgres.test.ts +0 -17
- package/src/bindings/postgres.ts +0 -446
- package/src/bindings/queue.ts +0 -191
- package/src/bindings/service-account.ts +0 -113
- package/src/bindings/storage.ts +0 -536
- package/src/bindings/vault.ts +0 -133
- package/src/bindings/worker.ts +0 -164
- package/src/channel.ts +0 -102
- package/src/commands/client.ts +0 -446
- package/src/commands/errors.ts +0 -126
- package/src/commands/index.ts +0 -41
- package/src/commands/types.ts +0 -52
- package/src/commands.ts +0 -76
- package/src/context.ts +0 -368
- package/src/errors.ts +0 -280
- package/src/events.ts +0 -511
- package/src/generated/artifact_registry.ts +0 -2096
- package/src/generated/build.ts +0 -1311
- package/src/generated/container.ts +0 -503
- package/src/generated/control.ts +0 -2018
- package/src/generated/google/protobuf/duration.ts +0 -196
- package/src/generated/google/protobuf/timestamp.ts +0 -226
- package/src/generated/kv.ts +0 -1169
- package/src/generated/queue.ts +0 -753
- package/src/generated/service_account.ts +0 -814
- package/src/generated/storage.ts +0 -3820
- package/src/generated/vault.ts +0 -543
- package/src/generated/wait_until.ts +0 -829
- package/src/generated/worker.ts +0 -759
- package/src/global.ts +0 -287
- package/src/grpc-utils.ts +0 -159
- package/src/index.ts +0 -160
- package/src/types.ts +0 -397
- package/src/wait-until.ts +0 -273
- package/tsconfig.json +0 -8
- package/tsdown.config.ts +0 -17
- /package/dist/{generated → worker-runtime/generated}/google/protobuf/duration.d.ts +0 -0
- /package/dist/{generated → worker-runtime/generated}/google/protobuf/timestamp.d.ts +0 -0
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Commands Client - Lightweight client for deployment command invocation
|
|
3
|
-
*
|
|
4
|
-
* Handles command invocation with automatic:
|
|
5
|
-
* - Base64 encoding/decoding of params and responses
|
|
6
|
-
* - Large payload upload/download via storage
|
|
7
|
-
* - Polling with exponential backoff
|
|
8
|
-
* - Error handling and timeout
|
|
9
|
-
*/
|
|
10
|
-
import type { CommandsClientConfig, InvokeOptions } from "./types.js";
|
|
11
|
-
/**
|
|
12
|
-
* Commands client for invoking deployment commands
|
|
13
|
-
*/
|
|
14
|
-
export declare class CommandsClient {
|
|
15
|
-
private readonly managerUrl;
|
|
16
|
-
private readonly deploymentId;
|
|
17
|
-
private readonly token;
|
|
18
|
-
private readonly defaultTimeout;
|
|
19
|
-
private readonly allowLocalStorage;
|
|
20
|
-
constructor(config: CommandsClientConfig);
|
|
21
|
-
/**
|
|
22
|
-
* Invoke a command on the deployment and wait for response
|
|
23
|
-
*
|
|
24
|
-
* @param command - Command name (e.g., "generate-report")
|
|
25
|
-
* @param params - Command parameters (JSON-serializable)
|
|
26
|
-
* @param options - Invocation options
|
|
27
|
-
* @returns Decoded response data
|
|
28
|
-
*/
|
|
29
|
-
invoke<TParams = unknown, TResponse = unknown>(command: string, params: TParams, options?: InvokeOptions): Promise<TResponse>;
|
|
30
|
-
/**
|
|
31
|
-
* Create a command
|
|
32
|
-
*/
|
|
33
|
-
private createCommand;
|
|
34
|
-
/**
|
|
35
|
-
* Get command status
|
|
36
|
-
*/
|
|
37
|
-
private getCommandStatus;
|
|
38
|
-
/**
|
|
39
|
-
* Handle terminal state and return response
|
|
40
|
-
*/
|
|
41
|
-
private handleTerminalState;
|
|
42
|
-
/**
|
|
43
|
-
* Sleep helper
|
|
44
|
-
*/
|
|
45
|
-
private sleep;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/commands/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,OAAO,KAAK,EAKV,oBAAoB,EAEpB,aAAa,EACd,MAAM,YAAY,CAAA;AA0LnB;;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;gBAE/B,MAAM,EAAE,oBAAoB;IAQxC;;;;;;;OAOG;IACG,MAAM,CAAC,OAAO,GAAG,OAAO,EAAE,SAAS,GAAG,OAAO,EACjD,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,SAAS,CAAC;IAsCrB;;OAEG;YACW,aAAa;IAsD3B;;OAEG;YACW,gBAAgB;IAkC9B;;OAEG;YACW,mBAAmB;IA4DjC;;OAEG;IACH,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Commands Client Error Definitions
|
|
3
|
-
*/
|
|
4
|
-
import { z } from "zod/v4";
|
|
5
|
-
/**
|
|
6
|
-
* Error thrown when command creation fails.
|
|
7
|
-
*/
|
|
8
|
-
export declare const CommandCreationFailedError: {
|
|
9
|
-
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
10
|
-
deploymentId: z.ZodString;
|
|
11
|
-
command: z.ZodString;
|
|
12
|
-
reason: z.ZodString;
|
|
13
|
-
}, z.core.$strip>>;
|
|
14
|
-
contextSchema: z.ZodObject<{
|
|
15
|
-
deploymentId: z.ZodString;
|
|
16
|
-
command: z.ZodString;
|
|
17
|
-
reason: z.ZodString;
|
|
18
|
-
}, z.core.$strip>;
|
|
19
|
-
create: (context: {
|
|
20
|
-
deploymentId: string;
|
|
21
|
-
command: string;
|
|
22
|
-
reason: string;
|
|
23
|
-
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
24
|
-
deploymentId: z.ZodString;
|
|
25
|
-
command: z.ZodString;
|
|
26
|
-
reason: z.ZodString;
|
|
27
|
-
}, z.core.$strip>>;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Error thrown when command execution times out.
|
|
31
|
-
*/
|
|
32
|
-
export declare const CommandTimeoutError: {
|
|
33
|
-
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
34
|
-
commandId: z.ZodString;
|
|
35
|
-
command: z.ZodString;
|
|
36
|
-
timeoutMs: z.ZodNumber;
|
|
37
|
-
lastState: z.ZodString;
|
|
38
|
-
}, z.core.$strip>>;
|
|
39
|
-
contextSchema: z.ZodObject<{
|
|
40
|
-
commandId: z.ZodString;
|
|
41
|
-
command: z.ZodString;
|
|
42
|
-
timeoutMs: z.ZodNumber;
|
|
43
|
-
lastState: z.ZodString;
|
|
44
|
-
}, z.core.$strip>;
|
|
45
|
-
create: (context: {
|
|
46
|
-
commandId: string;
|
|
47
|
-
command: string;
|
|
48
|
-
timeoutMs: number;
|
|
49
|
-
lastState: string;
|
|
50
|
-
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
51
|
-
commandId: z.ZodString;
|
|
52
|
-
command: z.ZodString;
|
|
53
|
-
timeoutMs: z.ZodNumber;
|
|
54
|
-
lastState: z.ZodString;
|
|
55
|
-
}, z.core.$strip>>;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Error thrown when the deployment returns an error response.
|
|
59
|
-
*/
|
|
60
|
-
export declare const DeploymentCommandError: {
|
|
61
|
-
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
62
|
-
commandId: z.ZodString;
|
|
63
|
-
command: z.ZodString;
|
|
64
|
-
errorCode: z.ZodString;
|
|
65
|
-
errorMessage: z.ZodString;
|
|
66
|
-
errorDetails: z.ZodOptional<z.ZodString>;
|
|
67
|
-
}, z.core.$strip>>;
|
|
68
|
-
contextSchema: z.ZodObject<{
|
|
69
|
-
commandId: z.ZodString;
|
|
70
|
-
command: z.ZodString;
|
|
71
|
-
errorCode: z.ZodString;
|
|
72
|
-
errorMessage: z.ZodString;
|
|
73
|
-
errorDetails: z.ZodOptional<z.ZodString>;
|
|
74
|
-
}, z.core.$strip>;
|
|
75
|
-
create: (context: {
|
|
76
|
-
commandId: string;
|
|
77
|
-
command: string;
|
|
78
|
-
errorCode: string;
|
|
79
|
-
errorMessage: string;
|
|
80
|
-
errorDetails?: string | undefined;
|
|
81
|
-
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
82
|
-
commandId: z.ZodString;
|
|
83
|
-
command: z.ZodString;
|
|
84
|
-
errorCode: z.ZodString;
|
|
85
|
-
errorMessage: z.ZodString;
|
|
86
|
-
errorDetails: z.ZodOptional<z.ZodString>;
|
|
87
|
-
}, z.core.$strip>>;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Error thrown when command expires before completion.
|
|
91
|
-
*/
|
|
92
|
-
export declare const CommandExpiredError: {
|
|
93
|
-
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
94
|
-
commandId: z.ZodString;
|
|
95
|
-
command: z.ZodString;
|
|
96
|
-
}, z.core.$strip>>;
|
|
97
|
-
contextSchema: z.ZodObject<{
|
|
98
|
-
commandId: z.ZodString;
|
|
99
|
-
command: z.ZodString;
|
|
100
|
-
}, z.core.$strip>;
|
|
101
|
-
create: (context: {
|
|
102
|
-
commandId: string;
|
|
103
|
-
command: string;
|
|
104
|
-
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
105
|
-
commandId: z.ZodString;
|
|
106
|
-
command: z.ZodString;
|
|
107
|
-
}, z.core.$strip>>;
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Error thrown when storage upload/download fails.
|
|
111
|
-
*/
|
|
112
|
-
export declare const StorageOperationFailedError: {
|
|
113
|
-
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
114
|
-
operation: z.ZodEnum<{
|
|
115
|
-
upload: "upload";
|
|
116
|
-
download: "download";
|
|
117
|
-
}>;
|
|
118
|
-
url: z.ZodString;
|
|
119
|
-
reason: z.ZodString;
|
|
120
|
-
}, z.core.$strip>>;
|
|
121
|
-
contextSchema: z.ZodObject<{
|
|
122
|
-
operation: z.ZodEnum<{
|
|
123
|
-
upload: "upload";
|
|
124
|
-
download: "download";
|
|
125
|
-
}>;
|
|
126
|
-
url: z.ZodString;
|
|
127
|
-
reason: z.ZodString;
|
|
128
|
-
}, z.core.$strip>;
|
|
129
|
-
create: (context: {
|
|
130
|
-
operation: "upload" | "download";
|
|
131
|
-
url: string;
|
|
132
|
-
reason: string;
|
|
133
|
-
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
134
|
-
operation: z.ZodEnum<{
|
|
135
|
-
upload: "upload";
|
|
136
|
-
download: "download";
|
|
137
|
-
}>;
|
|
138
|
-
url: z.ZodString;
|
|
139
|
-
reason: z.ZodString;
|
|
140
|
-
}, z.core.$strip>>;
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* Error thrown when response decoding fails.
|
|
144
|
-
*/
|
|
145
|
-
export declare const ResponseDecodingFailedError: {
|
|
146
|
-
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
147
|
-
commandId: z.ZodString;
|
|
148
|
-
command: z.ZodString;
|
|
149
|
-
reason: z.ZodString;
|
|
150
|
-
}, z.core.$strip>>;
|
|
151
|
-
contextSchema: z.ZodObject<{
|
|
152
|
-
commandId: z.ZodString;
|
|
153
|
-
command: z.ZodString;
|
|
154
|
-
reason: z.ZodString;
|
|
155
|
-
}, z.core.$strip>;
|
|
156
|
-
create: (context: {
|
|
157
|
-
commandId: string;
|
|
158
|
-
command: string;
|
|
159
|
-
reason: string;
|
|
160
|
-
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
161
|
-
commandId: z.ZodString;
|
|
162
|
-
command: z.ZodString;
|
|
163
|
-
reason: z.ZodString;
|
|
164
|
-
}, z.core.$strip>>;
|
|
165
|
-
};
|
|
166
|
-
/**
|
|
167
|
-
* Error thrown when Manager returns an HTTP error.
|
|
168
|
-
*/
|
|
169
|
-
export declare const ManagerHttpError: {
|
|
170
|
-
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
171
|
-
method: z.ZodString;
|
|
172
|
-
url: z.ZodString;
|
|
173
|
-
status: z.ZodNumber;
|
|
174
|
-
statusText: z.ZodString;
|
|
175
|
-
body: z.ZodOptional<z.ZodString>;
|
|
176
|
-
}, z.core.$strip>>;
|
|
177
|
-
contextSchema: z.ZodObject<{
|
|
178
|
-
method: z.ZodString;
|
|
179
|
-
url: z.ZodString;
|
|
180
|
-
status: z.ZodNumber;
|
|
181
|
-
statusText: z.ZodString;
|
|
182
|
-
body: z.ZodOptional<z.ZodString>;
|
|
183
|
-
}, z.core.$strip>;
|
|
184
|
-
create: (context: {
|
|
185
|
-
method: string;
|
|
186
|
-
url: string;
|
|
187
|
-
status: number;
|
|
188
|
-
statusText: string;
|
|
189
|
-
body?: string | undefined;
|
|
190
|
-
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
191
|
-
method: z.ZodString;
|
|
192
|
-
url: z.ZodString;
|
|
193
|
-
status: z.ZodNumber;
|
|
194
|
-
statusText: z.ZodString;
|
|
195
|
-
body: z.ZodOptional<z.ZodString>;
|
|
196
|
-
}, z.core.$strip>>;
|
|
197
|
-
};
|
|
198
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/commands/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;CAYrC,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;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAc3B,CAAA"}
|
package/dist/commands/index.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Commands client — invoke commands on remote Alien deployments.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```typescript
|
|
6
|
-
* import { CommandsClient } from "@alienplatform/sdk/commands"
|
|
7
|
-
*
|
|
8
|
-
* const commands = new CommandsClient({
|
|
9
|
-
* managerUrl: "https://manager.example.com",
|
|
10
|
-
* deploymentId: "deployment_123",
|
|
11
|
-
* token: "bearer_token",
|
|
12
|
-
* })
|
|
13
|
-
*
|
|
14
|
-
* const result = await commands.invoke("generate-report", {
|
|
15
|
-
* startDate: "2024-01-01",
|
|
16
|
-
* endDate: "2024-01-31",
|
|
17
|
-
* })
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export { CommandsClient } from "./client.js";
|
|
21
|
-
export type { CommandsClientConfig, BodySpec, CommandResponse, CommandState, CommandStatusResponse, CreateCommandResponse, InvokeOptions, PresignedRequest, StorageUpload, } from "./types.js";
|
|
22
|
-
export { DeploymentCommandError, ManagerHttpError, CommandCreationFailedError, CommandExpiredError, CommandTimeoutError, ResponseDecodingFailedError, StorageOperationFailedError, } from "./errors.js";
|
|
23
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,YAAY,EACV,oBAAoB,EACpB,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,aAAa,GACd,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,aAAa,CAAA"}
|
package/dist/commands/index.js
DELETED
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
import { c as string, n as defineError, o as number, r as _enum, s as object, t as AlienError } from "../dist.js";
|
|
2
|
-
//#region src/commands/errors.ts
|
|
3
|
-
/**
|
|
4
|
-
* Commands Client Error Definitions
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Error thrown when command creation fails.
|
|
8
|
-
*/
|
|
9
|
-
const CommandCreationFailedError = defineError({
|
|
10
|
-
code: "COMMAND_CREATION_FAILED",
|
|
11
|
-
context: object({
|
|
12
|
-
deploymentId: string(),
|
|
13
|
-
command: string(),
|
|
14
|
-
reason: string()
|
|
15
|
-
}),
|
|
16
|
-
message: ({ deploymentId, command, reason }) => `Failed to create command '${command}' for deployment '${deploymentId}': ${reason}`,
|
|
17
|
-
retryable: false,
|
|
18
|
-
internal: false,
|
|
19
|
-
httpStatusCode: 500
|
|
20
|
-
});
|
|
21
|
-
/**
|
|
22
|
-
* Error thrown when command execution times out.
|
|
23
|
-
*/
|
|
24
|
-
const CommandTimeoutError = defineError({
|
|
25
|
-
code: "COMMAND_TIMEOUT",
|
|
26
|
-
context: object({
|
|
27
|
-
commandId: string(),
|
|
28
|
-
command: string(),
|
|
29
|
-
timeoutMs: number(),
|
|
30
|
-
lastState: string()
|
|
31
|
-
}),
|
|
32
|
-
message: ({ command, timeoutMs, lastState }) => `Command '${command}' timed out after ${timeoutMs}ms (last state: ${lastState})`,
|
|
33
|
-
retryable: true,
|
|
34
|
-
internal: false,
|
|
35
|
-
httpStatusCode: 504
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
* Error thrown when the deployment returns an error response.
|
|
39
|
-
*/
|
|
40
|
-
const DeploymentCommandError = defineError({
|
|
41
|
-
code: "DEPLOYMENT_COMMAND_ERROR",
|
|
42
|
-
context: object({
|
|
43
|
-
commandId: string(),
|
|
44
|
-
command: string(),
|
|
45
|
-
errorCode: string(),
|
|
46
|
-
errorMessage: string(),
|
|
47
|
-
errorDetails: string().optional()
|
|
48
|
-
}),
|
|
49
|
-
message: ({ command, errorCode, errorMessage }) => `Deployment command '${command}' failed: [${errorCode}] ${errorMessage}`,
|
|
50
|
-
retryable: false,
|
|
51
|
-
internal: false,
|
|
52
|
-
httpStatusCode: 500
|
|
53
|
-
});
|
|
54
|
-
/**
|
|
55
|
-
* Error thrown when command expires before completion.
|
|
56
|
-
*/
|
|
57
|
-
const CommandExpiredError = defineError({
|
|
58
|
-
code: "COMMAND_EXPIRED",
|
|
59
|
-
context: object({
|
|
60
|
-
commandId: string(),
|
|
61
|
-
command: string()
|
|
62
|
-
}),
|
|
63
|
-
message: ({ command }) => `Command '${command}' expired before completion`,
|
|
64
|
-
retryable: false,
|
|
65
|
-
internal: false,
|
|
66
|
-
httpStatusCode: 410
|
|
67
|
-
});
|
|
68
|
-
/**
|
|
69
|
-
* Error thrown when storage upload/download fails.
|
|
70
|
-
*/
|
|
71
|
-
const StorageOperationFailedError = defineError({
|
|
72
|
-
code: "STORAGE_OPERATION_FAILED",
|
|
73
|
-
context: object({
|
|
74
|
-
operation: _enum(["upload", "download"]),
|
|
75
|
-
url: string(),
|
|
76
|
-
reason: string()
|
|
77
|
-
}),
|
|
78
|
-
message: ({ operation, reason }) => `Storage ${operation} failed: ${reason}`,
|
|
79
|
-
retryable: true,
|
|
80
|
-
internal: false,
|
|
81
|
-
httpStatusCode: 500
|
|
82
|
-
});
|
|
83
|
-
/**
|
|
84
|
-
* Error thrown when response decoding fails.
|
|
85
|
-
*/
|
|
86
|
-
const ResponseDecodingFailedError = defineError({
|
|
87
|
-
code: "RESPONSE_DECODING_FAILED",
|
|
88
|
-
context: object({
|
|
89
|
-
commandId: string(),
|
|
90
|
-
command: string(),
|
|
91
|
-
reason: string()
|
|
92
|
-
}),
|
|
93
|
-
message: ({ command, reason }) => `Failed to decode response for command '${command}': ${reason}`,
|
|
94
|
-
retryable: false,
|
|
95
|
-
internal: false,
|
|
96
|
-
httpStatusCode: 500
|
|
97
|
-
});
|
|
98
|
-
/**
|
|
99
|
-
* Error thrown when Manager returns an HTTP error.
|
|
100
|
-
*/
|
|
101
|
-
const ManagerHttpError = defineError({
|
|
102
|
-
code: "MANAGER_HTTP_ERROR",
|
|
103
|
-
context: object({
|
|
104
|
-
method: string(),
|
|
105
|
-
url: string(),
|
|
106
|
-
status: number(),
|
|
107
|
-
statusText: string(),
|
|
108
|
-
body: string().optional()
|
|
109
|
-
}),
|
|
110
|
-
message: ({ method, url, status, statusText }) => `Manager ${method} ${url} failed: ${status} ${statusText}`,
|
|
111
|
-
retryable: false,
|
|
112
|
-
internal: false,
|
|
113
|
-
httpStatusCode: 500
|
|
114
|
-
});
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/commands/client.ts
|
|
117
|
-
/**
|
|
118
|
-
* Commands Client - Lightweight client for deployment command invocation
|
|
119
|
-
*
|
|
120
|
-
* Handles command invocation with automatic:
|
|
121
|
-
* - Base64 encoding/decoding of params and responses
|
|
122
|
-
* - Large payload upload/download via storage
|
|
123
|
-
* - Polling with exponential backoff
|
|
124
|
-
* - Error handling and timeout
|
|
125
|
-
*/
|
|
126
|
-
/**
|
|
127
|
-
* Base64 encode data
|
|
128
|
-
*/
|
|
129
|
-
function base64Encode(data) {
|
|
130
|
-
const json = typeof data === "string" ? data : JSON.stringify(data);
|
|
131
|
-
if (typeof btoa !== "undefined") return btoa(json);
|
|
132
|
-
return Buffer.from(json, "utf-8").toString("base64");
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Base64 decode data
|
|
136
|
-
*/
|
|
137
|
-
function base64Decode(encoded) {
|
|
138
|
-
if (typeof atob !== "undefined") return atob(encoded);
|
|
139
|
-
return Buffer.from(encoded, "base64").toString("utf-8");
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Create inline body spec. Always sends inline — the server handles storage
|
|
143
|
-
* decisions transparently (auto-promoting to blob if needed).
|
|
144
|
-
*/
|
|
145
|
-
function createBodySpec(data) {
|
|
146
|
-
return {
|
|
147
|
-
mode: "inline",
|
|
148
|
-
inlineBase64: base64Encode(typeof data === "string" ? data : JSON.stringify(data))
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Decode response body spec
|
|
153
|
-
*/
|
|
154
|
-
async function decodeBodySpec(body, commandId, command, allowLocalStorage) {
|
|
155
|
-
if (body.mode === "inline") {
|
|
156
|
-
const json = base64Decode(body.inlineBase64);
|
|
157
|
-
return JSON.parse(json);
|
|
158
|
-
}
|
|
159
|
-
if (body.mode === "storage") {
|
|
160
|
-
if (!body.storageGetRequest) throw new AlienError(ResponseDecodingFailedError.create({
|
|
161
|
-
commandId,
|
|
162
|
-
command,
|
|
163
|
-
reason: "Storage response missing storageGetRequest"
|
|
164
|
-
}));
|
|
165
|
-
const request = body.storageGetRequest;
|
|
166
|
-
const expiration = new Date(request.expiration);
|
|
167
|
-
if (Date.now() > expiration.getTime()) throw new AlienError(StorageOperationFailedError.create({
|
|
168
|
-
operation: "download",
|
|
169
|
-
url: request.backend.type === "http" ? request.backend.url : "local",
|
|
170
|
-
reason: `Presigned request expired at ${expiration.toISOString()}`
|
|
171
|
-
}));
|
|
172
|
-
if (request.backend.type === "http") try {
|
|
173
|
-
const response = await fetch(request.backend.url, {
|
|
174
|
-
method: request.backend.method,
|
|
175
|
-
headers: request.backend.headers
|
|
176
|
-
});
|
|
177
|
-
if (!response.ok) throw new AlienError(StorageOperationFailedError.create({
|
|
178
|
-
operation: "download",
|
|
179
|
-
url: request.backend.url,
|
|
180
|
-
reason: `HTTP ${response.status} ${response.statusText}`
|
|
181
|
-
}));
|
|
182
|
-
const text = await response.text();
|
|
183
|
-
return JSON.parse(text);
|
|
184
|
-
} catch (error) {
|
|
185
|
-
if (error instanceof AlienError) throw error;
|
|
186
|
-
throw (await AlienError.from(error)).withContext(StorageOperationFailedError.create({
|
|
187
|
-
operation: "download",
|
|
188
|
-
url: request.backend.url,
|
|
189
|
-
reason: error instanceof Error ? error.message : String(error)
|
|
190
|
-
}));
|
|
191
|
-
}
|
|
192
|
-
else if (request.backend.type === "local") {
|
|
193
|
-
if (!allowLocalStorage) throw new AlienError(StorageOperationFailedError.create({
|
|
194
|
-
operation: "download",
|
|
195
|
-
url: `local://${request.backend.filePath}`,
|
|
196
|
-
reason: "Local storage backend not enabled (set allowLocalStorage: true for local dev)"
|
|
197
|
-
}));
|
|
198
|
-
const filePath = request.backend.filePath;
|
|
199
|
-
if (filePath.includes("..")) throw new AlienError(StorageOperationFailedError.create({
|
|
200
|
-
operation: "download",
|
|
201
|
-
url: `local://${filePath}`,
|
|
202
|
-
reason: "Path traversal not allowed in local storage paths"
|
|
203
|
-
}));
|
|
204
|
-
try {
|
|
205
|
-
const { readFile } = await import("node:fs/promises");
|
|
206
|
-
const content = await readFile(filePath, "utf-8");
|
|
207
|
-
return JSON.parse(content);
|
|
208
|
-
} catch (error) {
|
|
209
|
-
if (error instanceof AlienError) throw error;
|
|
210
|
-
throw (await AlienError.from(error)).withContext(StorageOperationFailedError.create({
|
|
211
|
-
operation: "download",
|
|
212
|
-
url: `local://${filePath}`,
|
|
213
|
-
reason: error instanceof Error ? error.message : String(error)
|
|
214
|
-
}));
|
|
215
|
-
}
|
|
216
|
-
} else throw new AlienError(StorageOperationFailedError.create({
|
|
217
|
-
operation: "download",
|
|
218
|
-
url: "unknown",
|
|
219
|
-
reason: `Unknown storage backend type: ${request.backend.type}`
|
|
220
|
-
}));
|
|
221
|
-
}
|
|
222
|
-
throw new AlienError(ResponseDecodingFailedError.create({
|
|
223
|
-
commandId,
|
|
224
|
-
command,
|
|
225
|
-
reason: `Unknown body mode: ${body.mode}`
|
|
226
|
-
}));
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Check if state is terminal
|
|
230
|
-
*/
|
|
231
|
-
function isTerminalState(state) {
|
|
232
|
-
return state === "SUCCEEDED" || state === "FAILED" || state === "EXPIRED";
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Commands client for invoking deployment commands
|
|
236
|
-
*/
|
|
237
|
-
var CommandsClient = class {
|
|
238
|
-
managerUrl;
|
|
239
|
-
deploymentId;
|
|
240
|
-
token;
|
|
241
|
-
defaultTimeout;
|
|
242
|
-
allowLocalStorage;
|
|
243
|
-
constructor(config) {
|
|
244
|
-
this.managerUrl = config.managerUrl.replace(/\/+$/, "");
|
|
245
|
-
this.deploymentId = config.deploymentId;
|
|
246
|
-
this.token = config.token;
|
|
247
|
-
this.defaultTimeout = config.timeout ?? 6e4;
|
|
248
|
-
this.allowLocalStorage = config.allowLocalStorage ?? false;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Invoke a command on the deployment and wait for response
|
|
252
|
-
*
|
|
253
|
-
* @param command - Command name (e.g., "generate-report")
|
|
254
|
-
* @param params - Command parameters (JSON-serializable)
|
|
255
|
-
* @param options - Invocation options
|
|
256
|
-
* @returns Decoded response data
|
|
257
|
-
*/
|
|
258
|
-
async invoke(command, params, options) {
|
|
259
|
-
const timeout = options?.timeout ?? this.defaultTimeout;
|
|
260
|
-
const startTime = Date.now();
|
|
261
|
-
const createResponse = await this.createCommand(command, params, options);
|
|
262
|
-
const pollInterval = options?.pollInterval ?? 500;
|
|
263
|
-
const maxPollInterval = options?.maxPollInterval ?? 5e3;
|
|
264
|
-
const pollBackoff = options?.pollBackoff ?? 1.5;
|
|
265
|
-
let currentInterval = pollInterval;
|
|
266
|
-
while (Date.now() - startTime < timeout) {
|
|
267
|
-
await this.sleep(currentInterval);
|
|
268
|
-
const status = await this.getCommandStatus(createResponse.commandId);
|
|
269
|
-
if (isTerminalState(status.state)) return await this.handleTerminalState(command, status);
|
|
270
|
-
currentInterval = Math.min(currentInterval * pollBackoff, maxPollInterval);
|
|
271
|
-
}
|
|
272
|
-
const finalStatus = await this.getCommandStatus(createResponse.commandId);
|
|
273
|
-
throw new AlienError(CommandTimeoutError.create({
|
|
274
|
-
commandId: createResponse.commandId,
|
|
275
|
-
command,
|
|
276
|
-
timeoutMs: timeout,
|
|
277
|
-
lastState: finalStatus.state
|
|
278
|
-
}));
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Create a command
|
|
282
|
-
*/
|
|
283
|
-
async createCommand(command, params, options) {
|
|
284
|
-
const url = `${this.managerUrl}/v1/commands`;
|
|
285
|
-
const body = {
|
|
286
|
-
deploymentId: this.deploymentId,
|
|
287
|
-
command,
|
|
288
|
-
params: createBodySpec(params),
|
|
289
|
-
deadline: options?.deadline?.toISOString(),
|
|
290
|
-
idempotencyKey: options?.idempotencyKey
|
|
291
|
-
};
|
|
292
|
-
try {
|
|
293
|
-
const response = await fetch(url, {
|
|
294
|
-
method: "POST",
|
|
295
|
-
headers: {
|
|
296
|
-
"Content-Type": "application/json",
|
|
297
|
-
Authorization: `Bearer ${this.token}`
|
|
298
|
-
},
|
|
299
|
-
body: JSON.stringify(body)
|
|
300
|
-
});
|
|
301
|
-
if (!response.ok) {
|
|
302
|
-
const errorBody = await response.text().catch(() => "");
|
|
303
|
-
throw new AlienError(ManagerHttpError.create({
|
|
304
|
-
method: "POST",
|
|
305
|
-
url,
|
|
306
|
-
status: response.status,
|
|
307
|
-
statusText: response.statusText,
|
|
308
|
-
body: errorBody
|
|
309
|
-
}));
|
|
310
|
-
}
|
|
311
|
-
return await response.json();
|
|
312
|
-
} catch (error) {
|
|
313
|
-
if (error instanceof AlienError) throw error;
|
|
314
|
-
throw (await AlienError.from(error)).withContext(CommandCreationFailedError.create({
|
|
315
|
-
deploymentId: this.deploymentId,
|
|
316
|
-
command,
|
|
317
|
-
reason: error instanceof Error ? error.message : String(error)
|
|
318
|
-
}));
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Get command status
|
|
323
|
-
*/
|
|
324
|
-
async getCommandStatus(commandId) {
|
|
325
|
-
const url = `${this.managerUrl}/v1/commands/${commandId}`;
|
|
326
|
-
try {
|
|
327
|
-
const response = await fetch(url, {
|
|
328
|
-
method: "GET",
|
|
329
|
-
headers: { Authorization: `Bearer ${this.token}` }
|
|
330
|
-
});
|
|
331
|
-
if (!response.ok) {
|
|
332
|
-
const errorBody = await response.text().catch(() => "");
|
|
333
|
-
throw new AlienError(ManagerHttpError.create({
|
|
334
|
-
method: "GET",
|
|
335
|
-
url,
|
|
336
|
-
status: response.status,
|
|
337
|
-
statusText: response.statusText,
|
|
338
|
-
body: errorBody
|
|
339
|
-
}));
|
|
340
|
-
}
|
|
341
|
-
return await response.json();
|
|
342
|
-
} catch (error) {
|
|
343
|
-
if (error instanceof AlienError) throw error;
|
|
344
|
-
throw await AlienError.from(error);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Handle terminal state and return response
|
|
349
|
-
*/
|
|
350
|
-
async handleTerminalState(command, status) {
|
|
351
|
-
if (status.state === "EXPIRED") throw new AlienError(CommandExpiredError.create({
|
|
352
|
-
commandId: status.commandId,
|
|
353
|
-
command
|
|
354
|
-
}));
|
|
355
|
-
if (!status.response) throw new AlienError(ResponseDecodingFailedError.create({
|
|
356
|
-
commandId: status.commandId,
|
|
357
|
-
command,
|
|
358
|
-
reason: "Terminal state but no response present"
|
|
359
|
-
}));
|
|
360
|
-
const response = status.response;
|
|
361
|
-
if (response.status === "error") throw new AlienError(DeploymentCommandError.create({
|
|
362
|
-
commandId: status.commandId,
|
|
363
|
-
command,
|
|
364
|
-
errorCode: response.code,
|
|
365
|
-
errorMessage: response.message,
|
|
366
|
-
errorDetails: response.details ?? void 0
|
|
367
|
-
}));
|
|
368
|
-
try {
|
|
369
|
-
return await decodeBodySpec(response.response, status.commandId, command, this.allowLocalStorage);
|
|
370
|
-
} catch (error) {
|
|
371
|
-
if (error instanceof AlienError) throw error;
|
|
372
|
-
throw new AlienError(ResponseDecodingFailedError.create({
|
|
373
|
-
commandId: status.commandId,
|
|
374
|
-
command,
|
|
375
|
-
reason: error instanceof Error ? error.message : String(error)
|
|
376
|
-
}));
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Sleep helper
|
|
381
|
-
*/
|
|
382
|
-
sleep(ms) {
|
|
383
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
//#endregion
|
|
387
|
-
export { CommandCreationFailedError, CommandExpiredError, CommandTimeoutError, CommandsClient, DeploymentCommandError, ManagerHttpError, ResponseDecodingFailedError, StorageOperationFailedError };
|