@alienplatform/sdk 1.14.1 → 2.0.1

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.
Files changed (160) hide show
  1. package/dist/dist.js +371 -275
  2. package/dist/index.d.ts +22 -28
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -14356
  5. package/dist/native.d.ts +26 -0
  6. package/dist/native.d.ts.map +1 -0
  7. package/dist/native.js +2 -0
  8. package/dist/worker-runtime/channel.d.ts +25 -0
  9. package/dist/worker-runtime/channel.d.ts.map +1 -0
  10. package/dist/worker-runtime/errors.d.ts +79 -0
  11. package/dist/worker-runtime/errors.d.ts.map +1 -0
  12. package/dist/worker-runtime/event-loop.d.ts +43 -0
  13. package/dist/worker-runtime/event-loop.d.ts.map +1 -0
  14. package/dist/{generated → worker-runtime/generated}/control.d.ts +15 -15
  15. package/dist/worker-runtime/generated/control.d.ts.map +1 -0
  16. package/dist/worker-runtime/generated/google/protobuf/duration.d.ts.map +1 -0
  17. package/dist/worker-runtime/generated/google/protobuf/timestamp.d.ts.map +1 -0
  18. package/dist/{generated → worker-runtime/generated}/wait_until.d.ts +29 -29
  19. package/dist/worker-runtime/generated/wait_until.d.ts.map +1 -0
  20. package/dist/worker-runtime/grpc-utils.d.ts +23 -0
  21. package/dist/worker-runtime/grpc-utils.d.ts.map +1 -0
  22. package/dist/worker-runtime/index.d.ts +33 -0
  23. package/dist/worker-runtime/index.d.ts.map +1 -0
  24. package/dist/{src.js → worker-runtime/index.js} +9370 -4035
  25. package/dist/worker-runtime/registry.d.ts +169 -0
  26. package/dist/worker-runtime/registry.d.ts.map +1 -0
  27. package/dist/worker-runtime/service-definitions.d.ts +12 -0
  28. package/dist/worker-runtime/service-definitions.d.ts.map +1 -0
  29. package/dist/worker-runtime/wait-until-manager.d.ts +34 -0
  30. package/dist/worker-runtime/wait-until-manager.d.ts.map +1 -0
  31. package/package.json +18 -38
  32. package/.turbo/turbo-build.log +0 -30
  33. package/AGENTS.md +0 -70
  34. package/dist/bearerTokenAuthenticationPolicy.js +0 -3028
  35. package/dist/bindings/artifact-registry.d.ts +0 -88
  36. package/dist/bindings/artifact-registry.d.ts.map +0 -1
  37. package/dist/bindings/build.d.ts +0 -67
  38. package/dist/bindings/build.d.ts.map +0 -1
  39. package/dist/bindings/index.d.ts +0 -13
  40. package/dist/bindings/index.d.ts.map +0 -1
  41. package/dist/bindings/kv.d.ts +0 -113
  42. package/dist/bindings/kv.d.ts.map +0 -1
  43. package/dist/bindings/postgres.d.ts +0 -90
  44. package/dist/bindings/postgres.d.ts.map +0 -1
  45. package/dist/bindings/postgres.test.d.ts +0 -2
  46. package/dist/bindings/postgres.test.d.ts.map +0 -1
  47. package/dist/bindings/queue.d.ts +0 -81
  48. package/dist/bindings/queue.d.ts.map +0 -1
  49. package/dist/bindings/service-account.d.ts +0 -46
  50. package/dist/bindings/service-account.d.ts.map +0 -1
  51. package/dist/bindings/storage.d.ts +0 -164
  52. package/dist/bindings/storage.d.ts.map +0 -1
  53. package/dist/bindings/vault.d.ts +0 -65
  54. package/dist/bindings/vault.d.ts.map +0 -1
  55. package/dist/bindings/worker.d.ts +0 -72
  56. package/dist/bindings/worker.d.ts.map +0 -1
  57. package/dist/channel.d.ts +0 -39
  58. package/dist/channel.d.ts.map +0 -1
  59. package/dist/checksum.js +0 -6176
  60. package/dist/commands/client.d.ts +0 -47
  61. package/dist/commands/client.d.ts.map +0 -1
  62. package/dist/commands/errors.d.ts +0 -198
  63. package/dist/commands/errors.d.ts.map +0 -1
  64. package/dist/commands/index.d.ts +0 -23
  65. package/dist/commands/index.d.ts.map +0 -1
  66. package/dist/commands/index.js +0 -387
  67. package/dist/commands/types.d.ts +0 -40
  68. package/dist/commands/types.d.ts.map +0 -1
  69. package/dist/commands.d.ts +0 -55
  70. package/dist/commands.d.ts.map +0 -1
  71. package/dist/context.d.ts +0 -182
  72. package/dist/context.d.ts.map +0 -1
  73. package/dist/dist-cjs.js +0 -15258
  74. package/dist/dist2.js +0 -1239
  75. package/dist/errors.d.ts +0 -359
  76. package/dist/errors.d.ts.map +0 -1
  77. package/dist/es5.js +0 -1720
  78. package/dist/esm.js +0 -18068
  79. package/dist/esm2.js +0 -3166
  80. package/dist/event-streams.js +0 -770
  81. package/dist/events.d.ts +0 -163
  82. package/dist/events.d.ts.map +0 -1
  83. package/dist/generated/artifact_registry.d.ts +0 -302
  84. package/dist/generated/artifact_registry.d.ts.map +0 -1
  85. package/dist/generated/build.d.ts +0 -184
  86. package/dist/generated/build.d.ts.map +0 -1
  87. package/dist/generated/container.d.ts +0 -101
  88. package/dist/generated/container.d.ts.map +0 -1
  89. package/dist/generated/control.d.ts.map +0 -1
  90. package/dist/generated/google/protobuf/duration.d.ts.map +0 -1
  91. package/dist/generated/google/protobuf/timestamp.d.ts.map +0 -1
  92. package/dist/generated/kv.d.ts +0 -182
  93. package/dist/generated/kv.d.ts.map +0 -1
  94. package/dist/generated/queue.d.ts +0 -127
  95. package/dist/generated/queue.d.ts.map +0 -1
  96. package/dist/generated/service_account.d.ts +0 -112
  97. package/dist/generated/service_account.d.ts.map +0 -1
  98. package/dist/generated/storage.d.ts +0 -784
  99. package/dist/generated/storage.d.ts.map +0 -1
  100. package/dist/generated/vault.d.ts +0 -107
  101. package/dist/generated/vault.d.ts.map +0 -1
  102. package/dist/generated/wait_until.d.ts.map +0 -1
  103. package/dist/generated/worker.d.ts +0 -107
  104. package/dist/generated/worker.d.ts.map +0 -1
  105. package/dist/global.d.ts +0 -208
  106. package/dist/global.d.ts.map +0 -1
  107. package/dist/grpc-utils.d.ts +0 -25
  108. package/dist/grpc-utils.d.ts.map +0 -1
  109. package/dist/jws.js +0 -611
  110. package/dist/open.js +0 -461
  111. package/dist/rolldown-runtime.js +0 -44
  112. package/dist/src2.js +0 -114032
  113. package/dist/types.d.ts +0 -337
  114. package/dist/types.d.ts.map +0 -1
  115. package/dist/wait-until.d.ts +0 -115
  116. package/dist/wait-until.d.ts.map +0 -1
  117. package/scripts/generate-proto.sh +0 -46
  118. package/src/bindings/AGENTS.md +0 -105
  119. package/src/bindings/artifact-registry.ts +0 -317
  120. package/src/bindings/build.ts +0 -195
  121. package/src/bindings/index.ts +0 -13
  122. package/src/bindings/kv.ts +0 -240
  123. package/src/bindings/postgres.test.ts +0 -17
  124. package/src/bindings/postgres.ts +0 -446
  125. package/src/bindings/queue.ts +0 -191
  126. package/src/bindings/service-account.ts +0 -113
  127. package/src/bindings/storage.ts +0 -536
  128. package/src/bindings/vault.ts +0 -133
  129. package/src/bindings/worker.ts +0 -164
  130. package/src/channel.ts +0 -102
  131. package/src/commands/client.ts +0 -446
  132. package/src/commands/errors.ts +0 -126
  133. package/src/commands/index.ts +0 -41
  134. package/src/commands/types.ts +0 -52
  135. package/src/commands.ts +0 -76
  136. package/src/context.ts +0 -368
  137. package/src/errors.ts +0 -280
  138. package/src/events.ts +0 -511
  139. package/src/generated/artifact_registry.ts +0 -2096
  140. package/src/generated/build.ts +0 -1311
  141. package/src/generated/container.ts +0 -503
  142. package/src/generated/control.ts +0 -2018
  143. package/src/generated/google/protobuf/duration.ts +0 -196
  144. package/src/generated/google/protobuf/timestamp.ts +0 -226
  145. package/src/generated/kv.ts +0 -1169
  146. package/src/generated/queue.ts +0 -753
  147. package/src/generated/service_account.ts +0 -814
  148. package/src/generated/storage.ts +0 -3820
  149. package/src/generated/vault.ts +0 -543
  150. package/src/generated/wait_until.ts +0 -829
  151. package/src/generated/worker.ts +0 -759
  152. package/src/global.ts +0 -287
  153. package/src/grpc-utils.ts +0 -159
  154. package/src/index.ts +0 -160
  155. package/src/types.ts +0 -397
  156. package/src/wait-until.ts +0 -273
  157. package/tsconfig.json +0 -8
  158. package/tsdown.config.ts +0 -17
  159. /package/dist/{generated → worker-runtime/generated}/google/protobuf/duration.d.ts +0 -0
  160. /package/dist/{generated → worker-runtime/generated}/google/protobuf/timestamp.d.ts +0 -0
