@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
package/src/types.ts
DELETED
|
@@ -1,397 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common types for the Alien bindings SDK.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// Re-export build types from core
|
|
6
|
-
export type { BuildStatus, ComputeType } from "@alienplatform/core"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Branded type for binding names.
|
|
10
|
-
*/
|
|
11
|
-
export type BindingName = string & { readonly __brand: unique symbol }
|
|
12
|
-
|
|
13
|
-
// ============================================================================
|
|
14
|
-
// Storage Types
|
|
15
|
-
// ============================================================================
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Options for storage get operations.
|
|
19
|
-
*/
|
|
20
|
-
export interface StorageGetOptions {
|
|
21
|
-
/** Range start offset in bytes */
|
|
22
|
-
rangeStart?: number
|
|
23
|
-
/** Range end offset in bytes */
|
|
24
|
-
rangeEnd?: number
|
|
25
|
-
/** If-Match header value (ETag) */
|
|
26
|
-
ifMatch?: string
|
|
27
|
-
/** If-None-Match header value (ETag) */
|
|
28
|
-
ifNoneMatch?: string
|
|
29
|
-
/** If-Modified-Since timestamp */
|
|
30
|
-
ifModifiedSince?: Date
|
|
31
|
-
/** If-Unmodified-Since timestamp */
|
|
32
|
-
ifUnmodifiedSince?: Date
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Options for storage put operations.
|
|
37
|
-
*/
|
|
38
|
-
export interface StoragePutOptions {
|
|
39
|
-
/** Content type of the object */
|
|
40
|
-
contentType?: string
|
|
41
|
-
/** Custom metadata */
|
|
42
|
-
metadata?: Record<string, string>
|
|
43
|
-
/** Only write if the object doesn't already exist */
|
|
44
|
-
ifNotExists?: boolean
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Object metadata from storage.
|
|
49
|
-
*/
|
|
50
|
-
export interface StorageObjectMeta {
|
|
51
|
-
/** Full path of the object */
|
|
52
|
-
location: string
|
|
53
|
-
/** Last modified timestamp */
|
|
54
|
-
lastModified?: Date
|
|
55
|
-
/** Object size in bytes */
|
|
56
|
-
size: number
|
|
57
|
-
/** ETag (entity tag) for the object */
|
|
58
|
-
etag?: string
|
|
59
|
-
/** Object version */
|
|
60
|
-
version?: string
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Result of a storage get operation.
|
|
65
|
-
*/
|
|
66
|
-
export interface StorageGetResult {
|
|
67
|
-
/** Object metadata */
|
|
68
|
-
meta: StorageObjectMeta
|
|
69
|
-
/** Object data as bytes */
|
|
70
|
-
data: Uint8Array
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Result of a storage list operation with delimiter.
|
|
75
|
-
*/
|
|
76
|
-
export interface StorageListResult {
|
|
77
|
-
/** Common prefixes (directories) */
|
|
78
|
-
commonPrefixes: string[]
|
|
79
|
-
/** Object metadata entries */
|
|
80
|
-
objects: StorageObjectMeta[]
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Options for signed URL generation.
|
|
85
|
-
*/
|
|
86
|
-
export interface SignedUrlOptions {
|
|
87
|
-
/** Operation type: get (download), put (upload), or delete */
|
|
88
|
-
operation: "get" | "put" | "delete"
|
|
89
|
-
/** URL expiration duration in seconds */
|
|
90
|
-
expiresInSeconds?: number
|
|
91
|
-
/** Content type for put operations */
|
|
92
|
-
contentType?: string
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Result of signed URL generation.
|
|
97
|
-
*/
|
|
98
|
-
export interface SignedUrlResult {
|
|
99
|
-
/** The signed URL */
|
|
100
|
-
url: string
|
|
101
|
-
/** Headers that must be included when using the signed URL */
|
|
102
|
-
headers?: Record<string, string>
|
|
103
|
-
/** URL expiration timestamp */
|
|
104
|
-
expiresAt?: Date
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// ============================================================================
|
|
108
|
-
// KV Types
|
|
109
|
-
// ============================================================================
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Options for KV put operations.
|
|
113
|
-
*/
|
|
114
|
-
export interface KvPutOptions {
|
|
115
|
-
/** Time-to-live in milliseconds */
|
|
116
|
-
ttlMs?: number
|
|
117
|
-
/** Only write if the key doesn't exist */
|
|
118
|
-
ifNotExists?: boolean
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Result of a KV scan operation.
|
|
123
|
-
*/
|
|
124
|
-
export interface KvScanResult {
|
|
125
|
-
/** Key-value pairs */
|
|
126
|
-
items: Array<{ key: string; value: Uint8Array }>
|
|
127
|
-
/** Cursor for next page */
|
|
128
|
-
nextCursor?: string
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// ============================================================================
|
|
132
|
-
// Queue Types
|
|
133
|
-
// ============================================================================
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* A message received from a queue via the Queue binding.
|
|
137
|
-
* (Not to be confused with QueueMessage from @alienplatform/core which is used for event handlers)
|
|
138
|
-
*/
|
|
139
|
-
export interface ReceivedQueueMessage<T = unknown> {
|
|
140
|
-
/** Message payload */
|
|
141
|
-
payload: T
|
|
142
|
-
/** Receipt handle for acknowledgment */
|
|
143
|
-
receiptHandle: string
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// ============================================================================
|
|
147
|
-
// Build Types
|
|
148
|
-
// ============================================================================
|
|
149
|
-
|
|
150
|
-
// BuildStatus and ComputeType are re-exported from @alienplatform/core above
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Configuration for starting a build via the Build binding.
|
|
154
|
-
* (SDK-specific - different from BuildConfig in core which is for resource definition)
|
|
155
|
-
*/
|
|
156
|
-
export interface BuildStartConfig {
|
|
157
|
-
/** Build script to execute */
|
|
158
|
-
script: string
|
|
159
|
-
/** Environment variables */
|
|
160
|
-
environment?: Record<string, string>
|
|
161
|
-
/** Compute type */
|
|
162
|
-
computeType?: import("@alienplatform/core").ComputeType
|
|
163
|
-
/** Timeout in seconds */
|
|
164
|
-
timeoutSeconds?: number
|
|
165
|
-
/** Monitoring configuration */
|
|
166
|
-
monitoring?: {
|
|
167
|
-
endpoint: string
|
|
168
|
-
headers?: Record<string, string>
|
|
169
|
-
logsUri?: string
|
|
170
|
-
tlsEnabled?: boolean
|
|
171
|
-
tlsVerify?: boolean
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Information about a build execution.
|
|
177
|
-
*/
|
|
178
|
-
export interface BuildExecution {
|
|
179
|
-
/** Build execution ID */
|
|
180
|
-
id: string
|
|
181
|
-
/** Current status */
|
|
182
|
-
status: import("@alienplatform/core").BuildStatus
|
|
183
|
-
/** Start timestamp */
|
|
184
|
-
startTime?: Date
|
|
185
|
-
/** End timestamp */
|
|
186
|
-
endTime?: Date
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// ============================================================================
|
|
190
|
-
// Artifact Registry Types
|
|
191
|
-
// ============================================================================
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Permission levels for artifact registry access.
|
|
195
|
-
*/
|
|
196
|
-
export type ArtifactRegistryPermissions = "pull" | "push-pull"
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Information about a repository.
|
|
200
|
-
*/
|
|
201
|
-
export interface RepositoryInfo {
|
|
202
|
-
/** Repository name */
|
|
203
|
-
name: string
|
|
204
|
-
/** Repository URI */
|
|
205
|
-
uri: string
|
|
206
|
-
/** Creation timestamp */
|
|
207
|
-
createdAt?: Date
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* How the registry expects credentials to be presented.
|
|
212
|
-
* - "basic": HTTP Basic auth (ECR, GAR, Local)
|
|
213
|
-
* - "bearer": HTTP Bearer token (ACR)
|
|
214
|
-
*/
|
|
215
|
-
export type RegistryAuthMethod = "basic" | "bearer"
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Credentials for repository access.
|
|
219
|
-
*/
|
|
220
|
-
export interface ArtifactRegistryCredentials {
|
|
221
|
-
/** How to present these credentials to the registry */
|
|
222
|
-
authMethod: RegistryAuthMethod
|
|
223
|
-
/** Username for authentication */
|
|
224
|
-
username: string
|
|
225
|
-
/** Password/token for authentication */
|
|
226
|
-
password: string
|
|
227
|
-
/** Credential expiration timestamp */
|
|
228
|
-
expiresAt?: Date
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Types of compute services that can have cross-account access.
|
|
233
|
-
*/
|
|
234
|
-
export type ComputeServiceType = "worker"
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* AWS-specific cross-account access configuration.
|
|
238
|
-
*/
|
|
239
|
-
export interface AwsCrossAccountAccess {
|
|
240
|
-
/** AWS account IDs that should have access */
|
|
241
|
-
accountIds: string[]
|
|
242
|
-
/** Types of compute services that should have access */
|
|
243
|
-
allowedServiceTypes: ComputeServiceType[]
|
|
244
|
-
/** Specific IAM role ARNs to grant access to */
|
|
245
|
-
roleArns: string[]
|
|
246
|
-
/** AWS regions where target Lambda workers run (for sourceArn condition) */
|
|
247
|
-
regions: string[]
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* GCP-specific cross-account access configuration.
|
|
252
|
-
*/
|
|
253
|
-
export interface GcpCrossAccountAccess {
|
|
254
|
-
/** GCP project numbers that should have access */
|
|
255
|
-
projectNumbers: string[]
|
|
256
|
-
/** Types of compute services that should have access */
|
|
257
|
-
allowedServiceTypes: ComputeServiceType[]
|
|
258
|
-
/** Additional service account emails to grant access to */
|
|
259
|
-
serviceAccountEmails: string[]
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Cross-account access configuration (discriminated union).
|
|
264
|
-
*/
|
|
265
|
-
export type CrossAccountAccess =
|
|
266
|
-
| { type: "aws"; aws: AwsCrossAccountAccess }
|
|
267
|
-
| { type: "gcp"; gcp: GcpCrossAccountAccess }
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Current cross-account access permissions.
|
|
271
|
-
*/
|
|
272
|
-
export interface CrossAccountPermissions {
|
|
273
|
-
/** Platform-specific access configuration */
|
|
274
|
-
access: CrossAccountAccess
|
|
275
|
-
/** Timestamp when permissions were last updated (ISO8601 format) */
|
|
276
|
-
lastUpdated?: string
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// ============================================================================
|
|
280
|
-
// Worker Types
|
|
281
|
-
// ============================================================================
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Request for worker invocation.
|
|
285
|
-
*/
|
|
286
|
-
export interface WorkerInvokeRequest {
|
|
287
|
-
/** Target worker identifier */
|
|
288
|
-
targetWorker: string
|
|
289
|
-
/** HTTP method */
|
|
290
|
-
method: string
|
|
291
|
-
/** Request path */
|
|
292
|
-
path: string
|
|
293
|
-
/** Request headers */
|
|
294
|
-
headers?: Record<string, string>
|
|
295
|
-
/** Request body */
|
|
296
|
-
body?: Uint8Array
|
|
297
|
-
/** Timeout in milliseconds */
|
|
298
|
-
timeoutMs?: number
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Response from worker invocation.
|
|
303
|
-
*/
|
|
304
|
-
export interface WorkerInvokeResponse {
|
|
305
|
-
/** HTTP status code */
|
|
306
|
-
status: number
|
|
307
|
-
/** Response headers */
|
|
308
|
-
headers: Record<string, string>
|
|
309
|
-
/** Response body */
|
|
310
|
-
body: Uint8Array
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// ============================================================================
|
|
314
|
-
// Service Account Types
|
|
315
|
-
// ============================================================================
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* AWS service account information.
|
|
319
|
-
*/
|
|
320
|
-
export interface AwsServiceAccountInfo {
|
|
321
|
-
platform: "aws"
|
|
322
|
-
roleName: string
|
|
323
|
-
roleArn: string
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* GCP service account information.
|
|
328
|
-
*/
|
|
329
|
-
export interface GcpServiceAccountInfo {
|
|
330
|
-
platform: "gcp"
|
|
331
|
-
email: string
|
|
332
|
-
uniqueId: string
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Azure service account information.
|
|
337
|
-
*/
|
|
338
|
-
export interface AzureServiceAccountInfo {
|
|
339
|
-
platform: "azure"
|
|
340
|
-
clientId: string
|
|
341
|
-
resourceId: string
|
|
342
|
-
principalId: string
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Platform-specific service account information.
|
|
347
|
-
*/
|
|
348
|
-
export type ServiceAccountInfo =
|
|
349
|
-
| AwsServiceAccountInfo
|
|
350
|
-
| GcpServiceAccountInfo
|
|
351
|
-
| AzureServiceAccountInfo
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Request for service account impersonation.
|
|
355
|
-
*/
|
|
356
|
-
export interface ImpersonationRequest {
|
|
357
|
-
/** Session name for AWS */
|
|
358
|
-
sessionName?: string
|
|
359
|
-
/** Duration in seconds */
|
|
360
|
-
durationSeconds?: number
|
|
361
|
-
/** OAuth scopes for GCP */
|
|
362
|
-
scopes?: string[]
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// ============================================================================
|
|
366
|
-
// Configuration Types
|
|
367
|
-
// ============================================================================
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Configuration for connecting to the Alien bindings server.
|
|
371
|
-
*/
|
|
372
|
-
export interface AlienBindingsConfig {
|
|
373
|
-
/** gRPC server address */
|
|
374
|
-
grpcAddress?: string
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Interface for the bindings provider.
|
|
379
|
-
*/
|
|
380
|
-
export interface AlienBindingsProvider {
|
|
381
|
-
/** Get a storage binding */
|
|
382
|
-
storage(name: string): import("./bindings/storage.js").Storage
|
|
383
|
-
/** Get a KV binding */
|
|
384
|
-
kv(name: string): import("./bindings/kv.js").Kv
|
|
385
|
-
/** Get a queue binding */
|
|
386
|
-
queue(name: string): import("./bindings/queue.js").Queue
|
|
387
|
-
/** Get a vault binding */
|
|
388
|
-
vault(name: string): import("./bindings/vault.js").Vault
|
|
389
|
-
/** Get a build binding */
|
|
390
|
-
build(name: string): import("./bindings/build.js").Build
|
|
391
|
-
/** Get an artifact registry binding */
|
|
392
|
-
artifactRegistry(name: string): import("./bindings/artifact-registry.js").ArtifactRegistry
|
|
393
|
-
/** Get a worker binding */
|
|
394
|
-
worker(name: string): import("./bindings/worker.js").WorkerBinding
|
|
395
|
-
/** Get a service account binding */
|
|
396
|
-
serviceAccount(name: string): import("./bindings/service-account.js").ServiceAccount
|
|
397
|
-
}
|
package/src/wait-until.ts
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WaitUntil functionality for background task management.
|
|
3
|
-
*
|
|
4
|
-
* Allows workers to continue running after the response has been sent.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { type Channel, createClient } from "nice-grpc"
|
|
8
|
-
import { getChannel } from "./channel.js"
|
|
9
|
-
import {
|
|
10
|
-
type WaitUntilServiceClient as GeneratedClient,
|
|
11
|
-
WaitUntilServiceDefinition,
|
|
12
|
-
} from "./generated/wait_until.js"
|
|
13
|
-
import { wrapGrpcCall } from "./grpc-utils.js"
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Task tracker for managing background tasks.
|
|
17
|
-
*/
|
|
18
|
-
export interface TaskTracker {
|
|
19
|
-
/** Unique task ID */
|
|
20
|
-
id: string
|
|
21
|
-
/** Task promise */
|
|
22
|
-
promise: Promise<unknown>
|
|
23
|
-
/** When the task was registered */
|
|
24
|
-
registeredAt: Date
|
|
25
|
-
/** Whether the task has completed */
|
|
26
|
-
completed: boolean
|
|
27
|
-
/** Error if the task failed */
|
|
28
|
-
error?: Error
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Internal storage for tracked tasks
|
|
32
|
-
const tasks: Map<string, TaskTracker> = new Map()
|
|
33
|
-
let taskIdCounter = 0
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* WaitUntil manager for coordinating background tasks with the runtime.
|
|
37
|
-
*
|
|
38
|
-
* @internal
|
|
39
|
-
*/
|
|
40
|
-
export class WaitUntilManager {
|
|
41
|
-
private readonly client: GeneratedClient
|
|
42
|
-
private readonly applicationId: string
|
|
43
|
-
|
|
44
|
-
constructor(channel: Channel, applicationId: string) {
|
|
45
|
-
this.client = createClient(WaitUntilServiceDefinition, channel)
|
|
46
|
-
this.applicationId = applicationId
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Register a background task.
|
|
51
|
-
*
|
|
52
|
-
* @param promise - The promise to track
|
|
53
|
-
* @param description - Optional task description for debugging
|
|
54
|
-
* @returns Task tracker
|
|
55
|
-
*/
|
|
56
|
-
async register(promise: Promise<unknown>, description?: string): Promise<TaskTracker> {
|
|
57
|
-
const id = `task-${++taskIdCounter}`
|
|
58
|
-
const registeredAt = new Date()
|
|
59
|
-
|
|
60
|
-
const tracker: TaskTracker = {
|
|
61
|
-
id,
|
|
62
|
-
promise,
|
|
63
|
-
registeredAt,
|
|
64
|
-
completed: false,
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
tasks.set(id, tracker)
|
|
68
|
-
|
|
69
|
-
// Notify the runtime about the new task
|
|
70
|
-
await wrapGrpcCall(
|
|
71
|
-
"WaitUntilService",
|
|
72
|
-
"NotifyTaskRegistered",
|
|
73
|
-
async () => {
|
|
74
|
-
await this.client.notifyTaskRegistered({
|
|
75
|
-
applicationId: this.applicationId,
|
|
76
|
-
taskDescription: description,
|
|
77
|
-
})
|
|
78
|
-
},
|
|
79
|
-
{},
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
// Track completion
|
|
83
|
-
promise
|
|
84
|
-
.then(() => {
|
|
85
|
-
tracker.completed = true
|
|
86
|
-
})
|
|
87
|
-
.catch(error => {
|
|
88
|
-
tracker.completed = true
|
|
89
|
-
tracker.error = error instanceof Error ? error : new Error(String(error))
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
return tracker
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Wait for all background tasks to complete.
|
|
97
|
-
*
|
|
98
|
-
* Called during drain to ensure all tasks finish before shutdown.
|
|
99
|
-
*/
|
|
100
|
-
async waitForAll(): Promise<void> {
|
|
101
|
-
const pending = Array.from(tasks.values())
|
|
102
|
-
.filter(t => !t.completed)
|
|
103
|
-
.map(t => t.promise.catch(() => {}))
|
|
104
|
-
|
|
105
|
-
await Promise.all(pending)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Get the current task count.
|
|
110
|
-
*/
|
|
111
|
-
async getTaskCount(): Promise<number> {
|
|
112
|
-
return await wrapGrpcCall(
|
|
113
|
-
"WaitUntilService",
|
|
114
|
-
"GetTaskCount",
|
|
115
|
-
async () => {
|
|
116
|
-
const response = await this.client.getTaskCount({
|
|
117
|
-
applicationId: this.applicationId,
|
|
118
|
-
})
|
|
119
|
-
return response.taskCount
|
|
120
|
-
},
|
|
121
|
-
{},
|
|
122
|
-
)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Wait for a drain signal from the runtime.
|
|
127
|
-
*
|
|
128
|
-
* This blocks until the runtime signals that it's time to drain.
|
|
129
|
-
*/
|
|
130
|
-
async waitForDrainSignal(): Promise<{
|
|
131
|
-
shouldDrain: boolean
|
|
132
|
-
drainReason: string
|
|
133
|
-
}> {
|
|
134
|
-
return await wrapGrpcCall(
|
|
135
|
-
"WaitUntilService",
|
|
136
|
-
"WaitForDrainSignal",
|
|
137
|
-
async () => {
|
|
138
|
-
const response = await this.client.waitForDrainSignal({
|
|
139
|
-
applicationId: this.applicationId,
|
|
140
|
-
timeout: undefined,
|
|
141
|
-
})
|
|
142
|
-
return {
|
|
143
|
-
shouldDrain: response.shouldDrain,
|
|
144
|
-
drainReason: response.drainReason,
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
{},
|
|
148
|
-
)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Notify the runtime that drain is complete.
|
|
153
|
-
*
|
|
154
|
-
* @param tasksDrained - Number of tasks that were drained
|
|
155
|
-
* @param success - Whether all tasks completed successfully
|
|
156
|
-
* @param errorMessage - Optional error message if draining failed
|
|
157
|
-
*/
|
|
158
|
-
async notifyDrainComplete(
|
|
159
|
-
tasksDrained: number,
|
|
160
|
-
success: boolean,
|
|
161
|
-
errorMessage?: string,
|
|
162
|
-
): Promise<void> {
|
|
163
|
-
await wrapGrpcCall(
|
|
164
|
-
"WaitUntilService",
|
|
165
|
-
"NotifyDrainComplete",
|
|
166
|
-
async () => {
|
|
167
|
-
await this.client.notifyDrainComplete({
|
|
168
|
-
applicationId: this.applicationId,
|
|
169
|
-
tasksDrained,
|
|
170
|
-
success,
|
|
171
|
-
errorMessage,
|
|
172
|
-
})
|
|
173
|
-
},
|
|
174
|
-
{},
|
|
175
|
-
)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Get all tracked tasks.
|
|
180
|
-
*/
|
|
181
|
-
getTasks(): Map<string, TaskTracker> {
|
|
182
|
-
return tasks
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Clear all completed tasks.
|
|
187
|
-
*/
|
|
188
|
-
clearCompleted(): void {
|
|
189
|
-
for (const [id, tracker] of tasks) {
|
|
190
|
-
if (tracker.completed) {
|
|
191
|
-
tasks.delete(id)
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Global wait-until manager instance
|
|
198
|
-
let globalManager: WaitUntilManager | undefined
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Initialize the global wait-until manager.
|
|
202
|
-
*
|
|
203
|
-
* @internal
|
|
204
|
-
*/
|
|
205
|
-
export function initWaitUntilManager(channel: Channel, applicationId: string): WaitUntilManager {
|
|
206
|
-
globalManager = new WaitUntilManager(channel, applicationId)
|
|
207
|
-
return globalManager
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Get the global wait-until manager.
|
|
212
|
-
*
|
|
213
|
-
* @internal
|
|
214
|
-
*/
|
|
215
|
-
export function getWaitUntilManager(): WaitUntilManager | undefined {
|
|
216
|
-
return globalManager
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Register a background task to continue after the response.
|
|
221
|
-
*
|
|
222
|
-
* This allows your function to return a response while continuing
|
|
223
|
-
* to do work in the background. The runtime will wait for all
|
|
224
|
-
* registered tasks to complete before shutting down.
|
|
225
|
-
*
|
|
226
|
-
* @param promise - The promise to track
|
|
227
|
-
*
|
|
228
|
-
* @example
|
|
229
|
-
* ```typescript
|
|
230
|
-
* import { waitUntil } from "@alienplatform/sdk"
|
|
231
|
-
*
|
|
232
|
-
* export default {
|
|
233
|
-
* async fetch(request: Request): Promise<Response> {
|
|
234
|
-
* const data = await request.json()
|
|
235
|
-
*
|
|
236
|
-
* // Start background work
|
|
237
|
-
* waitUntil(sendAnalytics(data))
|
|
238
|
-
* waitUntil(updateCache(data))
|
|
239
|
-
*
|
|
240
|
-
* // Return immediately
|
|
241
|
-
* return Response.json({ status: "accepted" })
|
|
242
|
-
* }
|
|
243
|
-
* }
|
|
244
|
-
* ```
|
|
245
|
-
*/
|
|
246
|
-
export function waitUntil(promise: Promise<unknown>): void {
|
|
247
|
-
// Lazily initialize the global manager on first use. This handles
|
|
248
|
-
// HTTP-only apps (e.g. Hono) that never call ctx.run() but still
|
|
249
|
-
// need background tasks to be tracked by the runtime.
|
|
250
|
-
if (!globalManager) {
|
|
251
|
-
getChannel()
|
|
252
|
-
.then(channel => {
|
|
253
|
-
if (!globalManager) {
|
|
254
|
-
globalManager = new WaitUntilManager(channel, `app-${process.pid}`)
|
|
255
|
-
}
|
|
256
|
-
globalManager.register(promise).catch(error => {
|
|
257
|
-
console.error("Failed to register background task:", error)
|
|
258
|
-
})
|
|
259
|
-
})
|
|
260
|
-
.catch(() => {
|
|
261
|
-
// No gRPC channel available (not running in alien-runtime).
|
|
262
|
-
// Track locally as best-effort.
|
|
263
|
-
promise.catch(error => {
|
|
264
|
-
console.error("Background task failed:", error)
|
|
265
|
-
})
|
|
266
|
-
})
|
|
267
|
-
return
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
globalManager.register(promise).catch(error => {
|
|
271
|
-
console.error("Failed to register background task:", error)
|
|
272
|
-
})
|
|
273
|
-
}
|
package/tsconfig.json
DELETED
package/tsdown.config.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsdown"
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: ["src/index.ts", "src/commands/index.ts"],
|
|
5
|
-
// Use tsc for declaration files instead of tsdown's built-in dts.
|
|
6
|
-
// With two entry points that share types, tsdown's rolldown-based dts
|
|
7
|
-
// generation code-splits the .d.ts output, putting shared types into
|
|
8
|
-
// index.d.ts (as a chunk with minified names) and the actual main entry
|
|
9
|
-
// types into index2.d.ts. This breaks the package.json "types" field.
|
|
10
|
-
dts: false,
|
|
11
|
-
hash: false,
|
|
12
|
-
ignoreWatch: ".turbo",
|
|
13
|
-
// Bundle all dependencies so the package is self-contained.
|
|
14
|
-
// This allows bun build --compile to work without needing
|
|
15
|
-
// transitive dependencies installed in the user's project.
|
|
16
|
-
noExternal: [/.*/],
|
|
17
|
-
})
|
|
File without changes
|
|
File without changes
|