@alienplatform/bindings 1.0.0 → 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/LICENSE.md +105 -0
- package/README.md +59 -0
- package/dist/errors.d.ts +56 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/factories.d.ts +26 -0
- package/dist/factories.d.ts.map +1 -0
- package/dist/index.d.ts +19 -1768
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -44772
- package/dist/loader.d.ts +171 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +3712 -0
- package/dist/native.d.ts +41 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +46 -0
- package/dist/types.d.ts +150 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +39 -21
- package/AGENTS.md +0 -70
- package/dist/index.js.map +0 -1
- package/scripts/generate-proto.sh +0 -46
- package/src/bindings/AGENTS.md +0 -105
- package/src/bindings/artifact-registry.ts +0 -314
- package/src/bindings/build.ts +0 -195
- package/src/bindings/function.ts +0 -164
- package/src/bindings/index.ts +0 -12
- package/src/bindings/kv.ts +0 -240
- package/src/bindings/queue.ts +0 -191
- package/src/bindings/service-account.ts +0 -113
- package/src/bindings/storage.ts +0 -535
- package/src/bindings/vault.ts +0 -133
- package/src/channel.ts +0 -94
- package/src/commands.ts +0 -76
- package/src/context.ts +0 -368
- package/src/errors.ts +0 -259
- package/src/events.ts +0 -463
- package/src/generated/artifact_registry.ts +0 -1934
- package/src/generated/build.ts +0 -1263
- package/src/generated/container.ts +0 -485
- package/src/generated/control.ts +0 -1574
- package/src/generated/function.ts +0 -741
- package/src/generated/google/protobuf/duration.ts +0 -196
- package/src/generated/google/protobuf/timestamp.ts +0 -225
- package/src/generated/kv.ts +0 -1137
- package/src/generated/queue.ts +0 -729
- package/src/generated/service_account.ts +0 -766
- package/src/generated/storage.ts +0 -3653
- package/src/generated/vault.ts +0 -519
- package/src/generated/wait_until.ts +0 -781
- package/src/global.ts +0 -316
- package/src/grpc-utils.ts +0 -159
- package/src/index.ts +0 -156
- package/src/types.ts +0 -384
- package/src/wait-until.ts +0 -257
- package/tsconfig.json +0 -8
- package/tsdown.config.ts +0 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,1770 +1,21 @@
|
|
|
1
|
-
import * as _alienplatform_core0 from "@alienplatform/core";
|
|
2
|
-
import { QueueMessage, ScheduledEvent, StorageEvent, StorageEvent as StorageEvent$1, StorageEventType } from "@alienplatform/core";
|
|
3
|
-
import { Channel } from "nice-grpc";
|
|
4
|
-
import * as z from "zod/v4";
|
|
5
|
-
|
|
6
|
-
//#region src/bindings/storage.d.ts
|
|
7
|
-
|
|
8
1
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
* // Generate a signed URL
|
|
30
|
-
* const { url } = await bucket.signedUrl("images/photo.jpg", { operation: "get" })
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
declare class Storage {
|
|
34
|
-
private readonly client;
|
|
35
|
-
private readonly bindingName;
|
|
36
|
-
constructor(channel: Channel, bindingName: string);
|
|
37
|
-
/**
|
|
38
|
-
* Get an object from storage.
|
|
39
|
-
*
|
|
40
|
-
* @param path - Path to the object
|
|
41
|
-
* @param options - Get options (range, conditionals)
|
|
42
|
-
* @returns Object data and metadata
|
|
43
|
-
*/
|
|
44
|
-
get(path: string, options?: StorageGetOptions): Promise<StorageGetResult>;
|
|
45
|
-
/**
|
|
46
|
-
* Get an object as a UTF-8 string.
|
|
47
|
-
*
|
|
48
|
-
* @param path - Path to the object
|
|
49
|
-
* @param options - Get options
|
|
50
|
-
* @returns Object content as string
|
|
51
|
-
*/
|
|
52
|
-
getText(path: string, options?: StorageGetOptions): Promise<string>;
|
|
53
|
-
/**
|
|
54
|
-
* Get an object and parse as JSON.
|
|
55
|
-
*
|
|
56
|
-
* @param path - Path to the object
|
|
57
|
-
* @param options - Get options
|
|
58
|
-
* @returns Parsed JSON content
|
|
59
|
-
*/
|
|
60
|
-
getJson<T = unknown>(path: string, options?: StorageGetOptions): Promise<T>;
|
|
61
|
-
/**
|
|
62
|
-
* Put an object to storage.
|
|
63
|
-
*
|
|
64
|
-
* @param path - Path to store the object
|
|
65
|
-
* @param data - Object data
|
|
66
|
-
* @param options - Put options (content type, metadata)
|
|
67
|
-
*/
|
|
68
|
-
put(path: string, data: Uint8Array | string | object, options?: StoragePutOptions): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Put an object using streaming (for large files).
|
|
71
|
-
*
|
|
72
|
-
* @param path - Path to store the object
|
|
73
|
-
* @param chunks - Async iterable of data chunks
|
|
74
|
-
* @param options - Put options
|
|
75
|
-
*/
|
|
76
|
-
putMultipart(path: string, chunks: AsyncIterable<Uint8Array>, options?: StoragePutOptions): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Delete an object from storage.
|
|
79
|
-
*
|
|
80
|
-
* @param path - Path to the object
|
|
81
|
-
*/
|
|
82
|
-
delete(path: string): Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* List objects in storage.
|
|
85
|
-
*
|
|
86
|
-
* @param prefix - Optional prefix filter
|
|
87
|
-
* @param options - List options
|
|
88
|
-
* @returns Async iterable of object metadata
|
|
89
|
-
*/
|
|
90
|
-
list(prefix?: string, options?: {
|
|
91
|
-
offset?: string;
|
|
92
|
-
}): AsyncIterable<StorageObjectMeta>;
|
|
93
|
-
/**
|
|
94
|
-
* List objects with delimiter (for directory-like listing).
|
|
95
|
-
*
|
|
96
|
-
* @param prefix - Optional prefix filter
|
|
97
|
-
* @returns List result with objects and common prefixes
|
|
98
|
-
*/
|
|
99
|
-
listWithDelimiter(prefix?: string): Promise<StorageListResult>;
|
|
100
|
-
/**
|
|
101
|
-
* Get object metadata without downloading content.
|
|
102
|
-
*
|
|
103
|
-
* @param path - Path to the object
|
|
104
|
-
* @returns Object metadata
|
|
105
|
-
*/
|
|
106
|
-
head(path: string): Promise<StorageObjectMeta>;
|
|
107
|
-
/**
|
|
108
|
-
* Check if an object exists.
|
|
109
|
-
*
|
|
110
|
-
* @param path - Path to the object
|
|
111
|
-
* @returns True if the object exists
|
|
112
|
-
*/
|
|
113
|
-
exists(path: string): Promise<boolean>;
|
|
114
|
-
/**
|
|
115
|
-
* Get the base directory path for this storage binding.
|
|
116
|
-
*
|
|
117
|
-
* @returns Base directory path
|
|
118
|
-
*/
|
|
119
|
-
getBaseDir(): Promise<string>;
|
|
120
|
-
/**
|
|
121
|
-
* Get the underlying URL for this storage binding.
|
|
122
|
-
*
|
|
123
|
-
* @returns Storage URL
|
|
124
|
-
*/
|
|
125
|
-
getUrl(): Promise<string>;
|
|
126
|
-
/**
|
|
127
|
-
* Copy an object within the same storage binding.
|
|
128
|
-
*
|
|
129
|
-
* @param from - Source path
|
|
130
|
-
* @param to - Destination path
|
|
131
|
-
*/
|
|
132
|
-
copy(from: string, to: string): Promise<void>;
|
|
133
|
-
/**
|
|
134
|
-
* Rename (move) an object within the same storage binding.
|
|
135
|
-
*
|
|
136
|
-
* @param from - Source path
|
|
137
|
-
* @param to - Destination path
|
|
138
|
-
*/
|
|
139
|
-
rename(from: string, to: string): Promise<void>;
|
|
140
|
-
/**
|
|
141
|
-
* Copy an object only if the destination doesn't exist.
|
|
142
|
-
*
|
|
143
|
-
* @param from - Source path
|
|
144
|
-
* @param to - Destination path
|
|
145
|
-
*/
|
|
146
|
-
copyIfNotExists(from: string, to: string): Promise<void>;
|
|
147
|
-
/**
|
|
148
|
-
* Rename (move) an object only if the destination doesn't exist.
|
|
149
|
-
*
|
|
150
|
-
* @param from - Source path
|
|
151
|
-
* @param to - Destination path
|
|
152
|
-
*/
|
|
153
|
-
renameIfNotExists(from: string, to: string): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* Generate a signed URL for an object.
|
|
156
|
-
*
|
|
157
|
-
* @param path - Path to the object
|
|
158
|
-
* @param options - Signed URL options
|
|
159
|
-
* @returns Signed URL result
|
|
160
|
-
*/
|
|
161
|
-
signedUrl(path: string, options: SignedUrlOptions): Promise<SignedUrlResult>;
|
|
162
|
-
private fromProtoMeta;
|
|
163
|
-
}
|
|
164
|
-
//#endregion
|
|
165
|
-
//#region src/bindings/kv.d.ts
|
|
166
|
-
/**
|
|
167
|
-
* KV binding for key-value storage operations.
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* ```typescript
|
|
171
|
-
* import { kv } from "@alienplatform/bindings"
|
|
172
|
-
*
|
|
173
|
-
* const cache = kv("my-cache")
|
|
174
|
-
*
|
|
175
|
-
* // Set a value
|
|
176
|
-
* await cache.set("user:123", { name: "John", email: "john@example.com" })
|
|
177
|
-
*
|
|
178
|
-
* // Get a value
|
|
179
|
-
* const user = await cache.getJson<User>("user:123")
|
|
180
|
-
*
|
|
181
|
-
* // Set with TTL (expires in 1 hour)
|
|
182
|
-
* await cache.set("session:abc", sessionData, { ttlMs: 60 * 60 * 1000 })
|
|
183
|
-
*
|
|
184
|
-
* // Delete
|
|
185
|
-
* await cache.delete("user:123")
|
|
186
|
-
*
|
|
187
|
-
* // Scan by prefix
|
|
188
|
-
* for await (const { key, value } of cache.scan("user:")) {
|
|
189
|
-
* console.log(key, value)
|
|
190
|
-
* }
|
|
191
|
-
* ```
|
|
192
|
-
*/
|
|
193
|
-
declare class Kv {
|
|
194
|
-
private readonly client;
|
|
195
|
-
private readonly bindingName;
|
|
196
|
-
constructor(channel: Channel, bindingName: string);
|
|
197
|
-
/**
|
|
198
|
-
* Get a value by key.
|
|
199
|
-
*
|
|
200
|
-
* @param key - Key to retrieve
|
|
201
|
-
* @returns Value as Uint8Array, or undefined if not found
|
|
202
|
-
*/
|
|
203
|
-
get(key: string): Promise<Uint8Array | undefined>;
|
|
204
|
-
/**
|
|
205
|
-
* Get a value as a UTF-8 string.
|
|
206
|
-
*
|
|
207
|
-
* @param key - Key to retrieve
|
|
208
|
-
* @returns Value as string, or undefined if not found
|
|
209
|
-
*/
|
|
210
|
-
getText(key: string): Promise<string | undefined>;
|
|
211
|
-
/**
|
|
212
|
-
* Get a value and parse as JSON.
|
|
213
|
-
*
|
|
214
|
-
* @param key - Key to retrieve
|
|
215
|
-
* @returns Parsed JSON value, or undefined if not found
|
|
216
|
-
*/
|
|
217
|
-
getJson<T = unknown>(key: string): Promise<T | undefined>;
|
|
218
|
-
/**
|
|
219
|
-
* Set a value.
|
|
220
|
-
*
|
|
221
|
-
* @param key - Key to store
|
|
222
|
-
* @param value - Value to store (string, Uint8Array, or object for JSON)
|
|
223
|
-
* @param options - Optional put options (TTL, ifNotExists)
|
|
224
|
-
* @returns True if stored, false if ifNotExists was true and key already exists
|
|
225
|
-
*/
|
|
226
|
-
set(key: string, value: string | Uint8Array | object, options?: KvPutOptions): Promise<boolean>;
|
|
227
|
-
/**
|
|
228
|
-
* Delete a key.
|
|
229
|
-
*
|
|
230
|
-
* @param key - Key to delete
|
|
231
|
-
*/
|
|
232
|
-
delete(key: string): Promise<void>;
|
|
233
|
-
/**
|
|
234
|
-
* Check if a key exists.
|
|
235
|
-
*
|
|
236
|
-
* @param key - Key to check
|
|
237
|
-
* @returns True if the key exists
|
|
238
|
-
*/
|
|
239
|
-
exists(key: string): Promise<boolean>;
|
|
240
|
-
/**
|
|
241
|
-
* Scan keys with a prefix.
|
|
242
|
-
*
|
|
243
|
-
* @param prefix - Prefix to scan for
|
|
244
|
-
* @param options - Optional scan options (limit)
|
|
245
|
-
* @returns Async iterable of key-value pairs
|
|
246
|
-
*
|
|
247
|
-
* @example
|
|
248
|
-
* ```typescript
|
|
249
|
-
* // Scan all users
|
|
250
|
-
* for await (const { key, value } of cache.scan("user:")) {
|
|
251
|
-
* console.log(key, new TextDecoder().decode(value))
|
|
252
|
-
* }
|
|
253
|
-
* ```
|
|
254
|
-
*/
|
|
255
|
-
scan(prefix: string, options?: {
|
|
256
|
-
limit?: number;
|
|
257
|
-
}): AsyncIterable<{
|
|
258
|
-
key: string;
|
|
259
|
-
value: Uint8Array;
|
|
260
|
-
}>;
|
|
261
|
-
/**
|
|
262
|
-
* Scan a single page of results.
|
|
263
|
-
*
|
|
264
|
-
* @param prefix - Prefix to scan for
|
|
265
|
-
* @param limit - Maximum items to return
|
|
266
|
-
* @param cursor - Pagination cursor
|
|
267
|
-
* @returns Scan result with items and next cursor
|
|
268
|
-
*/
|
|
269
|
-
scanPage(prefix: string, limit?: number, cursor?: string): Promise<KvScanResult>;
|
|
270
|
-
}
|
|
271
|
-
//#endregion
|
|
272
|
-
//#region src/bindings/queue.d.ts
|
|
273
|
-
/**
|
|
274
|
-
* Queue binding for message queue operations.
|
|
275
|
-
*
|
|
276
|
-
* @example
|
|
277
|
-
* ```typescript
|
|
278
|
-
* import { queue } from "@alienplatform/bindings"
|
|
279
|
-
*
|
|
280
|
-
* const tasks = queue("task-queue")
|
|
281
|
-
*
|
|
282
|
-
* // Send a message (JSON)
|
|
283
|
-
* await tasks.send("process-image", { imageId: "123", format: "webp" })
|
|
284
|
-
*
|
|
285
|
-
* // Receive messages
|
|
286
|
-
* const messages = await tasks.receive("process-image", 10)
|
|
287
|
-
* for (const msg of messages) {
|
|
288
|
-
* await processImage(msg.payload)
|
|
289
|
-
* await tasks.ack("process-image", msg.receiptHandle)
|
|
290
|
-
* }
|
|
291
|
-
* ```
|
|
292
|
-
*/
|
|
293
|
-
declare class Queue {
|
|
294
|
-
private readonly client;
|
|
295
|
-
private readonly bindingName;
|
|
296
|
-
constructor(channel: Channel, bindingName: string);
|
|
297
|
-
/**
|
|
298
|
-
* Send a message to a queue.
|
|
299
|
-
*
|
|
300
|
-
* @param queueName - Name of the queue
|
|
301
|
-
* @param payload - Message payload (object for JSON, string for text)
|
|
302
|
-
*/
|
|
303
|
-
send(queueName: string, payload: unknown): Promise<void>;
|
|
304
|
-
/**
|
|
305
|
-
* Send a text message to a queue.
|
|
306
|
-
*
|
|
307
|
-
* @param queueName - Name of the queue
|
|
308
|
-
* @param text - Text message
|
|
309
|
-
*/
|
|
310
|
-
sendText(queueName: string, text: string): Promise<void>;
|
|
311
|
-
/**
|
|
312
|
-
* Receive messages from a queue.
|
|
313
|
-
*
|
|
314
|
-
* @param queueName - Name of the queue
|
|
315
|
-
* @param maxMessages - Maximum number of messages to receive (1-10)
|
|
316
|
-
* @returns Array of messages with receipt handles
|
|
317
|
-
*/
|
|
318
|
-
receive<T = unknown>(queueName: string, maxMessages?: number): Promise<ReceivedQueueMessage<T>[]>;
|
|
319
|
-
/**
|
|
320
|
-
* Acknowledge a message (remove it from the queue).
|
|
321
|
-
*
|
|
322
|
-
* @param queueName - Name of the queue
|
|
323
|
-
* @param receiptHandle - Receipt handle from the received message
|
|
324
|
-
*/
|
|
325
|
-
ack(queueName: string, receiptHandle: string): Promise<void>;
|
|
326
|
-
/**
|
|
327
|
-
* Process messages from a queue with automatic acknowledgment.
|
|
328
|
-
*
|
|
329
|
-
* @param queueName - Name of the queue
|
|
330
|
-
* @param handler - Handler function for each message
|
|
331
|
-
* @param options - Processing options
|
|
332
|
-
*
|
|
333
|
-
* @example
|
|
334
|
-
* ```typescript
|
|
335
|
-
* await tasks.process("image-tasks", async (payload) => {
|
|
336
|
-
* await processImage(payload.imageId)
|
|
337
|
-
* })
|
|
338
|
-
* ```
|
|
339
|
-
*/
|
|
340
|
-
process<T = unknown>(queueName: string, handler: (payload: T) => Promise<void>, options?: {
|
|
341
|
-
maxMessages?: number;
|
|
342
|
-
}): Promise<void>;
|
|
343
|
-
private toProtoPayload;
|
|
344
|
-
private fromProtoMessage;
|
|
345
|
-
}
|
|
346
|
-
//#endregion
|
|
347
|
-
//#region src/bindings/vault.d.ts
|
|
348
|
-
/**
|
|
349
|
-
* Vault binding for secret management operations.
|
|
350
|
-
*
|
|
351
|
-
* @example
|
|
352
|
-
* ```typescript
|
|
353
|
-
* import { vault } from "@alienplatform/bindings"
|
|
354
|
-
*
|
|
355
|
-
* const secrets = vault("app-secrets")
|
|
356
|
-
*
|
|
357
|
-
* // Get a secret
|
|
358
|
-
* const apiKey = await secrets.get("API_KEY")
|
|
359
|
-
*
|
|
360
|
-
* // Set a secret
|
|
361
|
-
* await secrets.set("DATABASE_URL", "postgres://...")
|
|
362
|
-
*
|
|
363
|
-
* // Delete a secret
|
|
364
|
-
* await secrets.delete("OLD_KEY")
|
|
365
|
-
* ```
|
|
366
|
-
*/
|
|
367
|
-
declare class Vault {
|
|
368
|
-
private readonly client;
|
|
369
|
-
private readonly bindingName;
|
|
370
|
-
constructor(channel: Channel, bindingName: string);
|
|
371
|
-
/**
|
|
372
|
-
* Get a secret value.
|
|
373
|
-
*
|
|
374
|
-
* @param secretName - Name of the secret
|
|
375
|
-
* @returns Secret value
|
|
376
|
-
*/
|
|
377
|
-
get(secretName: string): Promise<string>;
|
|
378
|
-
/**
|
|
379
|
-
* Get a secret as JSON.
|
|
380
|
-
*
|
|
381
|
-
* @param secretName - Name of the secret
|
|
382
|
-
* @returns Parsed JSON value
|
|
383
|
-
*/
|
|
384
|
-
getJson<T = unknown>(secretName: string): Promise<T>;
|
|
385
|
-
/**
|
|
386
|
-
* Set a secret value.
|
|
387
|
-
*
|
|
388
|
-
* @param secretName - Name of the secret
|
|
389
|
-
* @param value - Secret value (string or object for JSON)
|
|
390
|
-
*/
|
|
391
|
-
set(secretName: string, value: string | object): Promise<void>;
|
|
392
|
-
/**
|
|
393
|
-
* Delete a secret.
|
|
394
|
-
*
|
|
395
|
-
* @param secretName - Name of the secret to delete
|
|
396
|
-
*/
|
|
397
|
-
delete(secretName: string): Promise<void>;
|
|
398
|
-
/**
|
|
399
|
-
* Check if a secret exists.
|
|
400
|
-
*
|
|
401
|
-
* @param secretName - Name of the secret
|
|
402
|
-
* @returns True if the secret exists
|
|
403
|
-
*/
|
|
404
|
-
exists(secretName: string): Promise<boolean>;
|
|
405
|
-
}
|
|
406
|
-
//#endregion
|
|
407
|
-
//#region src/bindings/build.d.ts
|
|
408
|
-
/**
|
|
409
|
-
* Build binding for executing build operations.
|
|
410
|
-
*
|
|
411
|
-
* @example
|
|
412
|
-
* ```typescript
|
|
413
|
-
* import { build } from "@alienplatform/bindings"
|
|
414
|
-
*
|
|
415
|
-
* const builder = build("my-builder")
|
|
416
|
-
*
|
|
417
|
-
* // Start a build
|
|
418
|
-
* const execution = await builder.start({
|
|
419
|
-
* script: "npm run build",
|
|
420
|
-
* computeType: "medium",
|
|
421
|
-
* timeoutSeconds: 600,
|
|
422
|
-
* })
|
|
423
|
-
*
|
|
424
|
-
* // Wait for completion
|
|
425
|
-
* const result = await builder.waitForCompletion(execution.id)
|
|
426
|
-
* console.log("Build status:", result.status)
|
|
427
|
-
* ```
|
|
428
|
-
*/
|
|
429
|
-
declare class Build {
|
|
430
|
-
private readonly client;
|
|
431
|
-
private readonly bindingName;
|
|
432
|
-
constructor(channel: Channel, bindingName: string);
|
|
433
|
-
/**
|
|
434
|
-
* Start a new build.
|
|
435
|
-
*
|
|
436
|
-
* @param config - Build configuration
|
|
437
|
-
* @returns Build execution information
|
|
438
|
-
*/
|
|
439
|
-
start(config: BuildStartConfig): Promise<BuildExecution>;
|
|
440
|
-
/**
|
|
441
|
-
* Get the status of a build.
|
|
442
|
-
*
|
|
443
|
-
* @param buildId - Build execution ID
|
|
444
|
-
* @returns Build execution information
|
|
445
|
-
*/
|
|
446
|
-
getStatus(buildId: string): Promise<BuildExecution>;
|
|
447
|
-
/**
|
|
448
|
-
* Stop a running build.
|
|
449
|
-
*
|
|
450
|
-
* @param buildId - Build execution ID
|
|
451
|
-
*/
|
|
452
|
-
stop(buildId: string): Promise<void>;
|
|
453
|
-
/**
|
|
454
|
-
* Wait for a build to complete.
|
|
455
|
-
*
|
|
456
|
-
* @param buildId - Build execution ID
|
|
457
|
-
* @param options - Polling options
|
|
458
|
-
* @returns Final build execution information
|
|
459
|
-
*/
|
|
460
|
-
waitForCompletion(buildId: string, options?: {
|
|
461
|
-
pollIntervalMs?: number;
|
|
462
|
-
timeoutMs?: number;
|
|
463
|
-
}): Promise<BuildExecution>;
|
|
464
|
-
private toProtoConfig;
|
|
465
|
-
private fromProtoExecution;
|
|
466
|
-
}
|
|
467
|
-
//#endregion
|
|
468
|
-
//#region src/bindings/function.d.ts
|
|
469
|
-
/**
|
|
470
|
-
* Function binding for direct function invocation.
|
|
471
|
-
*
|
|
472
|
-
* @example
|
|
473
|
-
* ```typescript
|
|
474
|
-
* import { func } from "@alienplatform/bindings"
|
|
475
|
-
*
|
|
476
|
-
* const processor = func("image-processor")
|
|
477
|
-
*
|
|
478
|
-
* // Invoke with JSON body
|
|
479
|
-
* const response = await processor.invokeJson("resize-image", {
|
|
480
|
-
* imageUrl: "https://...",
|
|
481
|
-
* width: 800,
|
|
482
|
-
* height: 600,
|
|
483
|
-
* })
|
|
484
|
-
*
|
|
485
|
-
* // Get function URL
|
|
486
|
-
* const url = await processor.getUrl()
|
|
487
|
-
* ```
|
|
488
|
-
*/
|
|
489
|
-
declare class FunctionBinding {
|
|
490
|
-
private readonly client;
|
|
491
|
-
private readonly bindingName;
|
|
492
|
-
constructor(channel: Channel, bindingName: string);
|
|
493
|
-
/**
|
|
494
|
-
* Invoke a function with raw request data.
|
|
495
|
-
*
|
|
496
|
-
* @param request - Invocation request
|
|
497
|
-
* @returns Function response
|
|
498
|
-
*/
|
|
499
|
-
invoke(request: FunctionInvokeRequest): Promise<FunctionInvokeResponse>;
|
|
500
|
-
/**
|
|
501
|
-
* Invoke a function with a JSON body.
|
|
502
|
-
*
|
|
503
|
-
* @param targetFunction - Target function identifier
|
|
504
|
-
* @param body - JSON body
|
|
505
|
-
* @param options - Optional request options
|
|
506
|
-
* @returns Parsed JSON response
|
|
507
|
-
*/
|
|
508
|
-
invokeJson<TRequest, TResponse = unknown>(targetFunction: string, body: TRequest, options?: {
|
|
509
|
-
method?: string;
|
|
510
|
-
path?: string;
|
|
511
|
-
headers?: Record<string, string>;
|
|
512
|
-
timeoutMs?: number;
|
|
513
|
-
}): Promise<TResponse>;
|
|
514
|
-
/**
|
|
515
|
-
* Invoke a function with GET request.
|
|
516
|
-
*
|
|
517
|
-
* @param targetFunction - Target function identifier
|
|
518
|
-
* @param path - Request path
|
|
519
|
-
* @param options - Optional request options
|
|
520
|
-
* @returns Parsed JSON response
|
|
521
|
-
*/
|
|
522
|
-
get<TResponse = unknown>(targetFunction: string, path?: string, options?: {
|
|
523
|
-
headers?: Record<string, string>;
|
|
524
|
-
timeoutMs?: number;
|
|
525
|
-
}): Promise<TResponse>;
|
|
526
|
-
/**
|
|
527
|
-
* Get the public URL of the function.
|
|
528
|
-
*
|
|
529
|
-
* @returns Function URL if available
|
|
530
|
-
*/
|
|
531
|
-
getUrl(): Promise<string | undefined>;
|
|
532
|
-
}
|
|
533
|
-
//#endregion
|
|
534
|
-
//#region src/bindings/service-account.d.ts
|
|
535
|
-
/**
|
|
536
|
-
* ServiceAccount binding for identity and impersonation.
|
|
537
|
-
*
|
|
538
|
-
* @example
|
|
539
|
-
* ```typescript
|
|
540
|
-
* import { serviceAccount } from "@alienplatform/bindings"
|
|
541
|
-
*
|
|
542
|
-
* const sa = serviceAccount("deployment-account")
|
|
543
|
-
*
|
|
544
|
-
* // Get account info
|
|
545
|
-
* const info = await sa.getInfo()
|
|
546
|
-
* if (info.platform === "aws") {
|
|
547
|
-
* console.log("Role ARN:", info.roleArn)
|
|
548
|
-
* }
|
|
549
|
-
*
|
|
550
|
-
* // Impersonate the service account
|
|
551
|
-
* const config = await sa.impersonate({ durationSeconds: 3600 })
|
|
552
|
-
* ```
|
|
553
|
-
*/
|
|
554
|
-
declare class ServiceAccount {
|
|
555
|
-
private readonly client;
|
|
556
|
-
private readonly bindingName;
|
|
557
|
-
constructor(channel: Channel, bindingName: string);
|
|
558
|
-
/**
|
|
559
|
-
* Get information about the service account.
|
|
560
|
-
*
|
|
561
|
-
* @returns Platform-specific service account information
|
|
562
|
-
*/
|
|
563
|
-
getInfo(): Promise<ServiceAccountInfo>;
|
|
564
|
-
/**
|
|
565
|
-
* Impersonate the service account.
|
|
566
|
-
*
|
|
567
|
-
* @param request - Impersonation options
|
|
568
|
-
* @returns Client configuration for the impersonated identity
|
|
569
|
-
*/
|
|
570
|
-
impersonate(request?: ImpersonationRequest): Promise<unknown>;
|
|
571
|
-
private fromProtoInfo;
|
|
572
|
-
}
|
|
573
|
-
//#endregion
|
|
574
|
-
//#region src/types.d.ts
|
|
575
|
-
/**
|
|
576
|
-
* Options for storage get operations.
|
|
577
|
-
*/
|
|
578
|
-
interface StorageGetOptions {
|
|
579
|
-
/** Range start offset in bytes */
|
|
580
|
-
rangeStart?: number;
|
|
581
|
-
/** Range end offset in bytes */
|
|
582
|
-
rangeEnd?: number;
|
|
583
|
-
/** If-Match header value (ETag) */
|
|
584
|
-
ifMatch?: string;
|
|
585
|
-
/** If-None-Match header value (ETag) */
|
|
586
|
-
ifNoneMatch?: string;
|
|
587
|
-
/** If-Modified-Since timestamp */
|
|
588
|
-
ifModifiedSince?: Date;
|
|
589
|
-
/** If-Unmodified-Since timestamp */
|
|
590
|
-
ifUnmodifiedSince?: Date;
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* Options for storage put operations.
|
|
594
|
-
*/
|
|
595
|
-
interface StoragePutOptions {
|
|
596
|
-
/** Content type of the object */
|
|
597
|
-
contentType?: string;
|
|
598
|
-
/** Custom metadata */
|
|
599
|
-
metadata?: Record<string, string>;
|
|
600
|
-
/** Only write if the object doesn't already exist */
|
|
601
|
-
ifNotExists?: boolean;
|
|
602
|
-
}
|
|
603
|
-
/**
|
|
604
|
-
* Object metadata from storage.
|
|
605
|
-
*/
|
|
606
|
-
interface StorageObjectMeta {
|
|
607
|
-
/** Full path of the object */
|
|
608
|
-
location: string;
|
|
609
|
-
/** Last modified timestamp */
|
|
610
|
-
lastModified?: Date;
|
|
611
|
-
/** Object size in bytes */
|
|
612
|
-
size: number;
|
|
613
|
-
/** ETag (entity tag) for the object */
|
|
614
|
-
etag?: string;
|
|
615
|
-
/** Object version */
|
|
616
|
-
version?: string;
|
|
617
|
-
}
|
|
618
|
-
/**
|
|
619
|
-
* Result of a storage get operation.
|
|
620
|
-
*/
|
|
621
|
-
interface StorageGetResult {
|
|
622
|
-
/** Object metadata */
|
|
623
|
-
meta: StorageObjectMeta;
|
|
624
|
-
/** Object data as bytes */
|
|
625
|
-
data: Uint8Array;
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* Result of a storage list operation with delimiter.
|
|
629
|
-
*/
|
|
630
|
-
interface StorageListResult {
|
|
631
|
-
/** Common prefixes (directories) */
|
|
632
|
-
commonPrefixes: string[];
|
|
633
|
-
/** Object metadata entries */
|
|
634
|
-
objects: StorageObjectMeta[];
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* Options for signed URL generation.
|
|
638
|
-
*/
|
|
639
|
-
interface SignedUrlOptions {
|
|
640
|
-
/** Operation type: get (download), put (upload), or delete */
|
|
641
|
-
operation: "get" | "put" | "delete";
|
|
642
|
-
/** URL expiration duration in seconds */
|
|
643
|
-
expiresInSeconds?: number;
|
|
644
|
-
/** Content type for put operations */
|
|
645
|
-
contentType?: string;
|
|
646
|
-
}
|
|
647
|
-
/**
|
|
648
|
-
* Result of signed URL generation.
|
|
649
|
-
*/
|
|
650
|
-
interface SignedUrlResult {
|
|
651
|
-
/** The signed URL */
|
|
652
|
-
url: string;
|
|
653
|
-
/** URL expiration timestamp */
|
|
654
|
-
expiresAt?: Date;
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* Options for KV put operations.
|
|
658
|
-
*/
|
|
659
|
-
interface KvPutOptions {
|
|
660
|
-
/** Time-to-live in milliseconds */
|
|
661
|
-
ttlMs?: number;
|
|
662
|
-
/** Only write if the key doesn't exist */
|
|
663
|
-
ifNotExists?: boolean;
|
|
664
|
-
}
|
|
665
|
-
/**
|
|
666
|
-
* Result of a KV scan operation.
|
|
667
|
-
*/
|
|
668
|
-
interface KvScanResult {
|
|
669
|
-
/** Key-value pairs */
|
|
670
|
-
items: Array<{
|
|
671
|
-
key: string;
|
|
672
|
-
value: Uint8Array;
|
|
673
|
-
}>;
|
|
674
|
-
/** Cursor for next page */
|
|
675
|
-
nextCursor?: string;
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
* A message received from a queue via the Queue binding.
|
|
679
|
-
* (Not to be confused with QueueMessage from @alienplatform/core which is used for event handlers)
|
|
680
|
-
*/
|
|
681
|
-
interface ReceivedQueueMessage<T = unknown> {
|
|
682
|
-
/** Message payload */
|
|
683
|
-
payload: T;
|
|
684
|
-
/** Receipt handle for acknowledgment */
|
|
685
|
-
receiptHandle: string;
|
|
686
|
-
}
|
|
687
|
-
/**
|
|
688
|
-
* Configuration for starting a build via the Build binding.
|
|
689
|
-
* (SDK-specific - different from BuildConfig in core which is for resource definition)
|
|
690
|
-
*/
|
|
691
|
-
interface BuildStartConfig {
|
|
692
|
-
/** Build script to execute */
|
|
693
|
-
script: string;
|
|
694
|
-
/** Environment variables */
|
|
695
|
-
environment?: Record<string, string>;
|
|
696
|
-
/** Compute type */
|
|
697
|
-
computeType?: _alienplatform_core0.ComputeType;
|
|
698
|
-
/** Timeout in seconds */
|
|
699
|
-
timeoutSeconds?: number;
|
|
700
|
-
/** Monitoring configuration */
|
|
701
|
-
monitoring?: {
|
|
702
|
-
endpoint: string;
|
|
703
|
-
headers?: Record<string, string>;
|
|
704
|
-
logsUri?: string;
|
|
705
|
-
tlsEnabled?: boolean;
|
|
706
|
-
tlsVerify?: boolean;
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
/**
|
|
710
|
-
* Information about a build execution.
|
|
711
|
-
*/
|
|
712
|
-
interface BuildExecution {
|
|
713
|
-
/** Build execution ID */
|
|
714
|
-
id: string;
|
|
715
|
-
/** Current status */
|
|
716
|
-
status: _alienplatform_core0.BuildStatus;
|
|
717
|
-
/** Start timestamp */
|
|
718
|
-
startTime?: Date;
|
|
719
|
-
/** End timestamp */
|
|
720
|
-
endTime?: Date;
|
|
721
|
-
}
|
|
722
|
-
/**
|
|
723
|
-
* Permission levels for artifact registry access.
|
|
724
|
-
*/
|
|
725
|
-
type ArtifactRegistryPermissions = "pull" | "push-pull";
|
|
726
|
-
/**
|
|
727
|
-
* Information about a repository.
|
|
728
|
-
*/
|
|
729
|
-
interface RepositoryInfo {
|
|
730
|
-
/** Repository name */
|
|
731
|
-
name: string;
|
|
732
|
-
/** Repository URI */
|
|
733
|
-
uri: string;
|
|
734
|
-
/** Creation timestamp */
|
|
735
|
-
createdAt?: Date;
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Credentials for repository access.
|
|
739
|
-
*/
|
|
740
|
-
interface ArtifactRegistryCredentials {
|
|
741
|
-
/** Username for authentication */
|
|
742
|
-
username: string;
|
|
743
|
-
/** Password/token for authentication */
|
|
744
|
-
password: string;
|
|
745
|
-
/** Credential expiration timestamp */
|
|
746
|
-
expiresAt?: Date;
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
* Types of compute services that can have cross-account access.
|
|
750
|
-
*/
|
|
751
|
-
type ComputeServiceType = "function";
|
|
752
|
-
/**
|
|
753
|
-
* AWS-specific cross-account access configuration.
|
|
754
|
-
*/
|
|
755
|
-
interface AwsCrossAccountAccess {
|
|
756
|
-
/** AWS account IDs that should have access */
|
|
757
|
-
accountIds: string[];
|
|
758
|
-
/** Types of compute services that should have access */
|
|
759
|
-
allowedServiceTypes: ComputeServiceType[];
|
|
760
|
-
/** Specific IAM role ARNs to grant access to */
|
|
761
|
-
roleArns: string[];
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* GCP-specific cross-account access configuration.
|
|
765
|
-
*/
|
|
766
|
-
interface GcpCrossAccountAccess {
|
|
767
|
-
/** GCP project numbers that should have access */
|
|
768
|
-
projectNumbers: string[];
|
|
769
|
-
/** Types of compute services that should have access */
|
|
770
|
-
allowedServiceTypes: ComputeServiceType[];
|
|
771
|
-
/** Additional service account emails to grant access to */
|
|
772
|
-
serviceAccountEmails: string[];
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
* Cross-account access configuration (discriminated union).
|
|
776
|
-
*/
|
|
777
|
-
type CrossAccountAccess = {
|
|
778
|
-
type: "aws";
|
|
779
|
-
aws: AwsCrossAccountAccess;
|
|
780
|
-
} | {
|
|
781
|
-
type: "gcp";
|
|
782
|
-
gcp: GcpCrossAccountAccess;
|
|
783
|
-
};
|
|
784
|
-
/**
|
|
785
|
-
* Current cross-account access permissions.
|
|
786
|
-
*/
|
|
787
|
-
interface CrossAccountPermissions {
|
|
788
|
-
/** Platform-specific access configuration */
|
|
789
|
-
access: CrossAccountAccess;
|
|
790
|
-
/** Timestamp when permissions were last updated (ISO8601 format) */
|
|
791
|
-
lastUpdated?: string;
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* Request for function invocation.
|
|
795
|
-
*/
|
|
796
|
-
interface FunctionInvokeRequest {
|
|
797
|
-
/** Target function identifier */
|
|
798
|
-
targetFunction: string;
|
|
799
|
-
/** HTTP method */
|
|
800
|
-
method: string;
|
|
801
|
-
/** Request path */
|
|
802
|
-
path: string;
|
|
803
|
-
/** Request headers */
|
|
804
|
-
headers?: Record<string, string>;
|
|
805
|
-
/** Request body */
|
|
806
|
-
body?: Uint8Array;
|
|
807
|
-
/** Timeout in milliseconds */
|
|
808
|
-
timeoutMs?: number;
|
|
809
|
-
}
|
|
810
|
-
/**
|
|
811
|
-
* Response from function invocation.
|
|
812
|
-
*/
|
|
813
|
-
interface FunctionInvokeResponse {
|
|
814
|
-
/** HTTP status code */
|
|
815
|
-
status: number;
|
|
816
|
-
/** Response headers */
|
|
817
|
-
headers: Record<string, string>;
|
|
818
|
-
/** Response body */
|
|
819
|
-
body: Uint8Array;
|
|
820
|
-
}
|
|
821
|
-
/**
|
|
822
|
-
* AWS service account information.
|
|
823
|
-
*/
|
|
824
|
-
interface AwsServiceAccountInfo {
|
|
825
|
-
platform: "aws";
|
|
826
|
-
roleName: string;
|
|
827
|
-
roleArn: string;
|
|
828
|
-
}
|
|
829
|
-
/**
|
|
830
|
-
* GCP service account information.
|
|
831
|
-
*/
|
|
832
|
-
interface GcpServiceAccountInfo {
|
|
833
|
-
platform: "gcp";
|
|
834
|
-
email: string;
|
|
835
|
-
uniqueId: string;
|
|
836
|
-
}
|
|
837
|
-
/**
|
|
838
|
-
* Azure service account information.
|
|
839
|
-
*/
|
|
840
|
-
interface AzureServiceAccountInfo {
|
|
841
|
-
platform: "azure";
|
|
842
|
-
clientId: string;
|
|
843
|
-
resourceId: string;
|
|
844
|
-
principalId: string;
|
|
845
|
-
}
|
|
846
|
-
/**
|
|
847
|
-
* Platform-specific service account information.
|
|
848
|
-
*/
|
|
849
|
-
type ServiceAccountInfo = AwsServiceAccountInfo | GcpServiceAccountInfo | AzureServiceAccountInfo;
|
|
850
|
-
/**
|
|
851
|
-
* Request for service account impersonation.
|
|
852
|
-
*/
|
|
853
|
-
interface ImpersonationRequest {
|
|
854
|
-
/** Session name for AWS */
|
|
855
|
-
sessionName?: string;
|
|
856
|
-
/** Duration in seconds */
|
|
857
|
-
durationSeconds?: number;
|
|
858
|
-
/** OAuth scopes for GCP */
|
|
859
|
-
scopes?: string[];
|
|
860
|
-
}
|
|
861
|
-
/**
|
|
862
|
-
* Configuration for connecting to the Alien bindings server.
|
|
863
|
-
*/
|
|
864
|
-
interface AlienBindingsConfig {
|
|
865
|
-
/** gRPC server address */
|
|
866
|
-
grpcAddress?: string;
|
|
867
|
-
}
|
|
868
|
-
/**
|
|
869
|
-
* Interface for the bindings provider.
|
|
870
|
-
*/
|
|
871
|
-
interface AlienBindingsProvider {
|
|
872
|
-
/** Get a storage binding */
|
|
873
|
-
storage(name: string): Storage;
|
|
874
|
-
/** Get a KV binding */
|
|
875
|
-
kv(name: string): Kv;
|
|
876
|
-
/** Get a queue binding */
|
|
877
|
-
queue(name: string): Queue;
|
|
878
|
-
/** Get a vault binding */
|
|
879
|
-
vault(name: string): Vault;
|
|
880
|
-
/** Get a build binding */
|
|
881
|
-
build(name: string): Build;
|
|
882
|
-
/** Get an artifact registry binding */
|
|
883
|
-
artifactRegistry(name: string): ArtifactRegistry;
|
|
884
|
-
/** Get a function binding */
|
|
885
|
-
func(name: string): FunctionBinding;
|
|
886
|
-
/** Get a service account binding */
|
|
887
|
-
serviceAccount(name: string): ServiceAccount;
|
|
888
|
-
}
|
|
889
|
-
//#endregion
|
|
890
|
-
//#region src/bindings/artifact-registry.d.ts
|
|
891
|
-
/**
|
|
892
|
-
* ArtifactRegistry binding for container repository management.
|
|
893
|
-
*
|
|
894
|
-
* @example
|
|
895
|
-
* ```typescript
|
|
896
|
-
* import { artifactRegistry } from "@alienplatform/bindings"
|
|
897
|
-
*
|
|
898
|
-
* const registry = artifactRegistry("my-registry")
|
|
899
|
-
*
|
|
900
|
-
* // Create a repository
|
|
901
|
-
* const repo = await registry.createRepository("my-app")
|
|
902
|
-
* console.log("Repository URI:", repo.uri)
|
|
903
|
-
*
|
|
904
|
-
* // Generate push credentials
|
|
905
|
-
* const creds = await registry.generateCredentials("my-app", "push-pull")
|
|
906
|
-
* console.log("Username:", creds.username)
|
|
907
|
-
* ```
|
|
908
|
-
*/
|
|
909
|
-
declare class ArtifactRegistry {
|
|
910
|
-
private readonly client;
|
|
911
|
-
private readonly bindingName;
|
|
912
|
-
constructor(channel: Channel, bindingName: string);
|
|
913
|
-
/**
|
|
914
|
-
* Create a repository.
|
|
915
|
-
*
|
|
916
|
-
* @param repoName - Name of the repository
|
|
917
|
-
* @returns Repository information
|
|
918
|
-
*/
|
|
919
|
-
createRepository(repoName: string): Promise<RepositoryInfo>;
|
|
920
|
-
/**
|
|
921
|
-
* Get repository details.
|
|
922
|
-
*
|
|
923
|
-
* @param repoId - Repository ID
|
|
924
|
-
* @returns Repository information
|
|
925
|
-
*/
|
|
926
|
-
getRepository(repoId: string): Promise<RepositoryInfo>;
|
|
927
|
-
/**
|
|
928
|
-
* Add cross-account access to a repository.
|
|
929
|
-
*
|
|
930
|
-
* @param repoId - Repository ID
|
|
931
|
-
* @param access - Cross-account access configuration
|
|
932
|
-
*/
|
|
933
|
-
addCrossAccountAccess(repoId: string, access: CrossAccountAccess): Promise<void>;
|
|
934
|
-
/**
|
|
935
|
-
* Remove cross-account access from a repository.
|
|
936
|
-
*
|
|
937
|
-
* @param repoId - Repository ID
|
|
938
|
-
* @param access - Cross-account access configuration to remove
|
|
939
|
-
*/
|
|
940
|
-
removeCrossAccountAccess(repoId: string, access: CrossAccountAccess): Promise<void>;
|
|
941
|
-
/**
|
|
942
|
-
* Get current cross-account access permissions for a repository.
|
|
943
|
-
*
|
|
944
|
-
* @param repoId - Repository ID
|
|
945
|
-
* @returns Current cross-account permissions
|
|
946
|
-
*/
|
|
947
|
-
getCrossAccountAccess(repoId: string): Promise<CrossAccountPermissions>;
|
|
948
|
-
/**
|
|
949
|
-
* Generate credentials for repository access.
|
|
950
|
-
*
|
|
951
|
-
* @param repoId - Repository ID
|
|
952
|
-
* @param permissions - Permission level (pull or push-pull)
|
|
953
|
-
* @param ttlSeconds - Optional TTL in seconds
|
|
954
|
-
* @returns Repository credentials
|
|
955
|
-
*/
|
|
956
|
-
generateCredentials(repoId: string, permissions: ArtifactRegistryPermissions, ttlSeconds?: number): Promise<ArtifactRegistryCredentials>;
|
|
957
|
-
/**
|
|
958
|
-
* Delete a repository.
|
|
959
|
-
*
|
|
960
|
-
* @param repoId - Repository ID
|
|
961
|
-
*/
|
|
962
|
-
deleteRepository(repoId: string): Promise<void>;
|
|
963
|
-
private fromProtoResult;
|
|
964
|
-
private fromProtoCredentials;
|
|
965
|
-
private toProtoCrossAccountAccess;
|
|
966
|
-
private fromProtoCrossAccountAccess;
|
|
967
|
-
private fromProtoCrossAccountPermissions;
|
|
968
|
-
private computeServiceTypeToProto;
|
|
969
|
-
private protoToComputeServiceType;
|
|
970
|
-
}
|
|
971
|
-
//#endregion
|
|
972
|
-
//#region src/events.d.ts
|
|
973
|
-
/**
|
|
974
|
-
* Cron/scheduled event with schedule info.
|
|
975
|
-
* Extends ScheduledEvent with the schedule name.
|
|
976
|
-
*/
|
|
977
|
-
interface CronEvent extends ScheduledEvent {
|
|
978
|
-
/** Schedule name */
|
|
979
|
-
scheduleName: string;
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* Queue message event with queue context.
|
|
983
|
-
*/
|
|
984
|
-
interface QueueMessageEvent<T = unknown> {
|
|
985
|
-
/** Message ID */
|
|
986
|
-
id: string;
|
|
987
|
-
/** Source queue name */
|
|
988
|
-
source: string;
|
|
989
|
-
/** Receipt handle for acknowledgment */
|
|
990
|
-
receiptHandle: string;
|
|
991
|
-
/** Message payload */
|
|
992
|
-
payload: T;
|
|
993
|
-
/** Delivery attempt count */
|
|
994
|
-
attemptCount: number;
|
|
995
|
-
/** Message timestamp */
|
|
996
|
-
timestamp: Date;
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
* Event handler registration.
|
|
1000
|
-
*/
|
|
1001
|
-
|
|
1002
|
-
//#endregion
|
|
1003
|
-
//#region src/context.d.ts
|
|
1004
|
-
/**
|
|
1005
|
-
* AlienContext provides the main entry point for accessing Alien bindings
|
|
1006
|
-
* and control plane functionality.
|
|
1007
|
-
*
|
|
1008
|
-
* @example
|
|
1009
|
-
* ```typescript
|
|
1010
|
-
* import { AlienContext } from "@alienplatform/bindings"
|
|
1011
|
-
*
|
|
1012
|
-
* // Create context from environment
|
|
1013
|
-
* const ctx = AlienContext.fromEnv()
|
|
1014
|
-
*
|
|
1015
|
-
* // Access bindings
|
|
1016
|
-
* const bucket = ctx.storage("my-bucket")
|
|
1017
|
-
* await bucket.put("hello.txt", "Hello, World!")
|
|
1018
|
-
*
|
|
1019
|
-
* // Register event handlers
|
|
1020
|
-
* ctx.onStorageEvent("uploads", async (event) => {
|
|
1021
|
-
* console.log("File uploaded:", event.key)
|
|
1022
|
-
* })
|
|
1023
|
-
*
|
|
1024
|
-
* // Start the runtime
|
|
1025
|
-
* await ctx.run()
|
|
1026
|
-
* ```
|
|
1027
|
-
*/
|
|
1028
|
-
declare class AlienContext implements AlienBindingsProvider {
|
|
1029
|
-
private readonly channel;
|
|
1030
|
-
private readonly instanceId;
|
|
1031
|
-
private readonly bindingCache;
|
|
1032
|
-
private eventLoop;
|
|
1033
|
-
private waitUntilManager;
|
|
1034
|
-
private constructor();
|
|
1035
|
-
/**
|
|
1036
|
-
* Create a context from environment variables.
|
|
1037
|
-
*
|
|
1038
|
-
* Reads the ALIEN_BINDINGS_GRPC_ADDRESS environment variable.
|
|
1039
|
-
*/
|
|
1040
|
-
static fromEnv(): Promise<AlienContext>;
|
|
1041
|
-
/**
|
|
1042
|
-
* Create a context with explicit configuration.
|
|
1043
|
-
*/
|
|
1044
|
-
static create(config: AlienBindingsConfig): Promise<AlienContext>;
|
|
1045
|
-
/**
|
|
1046
|
-
* Create a context for connecting to a remote agent.
|
|
1047
|
-
*
|
|
1048
|
-
* @param address - gRPC address of the remote agent
|
|
1049
|
-
*/
|
|
1050
|
-
static forRemoteAgent(address: string): Promise<AlienContext>;
|
|
1051
|
-
/**
|
|
1052
|
-
* Get or create a cached binding instance.
|
|
1053
|
-
*/
|
|
1054
|
-
private getBinding;
|
|
1055
|
-
/**
|
|
1056
|
-
* Get a storage binding.
|
|
1057
|
-
*
|
|
1058
|
-
* @param name - Binding name
|
|
1059
|
-
* @returns Storage binding instance
|
|
1060
|
-
*/
|
|
1061
|
-
storage(name: string): Storage;
|
|
1062
|
-
/**
|
|
1063
|
-
* Get a KV binding.
|
|
1064
|
-
*
|
|
1065
|
-
* @param name - Binding name
|
|
1066
|
-
* @returns KV binding instance
|
|
1067
|
-
*/
|
|
1068
|
-
kv(name: string): Kv;
|
|
1069
|
-
/**
|
|
1070
|
-
* Get a queue binding.
|
|
1071
|
-
*
|
|
1072
|
-
* @param name - Binding name
|
|
1073
|
-
* @returns Queue binding instance
|
|
1074
|
-
*/
|
|
1075
|
-
queue(name: string): Queue;
|
|
1076
|
-
/**
|
|
1077
|
-
* Get a vault binding.
|
|
1078
|
-
*
|
|
1079
|
-
* @param name - Binding name
|
|
1080
|
-
* @returns Vault binding instance
|
|
1081
|
-
*/
|
|
1082
|
-
vault(name: string): Vault;
|
|
1083
|
-
/**
|
|
1084
|
-
* Get a build binding.
|
|
1085
|
-
*
|
|
1086
|
-
* @param name - Binding name
|
|
1087
|
-
* @returns Build binding instance
|
|
1088
|
-
*/
|
|
1089
|
-
build(name: string): Build;
|
|
1090
|
-
/**
|
|
1091
|
-
* Get an artifact registry binding.
|
|
1092
|
-
*
|
|
1093
|
-
* @param name - Binding name
|
|
1094
|
-
* @returns ArtifactRegistry binding instance
|
|
1095
|
-
*/
|
|
1096
|
-
artifactRegistry(name: string): ArtifactRegistry;
|
|
1097
|
-
/**
|
|
1098
|
-
* Get a function binding.
|
|
1099
|
-
*
|
|
1100
|
-
* @param name - Binding name
|
|
1101
|
-
* @returns Function binding instance
|
|
1102
|
-
*/
|
|
1103
|
-
func(name: string): FunctionBinding;
|
|
1104
|
-
/**
|
|
1105
|
-
* Get a service account binding.
|
|
1106
|
-
*
|
|
1107
|
-
* @param name - Binding name
|
|
1108
|
-
* @returns ServiceAccount binding instance
|
|
1109
|
-
*/
|
|
1110
|
-
serviceAccount(name: string): ServiceAccount;
|
|
1111
|
-
/**
|
|
1112
|
-
* Register a storage event handler.
|
|
1113
|
-
*
|
|
1114
|
-
* @param bucket - Bucket name
|
|
1115
|
-
* @param handler - Event handler
|
|
1116
|
-
* @param options - Handler options
|
|
1117
|
-
* @returns Unsubscribe function
|
|
1118
|
-
*/
|
|
1119
|
-
onStorageEvent(bucket: string, handler: (event: StorageEvent$1) => Promise<void>, options?: {
|
|
1120
|
-
prefix?: string;
|
|
1121
|
-
}): () => void;
|
|
1122
|
-
/**
|
|
1123
|
-
* Register a cron event handler.
|
|
1124
|
-
*
|
|
1125
|
-
* @param schedule - Cron schedule expression
|
|
1126
|
-
* @param handler - Event handler
|
|
1127
|
-
* @returns Unsubscribe function
|
|
1128
|
-
*/
|
|
1129
|
-
onCronEvent(schedule: string, handler: (event: CronEvent) => Promise<void>): () => void;
|
|
1130
|
-
/**
|
|
1131
|
-
* Register a queue message handler.
|
|
1132
|
-
*
|
|
1133
|
-
* @param queueName - Queue name
|
|
1134
|
-
* @param handler - Message handler
|
|
1135
|
-
* @returns Unsubscribe function
|
|
1136
|
-
*/
|
|
1137
|
-
onQueueMessage<T = unknown>(queueName: string, handler: (message: QueueMessageEvent<T>) => Promise<void>): () => void;
|
|
1138
|
-
/**
|
|
1139
|
-
* Register an ARC command.
|
|
1140
|
-
*
|
|
1141
|
-
* @param name - Command name
|
|
1142
|
-
* @param handler - Command handler that receives params and returns a result
|
|
1143
|
-
*/
|
|
1144
|
-
command<TParams = unknown, TResult = unknown>(name: string, handler: (params: TParams) => Promise<TResult>): void;
|
|
1145
|
-
/**
|
|
1146
|
-
* Register an HTTP server with the control plane.
|
|
1147
|
-
*
|
|
1148
|
-
* @param port - Port the server is listening on
|
|
1149
|
-
*/
|
|
1150
|
-
registerHttpServer(port: number): Promise<void>;
|
|
1151
|
-
/**
|
|
1152
|
-
* Register a background task.
|
|
1153
|
-
*
|
|
1154
|
-
* @param promise - The promise to track
|
|
1155
|
-
*/
|
|
1156
|
-
waitUntil(promise: Promise<unknown>): void;
|
|
1157
|
-
/**
|
|
1158
|
-
* Start the Alien runtime.
|
|
1159
|
-
*
|
|
1160
|
-
* This initializes event handlers, registers with the control plane,
|
|
1161
|
-
* and starts processing events.
|
|
1162
|
-
*/
|
|
1163
|
-
run(): Promise<void>;
|
|
1164
|
-
/**
|
|
1165
|
-
* Stop the runtime gracefully.
|
|
1166
|
-
*/
|
|
1167
|
-
shutdown(): Promise<void>;
|
|
1168
|
-
}
|
|
1169
|
-
//#endregion
|
|
1170
|
-
//#region src/global.d.ts
|
|
1171
|
-
/**
|
|
1172
|
-
* Get a storage binding.
|
|
1173
|
-
*
|
|
1174
|
-
* @param name - Binding name
|
|
1175
|
-
* @returns Storage binding instance
|
|
1176
|
-
*
|
|
1177
|
-
* @example
|
|
1178
|
-
* ```typescript
|
|
1179
|
-
* import { storage } from "@alienplatform/bindings"
|
|
1180
|
-
*
|
|
1181
|
-
* const bucket = await storage("my-bucket")
|
|
1182
|
-
* await bucket.put("hello.txt", "Hello, World!")
|
|
1183
|
-
* ```
|
|
1184
|
-
*/
|
|
1185
|
-
declare function storage(name: string): Promise<Storage>;
|
|
1186
|
-
/**
|
|
1187
|
-
* Get a KV binding.
|
|
1188
|
-
*
|
|
1189
|
-
* @param name - Binding name
|
|
1190
|
-
* @returns KV binding instance
|
|
1191
|
-
*
|
|
1192
|
-
* @example
|
|
1193
|
-
* ```typescript
|
|
1194
|
-
* import { kv } from "@alienplatform/bindings"
|
|
1195
|
-
*
|
|
1196
|
-
* const cache = await kv("my-cache")
|
|
1197
|
-
* await cache.set("key", "value")
|
|
1198
|
-
* const value = await cache.getText("key")
|
|
1199
|
-
* ```
|
|
1200
|
-
*/
|
|
1201
|
-
declare function kv(name: string): Promise<Kv>;
|
|
1202
|
-
/**
|
|
1203
|
-
* Get a queue binding.
|
|
1204
|
-
*
|
|
1205
|
-
* @param name - Binding name
|
|
1206
|
-
* @returns Queue binding instance
|
|
1207
|
-
*
|
|
1208
|
-
* @example
|
|
1209
|
-
* ```typescript
|
|
1210
|
-
* import { queue } from "@alienplatform/bindings"
|
|
1211
|
-
*
|
|
1212
|
-
* const tasks = await queue("task-queue")
|
|
1213
|
-
* await tasks.send("job-type", { jobId: "123" })
|
|
1214
|
-
* ```
|
|
1215
|
-
*/
|
|
1216
|
-
declare function queue(name: string): Promise<Queue>;
|
|
1217
|
-
/**
|
|
1218
|
-
* Get a vault binding.
|
|
1219
|
-
*
|
|
1220
|
-
* @param name - Binding name
|
|
1221
|
-
* @returns Vault binding instance
|
|
1222
|
-
*
|
|
1223
|
-
* @example
|
|
1224
|
-
* ```typescript
|
|
1225
|
-
* import { vault } from "@alienplatform/bindings"
|
|
1226
|
-
*
|
|
1227
|
-
* const secrets = await vault("app-secrets")
|
|
1228
|
-
* const apiKey = await secrets.get("API_KEY")
|
|
1229
|
-
* ```
|
|
1230
|
-
*/
|
|
1231
|
-
declare function vault(name: string): Promise<Vault>;
|
|
1232
|
-
/**
|
|
1233
|
-
* Get a build binding.
|
|
1234
|
-
*
|
|
1235
|
-
* @param name - Binding name
|
|
1236
|
-
* @returns Build binding instance
|
|
1237
|
-
*
|
|
1238
|
-
* @example
|
|
1239
|
-
* ```typescript
|
|
1240
|
-
* import { build } from "@alienplatform/bindings"
|
|
1241
|
-
*
|
|
1242
|
-
* const builder = await build("my-builder")
|
|
1243
|
-
* const execution = await builder.start({ script: "npm run build" })
|
|
1244
|
-
* ```
|
|
1245
|
-
*/
|
|
1246
|
-
declare function build(name: string): Promise<Build>;
|
|
1247
|
-
/**
|
|
1248
|
-
* Get an artifact registry binding.
|
|
1249
|
-
*
|
|
1250
|
-
* @param name - Binding name
|
|
1251
|
-
* @returns ArtifactRegistry binding instance
|
|
1252
|
-
*
|
|
1253
|
-
* @example
|
|
1254
|
-
* ```typescript
|
|
1255
|
-
* import { artifactRegistry } from "@alienplatform/bindings"
|
|
1256
|
-
*
|
|
1257
|
-
* const registry = await artifactRegistry("my-registry")
|
|
1258
|
-
* const repo = await registry.createRepository("my-app")
|
|
1259
|
-
* ```
|
|
1260
|
-
*/
|
|
1261
|
-
declare function artifactRegistry(name: string): Promise<ArtifactRegistry>;
|
|
1262
|
-
/**
|
|
1263
|
-
* Get a function binding.
|
|
1264
|
-
*
|
|
1265
|
-
* @param name - Binding name
|
|
1266
|
-
* @returns Function binding instance
|
|
1267
|
-
*
|
|
1268
|
-
* @example
|
|
1269
|
-
* ```typescript
|
|
1270
|
-
* import { func } from "@alienplatform/bindings"
|
|
1271
|
-
*
|
|
1272
|
-
* const processor = await func("image-processor")
|
|
1273
|
-
* const result = await processor.invokeJson("resize", { width: 800 })
|
|
1274
|
-
* ```
|
|
1275
|
-
*/
|
|
1276
|
-
declare function func(name: string): Promise<FunctionBinding>;
|
|
1277
|
-
/**
|
|
1278
|
-
* Get a service account binding.
|
|
1279
|
-
*
|
|
1280
|
-
* @param name - Binding name
|
|
1281
|
-
* @returns ServiceAccount binding instance
|
|
1282
|
-
*
|
|
1283
|
-
* @example
|
|
1284
|
-
* ```typescript
|
|
1285
|
-
* import { serviceAccount } from "@alienplatform/bindings"
|
|
1286
|
-
*
|
|
1287
|
-
* const sa = await serviceAccount("deployment-account")
|
|
1288
|
-
* const info = await sa.getInfo()
|
|
1289
|
-
* ```
|
|
1290
|
-
*/
|
|
1291
|
-
declare function serviceAccount(name: string): Promise<ServiceAccount>;
|
|
1292
|
-
/**
|
|
1293
|
-
* Register a storage event handler.
|
|
1294
|
-
*
|
|
1295
|
-
* @param bucket - Bucket name
|
|
1296
|
-
* @param handler - Event handler
|
|
1297
|
-
* @param options - Handler options
|
|
1298
|
-
* @returns Unsubscribe function
|
|
1299
|
-
*
|
|
1300
|
-
* @example
|
|
1301
|
-
* ```typescript
|
|
1302
|
-
* import { onStorageEvent } from "@alienplatform/bindings"
|
|
1303
|
-
*
|
|
1304
|
-
* onStorageEvent("uploads", async (event) => {
|
|
1305
|
-
* console.log("File uploaded:", event.objectKey)
|
|
1306
|
-
* })
|
|
1307
|
-
* ```
|
|
1308
|
-
*/
|
|
1309
|
-
declare function onStorageEvent(bucket: string, handler: (event: StorageEvent) => Promise<void>, options?: {
|
|
1310
|
-
prefix?: string;
|
|
1311
|
-
}): () => void;
|
|
1312
|
-
/**
|
|
1313
|
-
* Register a cron event handler.
|
|
1314
|
-
*
|
|
1315
|
-
* @param schedule - Cron schedule expression
|
|
1316
|
-
* @param handler - Event handler
|
|
1317
|
-
* @returns Unsubscribe function
|
|
1318
|
-
*
|
|
1319
|
-
* @example
|
|
1320
|
-
* ```typescript
|
|
1321
|
-
* import { onCronEvent } from "@alienplatform/bindings"
|
|
1322
|
-
*
|
|
1323
|
-
* onCronEvent("0 * * * *", async (event) => {
|
|
1324
|
-
* console.log("Hourly task running at:", event.timestamp)
|
|
1325
|
-
* })
|
|
1326
|
-
* ```
|
|
1327
|
-
*/
|
|
1328
|
-
declare function onCronEvent(schedule: string, handler: (event: CronEvent) => Promise<void>): () => void;
|
|
1329
|
-
/**
|
|
1330
|
-
* Register a queue message handler.
|
|
1331
|
-
*
|
|
1332
|
-
* @param queueName - Queue name
|
|
1333
|
-
* @param handler - Message handler
|
|
1334
|
-
* @returns Unsubscribe function
|
|
1335
|
-
*
|
|
1336
|
-
* @example
|
|
1337
|
-
* ```typescript
|
|
1338
|
-
* import { onQueueMessage } from "@alienplatform/bindings"
|
|
1339
|
-
*
|
|
1340
|
-
* onQueueMessage("tasks", async (message) => {
|
|
1341
|
-
* console.log("Processing:", message.payload)
|
|
1342
|
-
* })
|
|
1343
|
-
* ```
|
|
1344
|
-
*/
|
|
1345
|
-
declare function onQueueMessage<T = unknown>(queueName: string, handler: (message: QueueMessageEvent<T>) => Promise<void>): () => void;
|
|
1346
|
-
/**
|
|
1347
|
-
* Register a CLI command.
|
|
1348
|
-
*
|
|
1349
|
-
* @param name - Command name
|
|
1350
|
-
* @param description - Command description
|
|
1351
|
-
* @param handler - Command handler
|
|
1352
|
-
*
|
|
1353
|
-
* @example
|
|
1354
|
-
* ```typescript
|
|
1355
|
-
* import { command } from "@alienplatform/bindings"
|
|
1356
|
-
*
|
|
1357
|
-
* command("migrate", "Run database migrations", async (args) => {
|
|
1358
|
-
* await runMigrations()
|
|
1359
|
-
* return 0
|
|
1360
|
-
* })
|
|
1361
|
-
* ```
|
|
1362
|
-
*/
|
|
1363
|
-
declare function command(name: string, _description: string, handler: (args: string[]) => Promise<number>): void;
|
|
1364
|
-
/**
|
|
1365
|
-
* Register a background task to continue after the response.
|
|
1366
|
-
*
|
|
1367
|
-
* @param promise - The promise to track
|
|
1368
|
-
*
|
|
1369
|
-
* @example
|
|
1370
|
-
* ```typescript
|
|
1371
|
-
* import { waitUntil } from "@alienplatform/bindings"
|
|
1372
|
-
*
|
|
1373
|
-
* export default {
|
|
1374
|
-
* async fetch(request: Request): Promise<Response> {
|
|
1375
|
-
* waitUntil(sendAnalytics(request))
|
|
1376
|
-
* return Response.json({ status: "ok" })
|
|
1377
|
-
* }
|
|
1378
|
-
* }
|
|
1379
|
-
* ```
|
|
1380
|
-
*/
|
|
1381
|
-
declare function waitUntil(promise: Promise<unknown>): void;
|
|
1382
|
-
//#endregion
|
|
1383
|
-
//#region src/errors.d.ts
|
|
1384
|
-
/**
|
|
1385
|
-
* Error thrown when the gRPC connection to the alien-runtime fails.
|
|
1386
|
-
*/
|
|
1387
|
-
declare const GrpcConnectionError: {
|
|
1388
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1389
|
-
endpoint: z.ZodString;
|
|
1390
|
-
reason: z.ZodString;
|
|
1391
|
-
}, z.core.$strip>>;
|
|
1392
|
-
contextSchema: z.ZodObject<{
|
|
1393
|
-
endpoint: z.ZodString;
|
|
1394
|
-
reason: z.ZodString;
|
|
1395
|
-
}, z.core.$strip>;
|
|
1396
|
-
create: (context: {
|
|
1397
|
-
endpoint: string;
|
|
1398
|
-
reason: string;
|
|
1399
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1400
|
-
endpoint: z.ZodString;
|
|
1401
|
-
reason: z.ZodString;
|
|
1402
|
-
}, z.core.$strip>>;
|
|
1403
|
-
};
|
|
1404
|
-
/**
|
|
1405
|
-
* Error thrown when a gRPC call fails.
|
|
1406
|
-
*/
|
|
1407
|
-
declare const GrpcCallError: {
|
|
1408
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1409
|
-
service: z.ZodString;
|
|
1410
|
-
method: z.ZodString;
|
|
1411
|
-
grpcCode: z.ZodString;
|
|
1412
|
-
details: z.ZodString;
|
|
1413
|
-
}, z.core.$strip>>;
|
|
1414
|
-
contextSchema: z.ZodObject<{
|
|
1415
|
-
service: z.ZodString;
|
|
1416
|
-
method: z.ZodString;
|
|
1417
|
-
grpcCode: z.ZodString;
|
|
1418
|
-
details: z.ZodString;
|
|
1419
|
-
}, z.core.$strip>;
|
|
1420
|
-
create: (context: {
|
|
1421
|
-
service: string;
|
|
1422
|
-
method: string;
|
|
1423
|
-
grpcCode: string;
|
|
1424
|
-
details: string;
|
|
1425
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1426
|
-
service: z.ZodString;
|
|
1427
|
-
method: z.ZodString;
|
|
1428
|
-
grpcCode: z.ZodString;
|
|
1429
|
-
details: z.ZodString;
|
|
1430
|
-
}, z.core.$strip>>;
|
|
1431
|
-
};
|
|
1432
|
-
/**
|
|
1433
|
-
* Error thrown when a binding is not found.
|
|
1434
|
-
*/
|
|
1435
|
-
declare const BindingNotFoundError: {
|
|
1436
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1437
|
-
bindingName: z.ZodString;
|
|
1438
|
-
bindingType: z.ZodString;
|
|
1439
|
-
}, z.core.$strip>>;
|
|
1440
|
-
contextSchema: z.ZodObject<{
|
|
1441
|
-
bindingName: z.ZodString;
|
|
1442
|
-
bindingType: z.ZodString;
|
|
1443
|
-
}, z.core.$strip>;
|
|
1444
|
-
create: (context: {
|
|
1445
|
-
bindingName: string;
|
|
1446
|
-
bindingType: string;
|
|
1447
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1448
|
-
bindingName: z.ZodString;
|
|
1449
|
-
bindingType: z.ZodString;
|
|
1450
|
-
}, z.core.$strip>>;
|
|
1451
|
-
};
|
|
1452
|
-
/**
|
|
1453
|
-
* Error thrown when the AlienContext is not initialized.
|
|
1454
|
-
*/
|
|
1455
|
-
declare const ContextNotInitializedError: {
|
|
1456
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1457
|
-
operation: z.ZodString;
|
|
1458
|
-
}, z.core.$strip>>;
|
|
1459
|
-
contextSchema: z.ZodObject<{
|
|
1460
|
-
operation: z.ZodString;
|
|
1461
|
-
}, z.core.$strip>;
|
|
1462
|
-
create: (context: {
|
|
1463
|
-
operation: string;
|
|
1464
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1465
|
-
operation: z.ZodString;
|
|
1466
|
-
}, z.core.$strip>>;
|
|
1467
|
-
};
|
|
1468
|
-
/**
|
|
1469
|
-
* Error thrown when a required environment variable is missing.
|
|
1470
|
-
*/
|
|
1471
|
-
declare const MissingEnvVarError: {
|
|
1472
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1473
|
-
variable: z.ZodString;
|
|
1474
|
-
description: z.ZodString;
|
|
1475
|
-
}, z.core.$strip>>;
|
|
1476
|
-
contextSchema: z.ZodObject<{
|
|
1477
|
-
variable: z.ZodString;
|
|
1478
|
-
description: z.ZodString;
|
|
1479
|
-
}, z.core.$strip>;
|
|
1480
|
-
create: (context: {
|
|
1481
|
-
variable: string;
|
|
1482
|
-
description: string;
|
|
1483
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1484
|
-
variable: z.ZodString;
|
|
1485
|
-
description: z.ZodString;
|
|
1486
|
-
}, z.core.$strip>>;
|
|
1487
|
-
};
|
|
1488
|
-
/**
|
|
1489
|
-
* Error thrown when a storage object is not found.
|
|
1490
|
-
*/
|
|
1491
|
-
declare const StorageObjectNotFoundError: {
|
|
1492
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1493
|
-
bindingName: z.ZodString;
|
|
1494
|
-
path: z.ZodString;
|
|
1495
|
-
}, z.core.$strip>>;
|
|
1496
|
-
contextSchema: z.ZodObject<{
|
|
1497
|
-
bindingName: z.ZodString;
|
|
1498
|
-
path: z.ZodString;
|
|
1499
|
-
}, z.core.$strip>;
|
|
1500
|
-
create: (context: {
|
|
1501
|
-
bindingName: string;
|
|
1502
|
-
path: string;
|
|
1503
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1504
|
-
bindingName: z.ZodString;
|
|
1505
|
-
path: z.ZodString;
|
|
1506
|
-
}, z.core.$strip>>;
|
|
1507
|
-
};
|
|
1508
|
-
/**
|
|
1509
|
-
* Error thrown when a storage precondition fails.
|
|
1510
|
-
*/
|
|
1511
|
-
declare const StoragePreconditionError: {
|
|
1512
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1513
|
-
bindingName: z.ZodString;
|
|
1514
|
-
path: z.ZodString;
|
|
1515
|
-
condition: z.ZodString;
|
|
1516
|
-
}, z.core.$strip>>;
|
|
1517
|
-
contextSchema: z.ZodObject<{
|
|
1518
|
-
bindingName: z.ZodString;
|
|
1519
|
-
path: z.ZodString;
|
|
1520
|
-
condition: z.ZodString;
|
|
1521
|
-
}, z.core.$strip>;
|
|
1522
|
-
create: (context: {
|
|
1523
|
-
bindingName: string;
|
|
1524
|
-
path: string;
|
|
1525
|
-
condition: string;
|
|
1526
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1527
|
-
bindingName: z.ZodString;
|
|
1528
|
-
path: z.ZodString;
|
|
1529
|
-
condition: z.ZodString;
|
|
1530
|
-
}, z.core.$strip>>;
|
|
1531
|
-
};
|
|
1532
|
-
/**
|
|
1533
|
-
* Error thrown when a storage object already exists (for create mode).
|
|
1534
|
-
*/
|
|
1535
|
-
declare const StorageObjectExistsError: {
|
|
1536
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1537
|
-
bindingName: z.ZodString;
|
|
1538
|
-
path: z.ZodString;
|
|
1539
|
-
}, z.core.$strip>>;
|
|
1540
|
-
contextSchema: z.ZodObject<{
|
|
1541
|
-
bindingName: z.ZodString;
|
|
1542
|
-
path: z.ZodString;
|
|
1543
|
-
}, z.core.$strip>;
|
|
1544
|
-
create: (context: {
|
|
1545
|
-
bindingName: string;
|
|
1546
|
-
path: string;
|
|
1547
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1548
|
-
bindingName: z.ZodString;
|
|
1549
|
-
path: z.ZodString;
|
|
1550
|
-
}, z.core.$strip>>;
|
|
1551
|
-
};
|
|
1552
|
-
/**
|
|
1553
|
-
* Error thrown when a KV key is not found.
|
|
1554
|
-
*/
|
|
1555
|
-
declare const KvKeyNotFoundError: {
|
|
1556
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1557
|
-
bindingName: z.ZodString;
|
|
1558
|
-
key: z.ZodString;
|
|
1559
|
-
}, z.core.$strip>>;
|
|
1560
|
-
contextSchema: z.ZodObject<{
|
|
1561
|
-
bindingName: z.ZodString;
|
|
1562
|
-
key: z.ZodString;
|
|
1563
|
-
}, z.core.$strip>;
|
|
1564
|
-
create: (context: {
|
|
1565
|
-
bindingName: string;
|
|
1566
|
-
key: string;
|
|
1567
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1568
|
-
bindingName: z.ZodString;
|
|
1569
|
-
key: z.ZodString;
|
|
1570
|
-
}, z.core.$strip>>;
|
|
1571
|
-
};
|
|
1572
|
-
/**
|
|
1573
|
-
* Error thrown when a KV key is invalid.
|
|
1574
|
-
*/
|
|
1575
|
-
declare const KvInvalidKeyError: {
|
|
1576
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1577
|
-
key: z.ZodString;
|
|
1578
|
-
reason: z.ZodString;
|
|
1579
|
-
}, z.core.$strip>>;
|
|
1580
|
-
contextSchema: z.ZodObject<{
|
|
1581
|
-
key: z.ZodString;
|
|
1582
|
-
reason: z.ZodString;
|
|
1583
|
-
}, z.core.$strip>;
|
|
1584
|
-
create: (context: {
|
|
1585
|
-
key: string;
|
|
1586
|
-
reason: string;
|
|
1587
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1588
|
-
key: z.ZodString;
|
|
1589
|
-
reason: z.ZodString;
|
|
1590
|
-
}, z.core.$strip>>;
|
|
1591
|
-
};
|
|
1592
|
-
/**
|
|
1593
|
-
* Error thrown when a KV value is invalid.
|
|
1594
|
-
*/
|
|
1595
|
-
declare const KvInvalidValueError: {
|
|
1596
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1597
|
-
reason: z.ZodString;
|
|
1598
|
-
}, z.core.$strip>>;
|
|
1599
|
-
contextSchema: z.ZodObject<{
|
|
1600
|
-
reason: z.ZodString;
|
|
1601
|
-
}, z.core.$strip>;
|
|
1602
|
-
create: (context: {
|
|
1603
|
-
reason: string;
|
|
1604
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1605
|
-
reason: z.ZodString;
|
|
1606
|
-
}, z.core.$strip>>;
|
|
1607
|
-
};
|
|
1608
|
-
/**
|
|
1609
|
-
* Error thrown when a secret is not found.
|
|
1610
|
-
*/
|
|
1611
|
-
declare const SecretNotFoundError: {
|
|
1612
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1613
|
-
bindingName: z.ZodString;
|
|
1614
|
-
secretName: z.ZodString;
|
|
1615
|
-
}, z.core.$strip>>;
|
|
1616
|
-
contextSchema: z.ZodObject<{
|
|
1617
|
-
bindingName: z.ZodString;
|
|
1618
|
-
secretName: z.ZodString;
|
|
1619
|
-
}, z.core.$strip>;
|
|
1620
|
-
create: (context: {
|
|
1621
|
-
bindingName: string;
|
|
1622
|
-
secretName: string;
|
|
1623
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1624
|
-
bindingName: z.ZodString;
|
|
1625
|
-
secretName: z.ZodString;
|
|
1626
|
-
}, z.core.$strip>>;
|
|
1627
|
-
};
|
|
1628
|
-
/**
|
|
1629
|
-
* Error thrown when a queue operation fails.
|
|
1630
|
-
*/
|
|
1631
|
-
declare const QueueOperationError: {
|
|
1632
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1633
|
-
bindingName: z.ZodString;
|
|
1634
|
-
queue: z.ZodString;
|
|
1635
|
-
operation: z.ZodString;
|
|
1636
|
-
reason: z.ZodString;
|
|
1637
|
-
}, z.core.$strip>>;
|
|
1638
|
-
contextSchema: z.ZodObject<{
|
|
1639
|
-
bindingName: z.ZodString;
|
|
1640
|
-
queue: z.ZodString;
|
|
1641
|
-
operation: z.ZodString;
|
|
1642
|
-
reason: z.ZodString;
|
|
1643
|
-
}, z.core.$strip>;
|
|
1644
|
-
create: (context: {
|
|
1645
|
-
bindingName: string;
|
|
1646
|
-
queue: string;
|
|
1647
|
-
operation: string;
|
|
1648
|
-
reason: string;
|
|
1649
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1650
|
-
bindingName: z.ZodString;
|
|
1651
|
-
queue: z.ZodString;
|
|
1652
|
-
operation: z.ZodString;
|
|
1653
|
-
reason: z.ZodString;
|
|
1654
|
-
}, z.core.$strip>>;
|
|
1655
|
-
};
|
|
1656
|
-
/**
|
|
1657
|
-
* Error thrown when an event handler is already registered.
|
|
1658
|
-
*/
|
|
1659
|
-
declare const EventHandlerAlreadyRegisteredError: {
|
|
1660
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1661
|
-
handlerType: z.ZodString;
|
|
1662
|
-
resourceName: z.ZodString;
|
|
1663
|
-
}, z.core.$strip>>;
|
|
1664
|
-
contextSchema: z.ZodObject<{
|
|
1665
|
-
handlerType: z.ZodString;
|
|
1666
|
-
resourceName: z.ZodString;
|
|
1667
|
-
}, z.core.$strip>;
|
|
1668
|
-
create: (context: {
|
|
1669
|
-
handlerType: string;
|
|
1670
|
-
resourceName: string;
|
|
1671
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1672
|
-
handlerType: z.ZodString;
|
|
1673
|
-
resourceName: z.ZodString;
|
|
1674
|
-
}, z.core.$strip>>;
|
|
1675
|
-
};
|
|
1676
|
-
/**
|
|
1677
|
-
* Error thrown when a command is already registered.
|
|
1678
|
-
*/
|
|
1679
|
-
declare const CommandAlreadyRegisteredError: {
|
|
1680
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1681
|
-
commandName: z.ZodString;
|
|
1682
|
-
}, z.core.$strip>>;
|
|
1683
|
-
contextSchema: z.ZodObject<{
|
|
1684
|
-
commandName: z.ZodString;
|
|
1685
|
-
}, z.core.$strip>;
|
|
1686
|
-
create: (context: {
|
|
1687
|
-
commandName: string;
|
|
1688
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1689
|
-
commandName: z.ZodString;
|
|
1690
|
-
}, z.core.$strip>>;
|
|
1691
|
-
};
|
|
1692
|
-
/**
|
|
1693
|
-
* Error thrown when the binding configuration is invalid.
|
|
1694
|
-
*/
|
|
1695
|
-
declare const InvalidBindingConfigError: {
|
|
1696
|
-
metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
|
|
1697
|
-
message: z.ZodString;
|
|
1698
|
-
suggestion: z.ZodOptional<z.ZodString>;
|
|
1699
|
-
}, z.core.$strip>>;
|
|
1700
|
-
contextSchema: z.ZodObject<{
|
|
1701
|
-
message: z.ZodString;
|
|
1702
|
-
suggestion: z.ZodOptional<z.ZodString>;
|
|
1703
|
-
}, z.core.$strip>;
|
|
1704
|
-
create: (context: {
|
|
1705
|
-
message: string;
|
|
1706
|
-
suggestion?: string | undefined;
|
|
1707
|
-
}) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
|
|
1708
|
-
message: z.ZodString;
|
|
1709
|
-
suggestion: z.ZodOptional<z.ZodString>;
|
|
1710
|
-
}, z.core.$strip>>;
|
|
1711
|
-
};
|
|
1712
|
-
//#endregion
|
|
1713
|
-
//#region src/commands.d.ts
|
|
1714
|
-
/**
|
|
1715
|
-
* Command handling for Alien bindings.
|
|
1716
|
-
*
|
|
1717
|
-
* Provides ARC command registration and execution.
|
|
1718
|
-
*/
|
|
1719
|
-
/**
|
|
1720
|
-
* Command definition.
|
|
1721
|
-
*/
|
|
1722
|
-
interface CommandDefinition {
|
|
1723
|
-
/** Command name */
|
|
1724
|
-
name: string;
|
|
1725
|
-
/** Handler function that receives params and returns a result */
|
|
1726
|
-
handler: (params: unknown) => Promise<unknown>;
|
|
1727
|
-
}
|
|
1728
|
-
/**
|
|
1729
|
-
* Register an ARC command.
|
|
1730
|
-
*
|
|
1731
|
-
* @param name - Command name
|
|
1732
|
-
* @param handler - Command handler function that receives params and returns a result
|
|
1733
|
-
*
|
|
1734
|
-
* @example
|
|
1735
|
-
* ```typescript
|
|
1736
|
-
* import { command } from "@alienplatform/bindings"
|
|
1737
|
-
*
|
|
1738
|
-
* command("echo", async ({ message }: { message: string }) => {
|
|
1739
|
-
* return {
|
|
1740
|
-
* message,
|
|
1741
|
-
* timestamp: new Date().toISOString(),
|
|
1742
|
-
* }
|
|
1743
|
-
* })
|
|
1744
|
-
*
|
|
1745
|
-
* command("process-data", async ({ data }: { data: string[] }) => {
|
|
1746
|
-
* const result = await processData(data)
|
|
1747
|
-
* return { processed: result.length }
|
|
1748
|
-
* })
|
|
1749
|
-
* ```
|
|
1750
|
-
*/
|
|
1751
|
-
|
|
1752
|
-
/**
|
|
1753
|
-
* Get all registered commands.
|
|
1754
|
-
*
|
|
1755
|
-
* @internal
|
|
1756
|
-
*/
|
|
1757
|
-
declare function getCommands(): Map<string, CommandDefinition>;
|
|
1758
|
-
/**
|
|
1759
|
-
* Execute an ARC command by name.
|
|
1760
|
-
*
|
|
1761
|
-
* @param name - Command name to execute
|
|
1762
|
-
* @param params - Command parameters
|
|
1763
|
-
* @returns Command result
|
|
1764
|
-
*
|
|
1765
|
-
* @internal
|
|
1766
|
-
*/
|
|
1767
|
-
declare function runCommand(name: string, params: unknown): Promise<unknown>;
|
|
1768
|
-
//#endregion
|
|
1769
|
-
export { type AlienBindingsConfig, type AlienBindingsProvider, AlienContext, ArtifactRegistry, type ArtifactRegistryCredentials, type ArtifactRegistryPermissions, type AwsCrossAccountAccess, type AwsServiceAccountInfo, type AzureServiceAccountInfo, BindingNotFoundError, Build, type BuildExecution, type BuildStartConfig, CommandAlreadyRegisteredError, type CommandDefinition, type ComputeServiceType, ContextNotInitializedError, type CronEvent, type CrossAccountAccess, type CrossAccountPermissions, EventHandlerAlreadyRegisteredError, FunctionBinding, type FunctionInvokeRequest, type FunctionInvokeResponse, type GcpCrossAccountAccess, type GcpServiceAccountInfo, GrpcCallError, GrpcConnectionError, type ImpersonationRequest, InvalidBindingConfigError, Kv, KvInvalidKeyError, KvInvalidValueError, KvKeyNotFoundError, type KvPutOptions, type KvScanResult, MissingEnvVarError, Queue, type QueueMessage, type QueueMessageEvent, QueueOperationError, type ReceivedQueueMessage, type RepositoryInfo, type ScheduledEvent, SecretNotFoundError, ServiceAccount, type ServiceAccountInfo, type SignedUrlOptions, type SignedUrlResult, Storage, type StorageEvent, type StorageEventType, type StorageGetOptions, type StorageGetResult, type StorageListResult, StorageObjectExistsError, type StorageObjectMeta, StorageObjectNotFoundError, StoragePreconditionError, type StoragePutOptions, Vault, artifactRegistry, build, command, func, getCommands, kv, onCronEvent, onQueueMessage, onStorageEvent, queue, runCommand, serviceAccount, storage, vault, waitUntil };
|
|
2
|
+
* `@alienplatform/bindings` — direct TypeScript bindings for Alien storage, kv,
|
|
3
|
+
* queue, and vault, backed by an in-process napi-rs addon over the Rust
|
|
4
|
+
* `alien-bindings` crate.
|
|
5
|
+
*
|
|
6
|
+
* Constructing a factory (`storage("x")`, `kv("y")`, …) does no I/O and needs no
|
|
7
|
+
* addon; the native module loads on the first operation. The first operation
|
|
8
|
+
* against a binding with no `ALIEN_<NAME>_BINDING` in the environment throws
|
|
9
|
+
* {@link BindingNotConfiguredError}.
|
|
10
|
+
*/
|
|
11
|
+
/** Resolve the storage binding named `name`. */
|
|
12
|
+
export declare const storage: (name: string) => import("./types.js").Storage;
|
|
13
|
+
/** Resolve the key-value binding named `name`. */
|
|
14
|
+
export declare const kv: (name: string) => import("./types.js").Kv;
|
|
15
|
+
/** Resolve the queue binding named `name`. */
|
|
16
|
+
export declare const queue: (name: string) => import("./types.js").Queue;
|
|
17
|
+
/** Resolve the vault binding named `name`. */
|
|
18
|
+
export declare const vault: (name: string) => import("./types.js").Vault;
|
|
19
|
+
export { AlienError, BindingNotConfiguredError, defineError } from "./errors.js";
|
|
20
|
+
export type { Kv, KvScanItem, KvScanResult, KvSetOptions, ObjectMeta, PresignedRequest, Queue, QueueMessage, SignedUrlMethod, SignedUrlOptions, Storage, Vault, } from "./types.js";
|
|
1770
21
|
//# sourceMappingURL=index.d.ts.map
|