@alienplatform/testing 1.4.2 → 1.7.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/errors.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { AlienError, defineError } from "@alienplatform/core";
2
- import * as z from "zod/v4";
2
+ import * as z$1 from "zod/v4";
3
3
  //#region src/errors.ts
4
4
  const TestingOperationFailedError = defineError({
5
5
  code: "TESTING_OPERATION_FAILED",
6
- context: z.object({
7
- operation: z.string(),
8
- message: z.string(),
9
- details: z.record(z.string(), z.unknown()).optional()
6
+ context: z$1.object({
7
+ operation: z$1.string(),
8
+ message: z$1.string(),
9
+ details: z$1.record(z$1.string(), z$1.unknown()).optional()
10
10
  }),
11
11
  message: ({ operation, message }) => `Testing operation '${operation}' failed: ${message}`,
12
12
  retryable: false,
@@ -15,9 +15,9 @@ const TestingOperationFailedError = defineError({
15
15
  });
16
16
  const TestingUnsupportedPlatformError = defineError({
17
17
  code: "TESTING_UNSUPPORTED_PLATFORM",
18
- context: z.object({
19
- platform: z.string(),
20
- operation: z.string()
18
+ context: z$1.object({
19
+ platform: z$1.string(),
20
+ operation: z$1.string()
21
21
  }),
22
22
  message: ({ platform, operation }) => `Unsupported platform '${platform}' for testing operation '${operation}'`,
23
23
  retryable: false,
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { AlienError, defineError } from \"@alienplatform/core\"\nimport * as z from \"zod/v4\"\n\nexport const TestingOperationFailedError = defineError({\n code: \"TESTING_OPERATION_FAILED\",\n context: z.object({\n operation: z.string(),\n message: z.string(),\n details: z.record(z.string(), z.unknown()).optional(),\n }),\n message: ({ operation, message }) => `Testing operation '${operation}' failed: ${message}`,\n retryable: false,\n internal: false,\n httpStatusCode: 500,\n})\n\nexport const TestingUnsupportedPlatformError = defineError({\n code: \"TESTING_UNSUPPORTED_PLATFORM\",\n context: z.object({\n platform: z.string(),\n operation: z.string(),\n }),\n message: ({ platform, operation }) =>\n `Unsupported platform '${platform}' for testing operation '${operation}'`,\n retryable: false,\n internal: false,\n httpStatusCode: 400,\n})\n\nexport async function withTestingContext(\n error: unknown,\n operation: string,\n message: string,\n details?: Record<string, unknown>,\n): Promise<AlienError<any>> {\n return (await AlienError.from(error)).withContext(\n TestingOperationFailedError.create({\n operation,\n message,\n details,\n }),\n )\n}\n"],"mappings":";;;AAGA,MAAa,8BAA8B,YAAY;CACrD,MAAM;CACN,SAAS,EAAE,OAAO;EAChB,WAAW,EAAE,OAAO;EACpB,SAAS,EAAE,OAAO;EAClB,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,EAAE,SAAS;CACtD,CAAC;CACD,UAAU,EAAE,WAAW,cAAc,sBAAsB,UAAU,YAAY;CACjF,WAAW;CACX,UAAU;CACV,gBAAgB;AAClB,CAAC;AAED,MAAa,kCAAkC,YAAY;CACzD,MAAM;CACN,SAAS,EAAE,OAAO;EAChB,UAAU,EAAE,OAAO;EACnB,WAAW,EAAE,OAAO;CACtB,CAAC;CACD,UAAU,EAAE,UAAU,gBACpB,yBAAyB,SAAS,2BAA2B,UAAU;CACzE,WAAW;CACX,UAAU;CACV,gBAAgB;AAClB,CAAC;AAED,eAAsB,mBACpB,OACA,WACA,SACA,SAC0B;CAC1B,QAAQ,MAAM,WAAW,KAAK,KAAK,GAAG,YACpC,4BAA4B,OAAO;EACjC;EACA;EACA;CACF,CAAC,CACH;AACF"}
1
+ {"version":3,"file":"errors.js","names":["z"],"sources":["../src/errors.ts"],"sourcesContent":["import { AlienError, defineError } from \"@alienplatform/core\"\nimport * as z from \"zod/v4\"\n\nexport const TestingOperationFailedError = defineError({\n code: \"TESTING_OPERATION_FAILED\",\n context: z.object({\n operation: z.string(),\n message: z.string(),\n details: z.record(z.string(), z.unknown()).optional(),\n }),\n message: ({ operation, message }) => `Testing operation '${operation}' failed: ${message}`,\n retryable: false,\n internal: false,\n httpStatusCode: 500,\n})\n\nexport const TestingUnsupportedPlatformError = defineError({\n code: \"TESTING_UNSUPPORTED_PLATFORM\",\n context: z.object({\n platform: z.string(),\n operation: z.string(),\n }),\n message: ({ platform, operation }) =>\n `Unsupported platform '${platform}' for testing operation '${operation}'`,\n retryable: false,\n internal: false,\n httpStatusCode: 400,\n})\n\nexport async function withTestingContext(\n error: unknown,\n operation: string,\n message: string,\n details?: Record<string, unknown>,\n): Promise<AlienError<any>> {\n return (await AlienError.from(error)).withContext(\n TestingOperationFailedError.create({\n operation,\n message,\n details,\n }),\n )\n}\n"],"mappings":";;;AAGA,MAAa,8BAA8B,YAAY;CACrD,MAAM;CACN,SAASA,IAAE,OAAO;EAChB,WAAWA,IAAE,OAAO;EACpB,SAASA,IAAE,OAAO;EAClB,SAASA,IAAE,OAAOA,IAAE,OAAO,GAAGA,IAAE,QAAQ,CAAC,EAAE,SAAS;CACtD,CAAC;CACD,UAAU,EAAE,WAAW,cAAc,sBAAsB,UAAU,YAAY;CACjF,WAAW;CACX,UAAU;CACV,gBAAgB;AAClB,CAAC;AAED,MAAa,kCAAkC,YAAY;CACzD,MAAM;CACN,SAASA,IAAE,OAAO;EAChB,UAAUA,IAAE,OAAO;EACnB,WAAWA,IAAE,OAAO;CACtB,CAAC;CACD,UAAU,EAAE,UAAU,gBACpB,yBAAyB,SAAS,2BAA2B,UAAU;CACzE,WAAW;CACX,UAAU;CACV,gBAAgB;AAClB,CAAC;AAED,eAAsB,mBACpB,OACA,WACA,SACA,SAC0B;CAC1B,QAAQ,MAAM,WAAW,KAAK,KAAK,GAAG,YACpC,4BAA4B,OAAO;EACjC;EACA;EACA;CACF,CAAC,CACH;AACF"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as node_child_process0 from "node:child_process";
2
- import * as _alienplatform_core0 from "@alienplatform/core";
3
- import { AlienError } from "@alienplatform/core";
4
- import * as z from "zod/v4";
2
+ import * as z$1 from "zod/v4";
3
+ import { z } from "zod/v4";
4
+ import * as z$2 from "zod";
5
5
 
6
6
  //#region src/types.d.ts
7
7
 
@@ -66,7 +66,8 @@ interface DeploymentInfo {
66
66
  interface DeploymentInit {
67
67
  id: string;
68
68
  name: string;
69
- url: string;
69
+ /** Public URL of the app, when the stack has a resource that exposes one. */
70
+ url?: string;
70
71
  platform: Platform;
71
72
  commandsUrl: string;
72
73
  appPath: string;
@@ -79,7 +80,8 @@ interface DeploymentInit {
79
80
  declare class Deployment {
80
81
  readonly id: string;
81
82
  readonly name: string;
82
- readonly url: string;
83
+ /** Public URL of the app. Undefined for stacks with no URL-exposing resource (e.g. daemon-only). */
84
+ readonly url: string | undefined;
83
85
  readonly platform: Platform;
84
86
  /** Whether the deployment has been destroyed */
85
87
  destroyed: boolean;
@@ -121,44 +123,193 @@ declare class Deployment {
121
123
  */
122
124
  declare function deploy(options: DeployOptions): Promise<Deployment>;
123
125
  //#endregion
126
+ //#region ../core/dist/index.d.ts
127
+
128
+ //#endregion
129
+ //#region src/generated/zod/alien-error-schema.d.ts
130
+ /**
131
+ * @description Canonical error container that provides a structured way to represent errors\nwith rich metadata including error codes, human-readable messages, context,\nand chaining capabilities for error propagation.\n\nThis struct is designed to be both machine-readable and user-friendly,\nsupporting serialization for API responses and detailed error reporting\nin distributed systems.
132
+ */
133
+ declare const AlienErrorSchema: z$2.ZodObject<{
134
+ code: z$2.ZodString;
135
+ context: z$2.ZodOptional<z$2.ZodAny>;
136
+ hint: z$2.ZodOptional<z$2.ZodNullable<z$2.ZodString>>;
137
+ httpStatusCode: z$2.ZodOptional<z$2.ZodNullable<z$2.ZodInt>>;
138
+ internal: z$2.ZodBoolean;
139
+ message: z$2.ZodString;
140
+ retryable: z$2.ZodDefault<z$2.ZodBoolean>;
141
+ source: z$2.ZodOptional<z$2.ZodAny>;
142
+ }, z$2.core.$strip>;
143
+ type AlienError$1 = z$2.infer<typeof AlienErrorSchema>;
144
+ //#endregion
145
+ //#region src/generated/zod/alien-event-schema.d.ts
146
+ /**
147
+ * @description Represents all possible events in the Alien system
148
+ */
149
+
150
+ //#endregion
151
+ //#region src/error.d.ts
152
+ /**
153
+ * Base interface that all error type definitions must implement.
154
+ *
155
+ * This provides the structure for creating type-safe error definitions
156
+ * with Zod validation and contextual information.
157
+ *
158
+ * @template TContext - Zod schema type for the error context
159
+ */
160
+ interface AlienErrorMetadata<TContext extends z.ZodTypeAny> {
161
+ /** Unique error code (e.g., "DATABASE_CONNECTION_FAILED") */
162
+ code: string;
163
+ /** Zod schema for type-safe context validation */
164
+ context: TContext;
165
+ /** Whether this error can be retried */
166
+ retryable: boolean;
167
+ /** Whether this error contains sensitive information */
168
+ internal: boolean;
169
+ /** HTTP status code for API responses */
170
+ httpStatusCode?: number;
171
+ /** Worker to generate human-readable error message from context */
172
+ message: (context: z.infer<TContext>) => string;
173
+ }
174
+ /**
175
+ * Helper function to create type-safe error definitions.
176
+ *
177
+ * This function provides a clean API for defining reusable error types
178
+ * with full TypeScript type safety and Zod validation.
179
+ *
180
+ * @template TContext - Zod schema type for the error context
181
+ * @param metadata - Error metadata including code, schema, and message generator
182
+ * @returns Object with metadata and a create function for error instances
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * const UserNotFound = defineError({
187
+ * code: "USER_NOT_FOUND",
188
+ * context: z.object({
189
+ * userId: z.string(),
190
+ * searchMethod: z.string(),
191
+ * }),
192
+ * message: ({ userId, searchMethod }) =>
193
+ * `User '${userId}' not found using method '${searchMethod}'`,
194
+ * retryable: false,
195
+ * internal: false,
196
+ * httpStatusCode: 404,
197
+ * })
198
+ *
199
+ * // Usage
200
+ * const error = UserNotFound.create({
201
+ * userId: "123",
202
+ * searchMethod: "database_lookup"
203
+ * })
204
+ * ```
205
+ */
206
+
207
+ /**
208
+ * Represents a specific error instance with its context.
209
+ *
210
+ * This is created by calling `.create()` on an error definition
211
+ * and contains the actual context data for a specific error occurrence.
212
+ *
213
+ * @template TContext - Zod schema type for the error context
214
+ */
215
+ interface AlienErrorDefinition<TContext extends z.ZodTypeAny> {
216
+ metadata: AlienErrorMetadata<TContext>;
217
+ contextSchema: TContext;
218
+ context: z.infer<TContext>;
219
+ /**
220
+ * Convert this error definition directly to AlienErrorOptions.
221
+ *
222
+ * This allows you to get the wire format representation
223
+ * without creating an AlienError instance first.
224
+ *
225
+ * @returns AlienErrorOptions object representing this error
226
+ */
227
+ toOptions(): AlienError$1;
228
+ }
229
+ /**
230
+ * Main AlienError class that provides structured error handling.
231
+ *
232
+ * This class extends the standard JavaScript Error with additional features:
233
+ * - Type-safe context data
234
+ * - Error chaining and source tracking
235
+ * - Retryability and internal/external visibility flags
236
+ * - HTTP status code mapping
237
+ * - Sanitization for external APIs
238
+ *
239
+ * @template TContext - Zod schema type for the error context
240
+ *
241
+ * @example Basic Construction
242
+ * ```typescript
243
+ * const error = new AlienError(DatabaseError.create({
244
+ * host: "localhost",
245
+ * port: 5432,
246
+ * reason: "Timeout"
247
+ * }))
248
+ * ```
249
+ *
250
+ * @example Converting JavaScript Errors
251
+ * ```typescript
252
+ * try {
253
+ * JSON.parse("invalid json")
254
+ * } catch (jsError) {
255
+ * const alienError = AlienError.from(jsError)
256
+ * console.log(alienError.code) // "GENERIC_ERROR"
257
+ * }
258
+ * ```
259
+ *
260
+ * @example Error Chaining
261
+ * ```typescript
262
+ * const contextualError = AlienError.from(new Error("Network timeout"))
263
+ * .withContext(DatabaseError.create({
264
+ * host: "localhost",
265
+ * port: 5432,
266
+ * reason: "Connection timeout"
267
+ * }))
268
+ *
269
+ * // Check error chain
270
+ * console.log(contextualError.hasErrorCode("DATABASE_CONNECTION_FAILED")) // true
271
+ * console.log(contextualError.toString()) // Shows full error chain
272
+ * ```
273
+ */
274
+ //#endregion
124
275
  //#region src/errors.d.ts
125
276
  declare const TestingOperationFailedError: {
126
- metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
127
- operation: z.ZodString;
128
- message: z.ZodString;
129
- details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
130
- }, z.core.$strip>>;
131
- contextSchema: z.ZodObject<{
132
- operation: z.ZodString;
133
- message: z.ZodString;
134
- details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
135
- }, z.core.$strip>;
277
+ metadata: AlienErrorMetadata<z$1.ZodObject<{
278
+ operation: z$1.ZodString;
279
+ message: z$1.ZodString;
280
+ details: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
281
+ }, z$1.core.$strip>>;
282
+ contextSchema: z$1.ZodObject<{
283
+ operation: z$1.ZodString;
284
+ message: z$1.ZodString;
285
+ details: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
286
+ }, z$1.core.$strip>;
136
287
  create: (context: {
137
288
  operation: string;
138
289
  message: string;
139
290
  details?: Record<string, unknown> | undefined;
140
- }) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
141
- operation: z.ZodString;
142
- message: z.ZodString;
143
- details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
144
- }, z.core.$strip>>;
291
+ }) => AlienErrorDefinition<z$1.ZodObject<{
292
+ operation: z$1.ZodString;
293
+ message: z$1.ZodString;
294
+ details: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
295
+ }, z$1.core.$strip>>;
145
296
  };
146
297
  declare const TestingUnsupportedPlatformError: {
147
- metadata: _alienplatform_core0.AlienErrorMetadata<z.ZodObject<{
148
- platform: z.ZodString;
149
- operation: z.ZodString;
150
- }, z.core.$strip>>;
151
- contextSchema: z.ZodObject<{
152
- platform: z.ZodString;
153
- operation: z.ZodString;
154
- }, z.core.$strip>;
298
+ metadata: AlienErrorMetadata<z$1.ZodObject<{
299
+ platform: z$1.ZodString;
300
+ operation: z$1.ZodString;
301
+ }, z$1.core.$strip>>;
302
+ contextSchema: z$1.ZodObject<{
303
+ platform: z$1.ZodString;
304
+ operation: z$1.ZodString;
305
+ }, z$1.core.$strip>;
155
306
  create: (context: {
156
307
  platform: string;
157
308
  operation: string;
158
- }) => _alienplatform_core0.AlienErrorDefinition<z.ZodObject<{
159
- platform: z.ZodString;
160
- operation: z.ZodString;
161
- }, z.core.$strip>>;
309
+ }) => AlienErrorDefinition<z$1.ZodObject<{
310
+ platform: z$1.ZodString;
311
+ operation: z$1.ZodString;
312
+ }, z$1.core.$strip>>;
162
313
  };
163
314
  //#endregion
164
315
  export { type DeployOptions, Deployment, type DeploymentInfo, type EnvironmentVariable, type Platform, TestingOperationFailedError, TestingUnsupportedPlatformError, type UpgradeOptions, deploy };