package/dist/types.d.ts DELETED
@@ -1,337 +0,0 @@
1
- /**
2
- * Common types for the Alien bindings SDK.
3
- */
4
- export type { BuildStatus, ComputeType } from "@alienplatform/core";
5
- /**
6
- * Branded type for binding names.
7
- */
8
- export type BindingName = string & {
9
- readonly __brand: unique symbol;
10
- };
11
- /**
12
- * Options for storage get operations.
13
- */
14
- export interface StorageGetOptions {
15
- /** Range start offset in bytes */
16
- rangeStart?: number;
17
- /** Range end offset in bytes */
18
- rangeEnd?: number;
19
- /** If-Match header value (ETag) */
20
- ifMatch?: string;
21
- /** If-None-Match header value (ETag) */
22
- ifNoneMatch?: string;
23
- /** If-Modified-Since timestamp */
24
- ifModifiedSince?: Date;
25
- /** If-Unmodified-Since timestamp */
26
- ifUnmodifiedSince?: Date;
27
- }
28
- /**
29
- * Options for storage put operations.
30
- */
31
- export interface StoragePutOptions {
32
- /** Content type of the object */
33
- contentType?: string;
34
- /** Custom metadata */
35
- metadata?: Record<string, string>;
36
- /** Only write if the object doesn't already exist */
37
- ifNotExists?: boolean;
38
- }
39
- /**
40
- * Object metadata from storage.
41
- */
42
- export interface StorageObjectMeta {
43
- /** Full path of the object */
44
- location: string;
45
- /** Last modified timestamp */
46
- lastModified?: Date;
47
- /** Object size in bytes */
48
- size: number;
49
- /** ETag (entity tag) for the object */
50
- etag?: string;
51
- /** Object version */
52
- version?: string;
53
- }
54
- /**
55
- * Result of a storage get operation.
56
- */
57
- export interface StorageGetResult {
58
- /** Object metadata */
59
- meta: StorageObjectMeta;
60
- /** Object data as bytes */
61
- data: Uint8Array;
62
- }
63
- /**
64
- * Result of a storage list operation with delimiter.
65
- */
66
- export interface StorageListResult {
67
- /** Common prefixes (directories) */
68
- commonPrefixes: string[];
69
- /** Object metadata entries */
70
- objects: StorageObjectMeta[];
71
- }
72
- /**
73
- * Options for signed URL generation.
74
- */
75
- export interface SignedUrlOptions {
76
- /** Operation type: get (download), put (upload), or delete */
77
- operation: "get" | "put" | "delete";
78
- /** URL expiration duration in seconds */
79
- expiresInSeconds?: number;
80
- /** Content type for put operations */
81
- contentType?: string;
82
- }
83
- /**
84
- * Result of signed URL generation.
85
- */
86
- export interface SignedUrlResult {
87
- /** The signed URL */
88
- url: string;
89
- /** Headers that must be included when using the signed URL */
90
- headers?: Record<string, string>;
91
- /** URL expiration timestamp */
92
- expiresAt?: Date;
93
- }
94
- /**
95
- * Options for KV put operations.
96
- */
97
- export interface KvPutOptions {
98
- /** Time-to-live in milliseconds */
99
- ttlMs?: number;
100
- /** Only write if the key doesn't exist */
101
- ifNotExists?: boolean;
102
- }
103
- /**
104
- * Result of a KV scan operation.
105
- */
106
- export interface KvScanResult {
107
- /** Key-value pairs */
108
- items: Array<{
109
- key: string;
110
- value: Uint8Array;
111
- }>;
112
- /** Cursor for next page */
113
- nextCursor?: string;
114
- }
115
- /**
116
- * A message received from a queue via the Queue binding.
117
- * (Not to be confused with QueueMessage from @alienplatform/core which is used for event handlers)
118
- */
119
- export interface ReceivedQueueMessage<T = unknown> {
120
- /** Message payload */
121
- payload: T;
122
- /** Receipt handle for acknowledgment */
123
- receiptHandle: string;
124
- }
125
- /**
126
- * Configuration for starting a build via the Build binding.
127
- * (SDK-specific - different from BuildConfig in core which is for resource definition)
128
- */
129
- export interface BuildStartConfig {
130
- /** Build script to execute */
131
- script: string;
132
- /** Environment variables */
133
- environment?: Record<string, string>;
134
- /** Compute type */
135
- computeType?: import("@alienplatform/core").ComputeType;
136
- /** Timeout in seconds */
137
- timeoutSeconds?: number;
138
- /** Monitoring configuration */
139
- monitoring?: {
140
- endpoint: string;
141
- headers?: Record<string, string>;
142
- logsUri?: string;
143
- tlsEnabled?: boolean;
144
- tlsVerify?: boolean;
145
- };
146
- }
147
- /**
148
- * Information about a build execution.
149
- */
150
- export interface BuildExecution {
151
- /** Build execution ID */
152
- id: string;
153
- /** Current status */
154
- status: import("@alienplatform/core").BuildStatus;
155
- /** Start timestamp */
156
- startTime?: Date;
157
- /** End timestamp */
158
- endTime?: Date;
159
- }
160
- /**
161
- * Permission levels for artifact registry access.
162
- */
163
- export type ArtifactRegistryPermissions = "pull" | "push-pull";
164
- /**
165
- * Information about a repository.
166
- */
167
- export interface RepositoryInfo {
168
- /** Repository name */
169
- name: string;
170
- /** Repository URI */
171
- uri: string;
172
- /** Creation timestamp */
173
- createdAt?: Date;
174
- }
175
- /**
176
- * How the registry expects credentials to be presented.
177
- * - "basic": HTTP Basic auth (ECR, GAR, Local)
178
- * - "bearer": HTTP Bearer token (ACR)
179
- */
180
- export type RegistryAuthMethod = "basic" | "bearer";
181
- /**
182
- * Credentials for repository access.
183
- */
184
- export interface ArtifactRegistryCredentials {
185
- /** How to present these credentials to the registry */
186
- authMethod: RegistryAuthMethod;
187
- /** Username for authentication */
188
- username: string;
189
- /** Password/token for authentication */
190
- password: string;
191
- /** Credential expiration timestamp */
192
- expiresAt?: Date;
193
- }
194
- /**
195
- * Types of compute services that can have cross-account access.
196
- */
197
- export type ComputeServiceType = "worker";
198
- /**
199
- * AWS-specific cross-account access configuration.
200
- */
201
- export interface AwsCrossAccountAccess {
202
- /** AWS account IDs that should have access */
203
- accountIds: string[];
204
- /** Types of compute services that should have access */
205
- allowedServiceTypes: ComputeServiceType[];
206
- /** Specific IAM role ARNs to grant access to */
207
- roleArns: string[];
208
- /** AWS regions where target Lambda workers run (for sourceArn condition) */
209
- regions: string[];
210
- }
211
- /**
212
- * GCP-specific cross-account access configuration.
213
- */
214
- export interface GcpCrossAccountAccess {
215
- /** GCP project numbers that should have access */
216
- projectNumbers: string[];
217
- /** Types of compute services that should have access */
218
- allowedServiceTypes: ComputeServiceType[];
219
- /** Additional service account emails to grant access to */
220
- serviceAccountEmails: string[];
221
- }
222
- /**
223
- * Cross-account access configuration (discriminated union).
224
- */
225
- export type CrossAccountAccess = {
226
- type: "aws";
227
- aws: AwsCrossAccountAccess;
228
- } | {
229
- type: "gcp";
230
- gcp: GcpCrossAccountAccess;
231
- };
232
- /**
233
- * Current cross-account access permissions.
234
- */
235
- export interface CrossAccountPermissions {
236
- /** Platform-specific access configuration */
237
- access: CrossAccountAccess;
238
- /** Timestamp when permissions were last updated (ISO8601 format) */
239
- lastUpdated?: string;
240
- }
241
- /**
242
- * Request for worker invocation.
243
- */
244
- export interface WorkerInvokeRequest {
245
- /** Target worker identifier */
246
- targetWorker: string;
247
- /** HTTP method */
248
- method: string;
249
- /** Request path */
250
- path: string;
251
- /** Request headers */
252
- headers?: Record<string, string>;
253
- /** Request body */
254
- body?: Uint8Array;
255
- /** Timeout in milliseconds */
256
- timeoutMs?: number;
257
- }
258
- /**
259
- * Response from worker invocation.
260
- */
261
- export interface WorkerInvokeResponse {
262
- /** HTTP status code */
263
- status: number;
264
- /** Response headers */
265
- headers: Record<string, string>;
266
- /** Response body */
267
- body: Uint8Array;
268
- }
269
- /**
270
- * AWS service account information.
271
- */
272
- export interface AwsServiceAccountInfo {
273
- platform: "aws";
274
- roleName: string;
275
- roleArn: string;
276
- }
277
- /**
278
- * GCP service account information.
279
- */
280
- export interface GcpServiceAccountInfo {
281
- platform: "gcp";
282
- email: string;
283
- uniqueId: string;
284
- }
285
- /**
286
- * Azure service account information.
287
- */
288
- export interface AzureServiceAccountInfo {
289
- platform: "azure";
290
- clientId: string;
291
- resourceId: string;
292
- principalId: string;
293
- }
294
- /**
295
- * Platform-specific service account information.
296
- */
297
- export type ServiceAccountInfo = AwsServiceAccountInfo | GcpServiceAccountInfo | AzureServiceAccountInfo;
298
- /**
299
- * Request for service account impersonation.
300
- */
301
- export interface ImpersonationRequest {
302
- /** Session name for AWS */
303
- sessionName?: string;
304
- /** Duration in seconds */
305
- durationSeconds?: number;
306
- /** OAuth scopes for GCP */
307
- scopes?: string[];
308
- }
309
- /**
310
- * Configuration for connecting to the Alien bindings server.
311
- */
312
- export interface AlienBindingsConfig {
313
- /** gRPC server address */
314
- grpcAddress?: string;
315
- }
316
- /**
317
- * Interface for the bindings provider.
318
- */
319
- export interface AlienBindingsProvider {
320
- /** Get a storage binding */
321
- storage(name: string): import("./bindings/storage.js").Storage;
322
- /** Get a KV binding */
323
- kv(name: string): import("./bindings/kv.js").Kv;
324
- /** Get a queue binding */
325
- queue(name: string): import("./bindings/queue.js").Queue;
326
- /** Get a vault binding */
327
- vault(name: string): import("./bindings/vault.js").Vault;
328
- /** Get a build binding */
329
- build(name: string): import("./bindings/build.js").Build;
330
- /** Get an artifact registry binding */
331
- artifactRegistry(name: string): import("./bindings/artifact-registry.js").ArtifactRegistry;
332
- /** Get a worker binding */
333
- worker(name: string): import("./bindings/worker.js").WorkerBinding;
334
- /** Get a service account binding */
335
- serviceAccount(name: string): import("./bindings/service-account.js").ServiceAccount;
336
- }
337
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEnE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAA;CAAE,CAAA;AAMtE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kCAAkC;IAClC,eAAe,CAAC,EAAE,IAAI,CAAA;IACtB,oCAAoC;IACpC,iBAAiB,CAAC,EAAE,IAAI,CAAA;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,qDAAqD;IACrD,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED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IACpB,0BAA0B;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB;AAMD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,4BAA4B;IAC5B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,uBAAuB,EAAE,OAAO,CAAA;IAC9D,uBAAuB;IACvB,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,kBAAkB,EAAE,EAAE,CAAA;IAC/C,0BAA0B;IAC1B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,qBAAqB,EAAE,KAAK,CAAA;IACxD,0BAA0B;IAC1B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,qBAAqB,EAAE,KAAK,CAAA;IACxD,0BAA0B;IAC1B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,qBAAqB,EAAE,KAAK,CAAA;IACxD,uCAAuC;IACvC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,iCAAiC,EAAE,gBAAgB,CAAA;IAC1F,2BAA2B;IAC3B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,sBAAsB,EAAE,aAAa,CAAA;IAClE,oCAAoC;IACpC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,+BAA+B,EAAE,cAAc,CAAA;CACrF"}
@@ -1,115 +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
- import { type Channel } from "nice-grpc";
7
- /**
8
- * Task tracker for managing background tasks.
9
- */
10
- export interface TaskTracker {
11
- /** Unique task ID */
12
- id: string;
13
- /** Task promise */
14
- promise: Promise<unknown>;
15
- /** When the task was registered */
16
- registeredAt: Date;
17
- /** Whether the task has completed */
18
- completed: boolean;
19
- /** Error if the task failed */
20
- error?: Error;
21
- }
22
- /**
23
- * WaitUntil manager for coordinating background tasks with the runtime.
24
- *
25
- * @internal
26
- */
27
- export declare class WaitUntilManager {
28
- private readonly client;
29
- private readonly applicationId;
30
- constructor(channel: Channel, applicationId: string);
31
- /**
32
- * Register a background task.
33
- *
34
- * @param promise - The promise to track
35
- * @param description - Optional task description for debugging
36
- * @returns Task tracker
37
- */
38
- register(promise: Promise<unknown>, description?: string): Promise<TaskTracker>;
39
- /**
40
- * Wait for all background tasks to complete.
41
- *
42
- * Called during drain to ensure all tasks finish before shutdown.
43
- */
44
- waitForAll(): Promise<void>;
45
- /**
46
- * Get the current task count.
47
- */
48
- getTaskCount(): Promise<number>;
49
- /**
50
- * Wait for a drain signal from the runtime.
51
- *
52
- * This blocks until the runtime signals that it's time to drain.
53
- */
54
- waitForDrainSignal(): Promise<{
55
- shouldDrain: boolean;
56
- drainReason: string;
57
- }>;
58
- /**
59
- * Notify the runtime that drain is complete.
60
- *
61
- * @param tasksDrained - Number of tasks that were drained
62
- * @param success - Whether all tasks completed successfully
63
- * @param errorMessage - Optional error message if draining failed
64
- */
65
- notifyDrainComplete(tasksDrained: number, success: boolean, errorMessage?: string): Promise<void>;
66
- /**
67
- * Get all tracked tasks.
68
- */
69
- getTasks(): Map<string, TaskTracker>;
70
- /**
71
- * Clear all completed tasks.
72
- */
73
- clearCompleted(): void;
74
- }
75
- /**
76
- * Initialize the global wait-until manager.
77
- *
78
- * @internal
79
- */
80
- export declare function initWaitUntilManager(channel: Channel, applicationId: string): WaitUntilManager;
81
- /**
82
- * Get the global wait-until manager.
83
- *
84
- * @internal
85
- */
86
- export declare function getWaitUntilManager(): WaitUntilManager | undefined;
87
- /**
88
- * Register a background task to continue after the response.
89
- *
90
- * This allows your function to return a response while continuing
91
- * to do work in the background. The runtime will wait for all
92
- * registered tasks to complete before shutting down.
93
- *
94
- * @param promise - The promise to track
95
- *
96
- * @example
97
- * ```typescript
98
- * import { waitUntil } from "@alienplatform/sdk"
99
- *
100
- * export default {
101
- * async fetch(request: Request): Promise<Response> {
102
- * const data = await request.json()
103
- *
104
- * // Start background work
105
- * waitUntil(sendAnalytics(data))
106
- * waitUntil(updateCache(data))
107
- *
108
- * // Return immediately
109
- * return Response.json({ status: "accepted" })
110
- * }
111
- * }
112
- * ```
113
- */
114
- export declare function waitUntil(promise: Promise<unknown>): void;
115
- //# sourceMappingURL=wait-until.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wait-until.d.ts","sourceRoot":"","sources":["../src/wait-until.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAgB,MAAM,WAAW,CAAA;AAQtD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,qBAAqB;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,mBAAmB;IACnB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IACzB,mCAAmC;IACnC,YAAY,EAAE,IAAI,CAAA;IAClB,qCAAqC;IACrC,SAAS,EAAE,OAAO,CAAA;IAClB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAMD;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAQ;gBAE1B,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM;IAKnD;;;;;;OAMG;IACG,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAuCrF;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAQjC;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAcrC;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC;QAClC,WAAW,EAAE,OAAO,CAAA;QACpB,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC;IAkBF;;;;;;OAMG;IACG,mBAAmB,CACvB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,OAAO,EAChB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;IAgBhB;;OAEG;IACH,QAAQ,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC;IAIpC;;OAEG;IACH,cAAc,IAAI,IAAI;CAOvB;AAKD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,gBAAgB,CAG9F;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,GAAG,SAAS,CAElE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CA2BzD"}
@@ -1,46 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Generate TypeScript types from proto files using ts-proto + nice-grpc
4
-
5
- set -e
6
-
7
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
- PACKAGE_DIR="$(dirname "$SCRIPT_DIR")"
9
- PROTO_DIR="$PACKAGE_DIR/../../crates/alien-bindings/proto"
10
- OUT_DIR="$PACKAGE_DIR/src/generated"
11
-
12
- # Clean and create output directory
13
- rm -rf "$OUT_DIR"
14
- mkdir -p "$OUT_DIR"
15
-
16
- # Find protoc - prefer system installation
17
- if command -v protoc &> /dev/null; then
18
- PROTOC="protoc"
19
- else
20
- echo "Error: protoc not found. Install via 'brew install protobuf' on macOS."
21
- exit 1
22
- fi
23
-
24
- # Find ts-proto plugin
25
- TS_PROTO_PLUGIN="$PACKAGE_DIR/node_modules/.bin/protoc-gen-ts_proto"
26
-
27
- if [ ! -f "$TS_PROTO_PLUGIN" ]; then
28
- echo "Error: protoc-gen-ts_proto not found. Run 'pnpm install' first."
29
- exit 1
30
- fi
31
-
32
- echo "Using protoc: $PROTOC"
33
- echo "Using ts-proto plugin: $TS_PROTO_PLUGIN"
34
- echo "Generating TypeScript types from proto files..."
35
-
36
- # Generate types for all proto files
37
- # Using nice-grpc options as per the playbook
38
- "$PROTOC" \
39
- --plugin="protoc-gen-ts_proto=$TS_PROTO_PLUGIN" \
40
- --ts_proto_out="$OUT_DIR" \
41
- --ts_proto_opt=outputServices=nice-grpc,outputServices=generic-definitions,useExactTypes=false,esModuleInterop=true,importSuffix=.js \
42
- --proto_path="$PROTO_DIR" \
43
- "$PROTO_DIR"/*.proto
44
-
45
- echo "Generated TypeScript types in $OUT_DIR"
46
- echo "Done!"
@@ -1,105 +0,0 @@
1
- # Binding Implementations
2
-
3
- Each TypeScript binding must match its Rust counterpart in `alien-bindings/src/providers/<name>/grpc.rs`.
4
-
5
- **Examples:**
6
- - `kv.ts` → `providers/kv/grpc.rs`
7
- - `storage.ts` → `providers/storage/grpc.rs`
8
- - `build.ts` → `providers/build/grpc.rs`
9
-
10
- ## Core Pattern: Public API → gRPC → Public API
11
-
12
- ```
13
- ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
14
- │ Public API │ → │ gRPC Proto │ → │ Public API │
15
- │ (SDK types) │ │ (wire format) │ │ (SDK types) │
16
- └─────────────────┘ └─────────────────┘ └─────────────────┘
17
- User calls Internal only User receives
18
- ```
19
-
20
- **Public API types** come from `@alienplatform/core` or `../types.ts`. Proto types are **internal only** - never exposed to users.
21
-
22
- ```typescript
23
- // ❌ Bad - exposing proto types
24
- async getStatus(buildId: string): Promise<BuildExecutionProto>
25
-
26
- // ✅ Good - convert proto to public types
27
- async getStatus(buildId: string): Promise<BuildExecution> {
28
- const response = await this.client.getBuildStatus({ ... })
29
- return this.fromProtoExecution(response.execution!) // Transform here
30
- }
31
- ```
32
-
33
- ## Guidelines
34
-
35
- ### 1. Match All Rust Trait Methods
36
- Every method in the Rust trait must have a TypeScript equivalent. Check for missing methods when adding bindings.
37
-
38
- ### 2. Match Rust Enum Fallbacks Exactly
39
- Rust often maps unknown/unspecified enum values to a specific fallback. TypeScript must match:
40
-
41
- ```rust
42
- // Rust: maps Unspecified → Failed
43
- BuildStatus::Unspecified => BuildStatus::Failed,
44
- ```
45
- ```typescript
46
- // TypeScript: must match
47
- [BuildStatusProto.BUILD_STATUS_UNSPECIFIED]: "FAILED", // NOT "QUEUED"
48
- ```
49
-
50
- ### 3. Transform Types in Private Helpers
51
- Keep transformations consistent and testable:
52
-
53
- ```typescript
54
- private fromProtoExecution(proto: BuildExecutionProto): BuildExecution {
55
- return {
56
- id: proto.id,
57
- status: statusMap[proto.status] ?? "FAILED",
58
- startTime: proto.startTime ? new Date(proto.startTime) : undefined,
59
- }
60
- }
61
-
62
- private toProtoConfig(config: BuildStartConfig): BuildConfigProto {
63
- return {
64
- script: config.script,
65
- computeType: computeTypeMap[config.computeType] ?? ComputeType.UNSPECIFIED,
66
- }
67
- }
68
- ```
69
-
70
- ### 4. Convert Units Consistently
71
- Rust uses `Duration`, TypeScript uses milliseconds:
72
-
73
- ```typescript
74
- ttlSeconds: options.ttlMs ? Math.floor(options.ttlMs / 1000) : undefined
75
- timeoutSeconds: request.timeoutMs ? Math.floor(request.timeoutMs / 1000) : undefined
76
- ```
77
-
78
- ### 5. Use wrapGrpcCall for Error Handling
79
- Always wrap gRPC calls with context for proper error mapping:
80
-
81
- ```typescript
82
- return await wrapGrpcCall(
83
- "BuildService",
84
- "GetBuildStatus",
85
- async () => { ... },
86
- { bindingName: this.bindingName }, // Context for error mapping
87
- )
88
- ```
89
-
90
- ### 6. Handle Optional Proto Fields
91
- Rust `Option<T>` becomes `T | undefined`. Use nullish coalescing:
92
-
93
- ```typescript
94
- uri: proto.uri ?? "",
95
- createdAt: proto.createdAt ? new Date(proto.createdAt) : undefined,
96
- ```
97
-
98
- ## Convenience Methods
99
-
100
- TypeScript may add convenience methods not in Rust (e.g., `getJson()`, `exists()`, `waitForCompletion()`). These are fine if they build on core methods.
101
-
102
- ## See Also
103
-
104
- - Parent: `packages/bindings/AGENTS.md` - Package overview and type architecture
105
- - Proto definitions: `crates/alien-bindings/proto/`