|
1 | 1 | { |
2 | 2 | "name": "builder", |
3 | 3 | "specifier": "@probitas/builder", |
4 | | - "version": "0.3.1", |
| 4 | + "version": "0.3.2", |
5 | 5 | "moduleDoc": "Builder module for creating scenario definitions with a fluent, type-safe API.\n\nThis package provides the {@linkcode scenario} fn function that returns a builder\nfor constructing scenario definitions. The builder uses method chaining to define\nresources, setup functions, and test steps with full TypeScript type inference.\n\n## Links\n\n- [GitHub Repository](https://github.com/jsr-probitas/probitas)\n- [@probitas/probitas](https://jsr.io/@probitas/probitas) - Main package (recommended for most users)\n\n## Related Packages\n\n| Package | Description |\n|---------|-------------|\n| [@probitas/core](https://jsr.io/@probitas/core) | Core type definitions used by this builder |\n| [@probitas/runner](https://jsr.io/@probitas/runner) | Executes scenarios built with this package |\n\n## Key Features\n\n- **Fluent API**: Chain methods naturally to build complex scenarios\n- **Type-safe context**: Each step receives typed access to previous step results\n- **Resource management**: Register resources with automatic lifecycle handling\n- **Setup/Cleanup**: Define setup functions with automatic cleanup support\n- **Configurable defaults**: Override timeout and retry settings at any level\n\n## Core Exports\n\n- {@linkcode scenario} - Factory function to create a new scenario builder\n- {@linkcode StepContext} - Type representing the context passed to step functions\n- {@linkcode StepFunction} - Type signature for step functions\n- {@linkcode SetupFunction} - Type signature for setup functions\n- {@linkcode ResourceFunction} - Type signature for resource fn functions\n- {@linkcode BuilderScenarioOptions} - Partial options for scenario configuration\n- {@linkcode BuilderStepOptions} - Partial options for step configuration\n- {@linkcode DEFAULT_SCENARIO_OPTIONS} - Default values for scenario options\n- {@linkcode DEFAULT_STEP_OPTIONS} - Default values for step options\n", |
6 | 6 | "exports": [ |
7 | 7 | { |
8 | 8 | "name": "scenario", |
9 | 9 | "isDefault": false, |
10 | 10 | "location": { |
11 | | - "filename": "https://jsr.io/@probitas/builder/0.3.1/scenario_builder.ts", |
12 | | - "line": 571, |
| 11 | + "filename": "https://jsr.io/@probitas/builder/0.3.2/scenario_builder.ts", |
| 12 | + "line": 644, |
13 | 13 | "col": 0, |
14 | | - "byteIndex": 18358 |
| 14 | + "byteIndex": 20517 |
15 | 15 | }, |
16 | 16 | "declarationKind": "export", |
17 | 17 | "jsDoc": { |
|
37 | 37 | }, |
38 | 38 | { |
39 | 39 | "kind": "example", |
40 | | - "doc": "Basic scenario with type-safe step chaining\n```ts\nimport { scenario } from \"@probitas/builder\";\n\nexport default scenario(\"User Registration\")\n .step(\"Create user\", async () => {\n const user = await createUser({ email: \"test@example.com\" });\n return { userId: user.id };\n })\n .step(\"Verify email\", async (ctx) => {\n // ctx.previous is typed as { userId: string }\n await verifyEmail(ctx.previous.userId);\n })\n .build();\n```\n" |
| 40 | + "doc": "Basic scenario with type-safe step chaining\n```ts\nimport { scenario } from \"@probitas/builder\";\n\n// Mock user service for example\nconst createUser = (_data: { email: string }) =>\n Promise.resolve({ id: \"user-123\" });\nconst verifyEmail = (_userId: string) => Promise.resolve();\n\nexport default scenario(\"User Registration\")\n .step(\"Create user\", async () => {\n const user = await createUser({ email: \"test@example.com\" });\n return { userId: user.id };\n })\n .step(\"Verify email\", async (ctx) => {\n // ctx.previous is typed as { userId: string }\n await verifyEmail(ctx.previous.userId);\n })\n .build();\n```\n" |
41 | 41 | }, |
42 | 42 | { |
43 | 43 | "kind": "example", |
44 | | - "doc": "Scenario with tags for filtering\n```ts\nscenario(\"Payment Integration\", {\n tags: [\"integration\", \"payment\", \"slow\"],\n stepOptions: { timeout: 60000 } // 1 minute timeout for all steps\n})\n .step(\"Process payment\", async () => { ... })\n .build();\n\n// Run with: probitas run -s \"tag:payment\"\n```\n" |
| 44 | + "doc": "Scenario with tags for filtering\n```ts\nimport { scenario } from \"@probitas/builder\";\n\nscenario(\"Payment Integration\", {\n tags: [\"integration\", \"payment\", \"slow\"],\n stepOptions: { timeout: 60000 } // 1 minute timeout for all steps\n})\n .step(\"Process payment\", async () => {\n return { success: true };\n })\n .build();\n\n// Run with: probitas run -s \"tag:payment\"\n```\n" |
45 | 45 | }, |
46 | 46 | { |
47 | 47 | "kind": "example", |
48 | | - "doc": "Scenario with resources and setup\n```ts\nscenario(\"Database Test\")\n .resource(\"db\", async () => await Database.connect())\n .setup((ctx) => {\n // Run migrations\n return () => ctx.resources.db.rollback();\n })\n .step(\"Insert data\", (ctx) => ctx.resources.db.insert(...))\n .step(\"Query data\", (ctx) => ctx.resources.db.query(...))\n .build();\n```\n" |
| 48 | + "doc": "Scenario with resources and setup\n```ts\nimport { scenario } from \"@probitas/builder\";\n\n// Mock Database for example\nconst Database = {\n connect: () =>\n Promise.resolve({\n rollback: () => {},\n insert: (_data: { id: number }) => {},\n query: (_sql: string) => [{ id: 1 }],\n }),\n};\n\nscenario(\"Database Test\")\n .resource(\"db\", async () => await Database.connect())\n .setup((ctx) => {\n // Run migrations\n return () => ctx.resources.db.rollback();\n })\n .step(\"Insert data\", (ctx) => ctx.resources.db.insert({ id: 1 }))\n .step(\"Query data\", (ctx) => ctx.resources.db.query(\"SELECT * FROM users\"))\n .build();\n```\n" |
49 | 49 | }, |
50 | 50 | { |
51 | 51 | "kind": "see", |
|
102 | 102 | "name": "BuilderStepContext", |
103 | 103 | "isDefault": false, |
104 | 104 | "location": { |
105 | | - "filename": "https://jsr.io/@probitas/builder/0.3.1/types.ts", |
106 | | - "line": 40, |
| 105 | + "filename": "https://jsr.io/@probitas/builder/0.3.2/types.ts", |
| 106 | + "line": 44, |
107 | 107 | "col": 0, |
108 | | - "byteIndex": 1233 |
| 108 | + "byteIndex": 1337 |
109 | 109 | }, |
110 | 110 | "declarationKind": "export", |
111 | 111 | "jsDoc": { |
|
128 | 128 | }, |
129 | 129 | { |
130 | 130 | "kind": "example", |
131 | | - "doc": "Accessing previous result\n```ts\nscenario(\"Chained Steps\")\n .step(\"First\", () => ({ id: 123 }))\n .step(\"Second\", (ctx) => {\n console.log(ctx.previous.id); // 123 (typed as number)\n })\n .build();\n```\n" |
| 131 | + "doc": "Accessing previous result\n```ts\nimport { scenario } from \"@probitas/builder\";\n\nscenario(\"Chained Steps\")\n .step(\"First\", () => ({ id: 123 }))\n .step(\"Second\", (ctx) => {\n console.log(ctx.previous.id); // 123 (typed as number)\n })\n .build();\n```\n" |
132 | 132 | }, |
133 | 133 | { |
134 | 134 | "kind": "example", |
135 | | - "doc": "Using shared store\n```ts\nscenario(\"Store Example\")\n .setup((ctx) => {\n ctx.store.set(\"startTime\", Date.now());\n })\n .step(\"Check duration\", (ctx) => {\n const start = ctx.store.get(\"startTime\") as number;\n console.log(`Elapsed: ${Date.now() - start}ms`);\n })\n .build();\n```" |
| 135 | + "doc": "Using shared store\n```ts\nimport { scenario } from \"@probitas/builder\";\n\nscenario(\"Store Example\")\n .setup((ctx) => {\n ctx.store.set(\"startTime\", Date.now());\n })\n .step(\"Check duration\", (ctx) => {\n const start = ctx.store.get(\"startTime\") as number;\n console.log(`Elapsed: ${Date.now() - start}ms`);\n })\n .build();\n```" |
136 | 136 | } |
137 | 137 | ] |
138 | 138 | }, |
|
163 | 163 | "doc": "Result from the previous step.\n\nFully typed based on what the previous step returned.\nFor the first step, this is `unknown`." |
164 | 164 | }, |
165 | 165 | "location": { |
166 | | - "filename": "https://jsr.io/@probitas/builder/0.3.1/types.ts", |
167 | | - "line": 51, |
| 166 | + "filename": "https://jsr.io/@probitas/builder/0.3.2/types.ts", |
| 167 | + "line": 55, |
168 | 168 | "col": 2, |
169 | | - "byteIndex": 1574 |
| 169 | + "byteIndex": 1678 |
170 | 170 | }, |
171 | 171 | "params": [], |
172 | 172 | "readonly": true, |
|
185 | 185 | { |
186 | 186 | "name": "results", |
187 | 187 | "jsDoc": { |
188 | | - "doc": "All accumulated results as a typed tuple.\n\nAllows accessing any previous result by index:\n```ts\nctx.results[0] // First step's result\nctx.results[1] // Second step's result\n```" |
| 188 | + "doc": "All accumulated results as a typed tuple.\n\nAllows accessing any previous result by index:\n- `ctx.results[0]` - First step's result\n- `ctx.results[1]` - Second step's result" |
189 | 189 | }, |
190 | 190 | "location": { |
191 | | - "filename": "https://jsr.io/@probitas/builder/0.3.1/types.ts", |
192 | | - "line": 62, |
| 191 | + "filename": "https://jsr.io/@probitas/builder/0.3.2/types.ts", |
| 192 | + "line": 64, |
193 | 193 | "col": 2, |
194 | | - "byteIndex": 1824 |
| 194 | + "byteIndex": 1912 |
195 | 195 | }, |
196 | 196 | "params": [], |
197 | 197 | "readonly": true, |
|
210 | 210 | { |
211 | 211 | "name": "resources", |
212 | 212 | "jsDoc": { |
213 | | - "doc": "Named resources registered with `.resource()`.\n\nResources are typed based on their registration:\n```ts\n.resource(\"db\", () => createDbConnection())\n.step((ctx) => ctx.resources.db.query(...))\n```" |
| 213 | + "doc": "Named resources registered with `.resource()`.\n\nResources are typed based on their registration:\n```ts\nimport { scenario } from \"@probitas/builder\";\n\n// Mock database connection for example\nconst createDbConnection = () => ({ query: (_sql: string) => [{ id: 1 }] });\n\nscenario(\"test\")\n .resource(\"db\", () => createDbConnection())\n .step((ctx) => ctx.resources.db.query(\"SELECT 1\"))\n .build();\n```" |
214 | 214 | }, |
215 | 215 | "location": { |
216 | | - "filename": "https://jsr.io/@probitas/builder/0.3.1/types.ts", |
217 | | - "line": 73, |
| 216 | + "filename": "https://jsr.io/@probitas/builder/0.3.2/types.ts", |
| 217 | + "line": 82, |
218 | 218 | "col": 2, |
219 | | - "byteIndex": 2089 |
| 219 | + "byteIndex": 2415 |
220 | 220 | }, |
221 | 221 | "params": [], |
222 | 222 | "readonly": true, |
|
331 | 331 | "name": "BuilderStepFunction", |
332 | 332 | "isDefault": false, |
333 | 333 | "location": { |
334 | | - "filename": "https://jsr.io/@probitas/builder/0.3.1/types.ts", |
335 | | - "line": 102, |
| 334 | + "filename": "https://jsr.io/@probitas/builder/0.3.2/types.ts", |
| 335 | + "line": 117, |
336 | 336 | "col": 0, |
337 | | - "byteIndex": 2903 |
| 337 | + "byteIndex": 3428 |
338 | 338 | }, |
339 | 339 | "declarationKind": "export", |
340 | 340 | "jsDoc": { |
|
362 | 362 | }, |
363 | 363 | { |
364 | 364 | "kind": "example", |
365 | | - "doc": "Sync step returning data\n```ts\nconst step: StepFunction<{ name: string }> = (ctx) => {\n return { name: \"Alice\" };\n};\n```\n" |
| 365 | + "doc": "Sync step returning data\n```ts\nimport type { BuilderStepFunction } from \"@probitas/builder\";\n\nconst step: BuilderStepFunction<{ name: string }> = (_ctx) => {\n return { name: \"Alice\" };\n};\n```\n" |
366 | 366 | }, |
367 | 367 | { |
368 | 368 | "kind": "example", |
369 | | - "doc": "Async step with API call\n```ts\nconst step: StepFunction<User> = async (ctx) => {\n const response = await fetch(\"/api/user\", { signal: ctx.signal });\n return response.json();\n};\n```" |
| 369 | + "doc": "Async step with API call\n```ts\nimport type { BuilderStepFunction } from \"@probitas/builder\";\n\ntype User = { id: string; name: string };\n\nconst step: BuilderStepFunction<User> = async (ctx) => {\n const response = await fetch(\"/api/user\", { signal: ctx.signal });\n return response.json();\n};\n```" |
370 | 370 | } |
371 | 371 | ] |
372 | 372 | }, |
|
551 | 551 | "name": "BuilderStepDefinition", |
552 | 552 | "isDefault": false, |
553 | 553 | "location": { |
554 | | - "filename": "https://jsr.io/@probitas/builder/0.3.1/types.ts", |
555 | | - "line": 124, |
| 554 | + "filename": "https://jsr.io/@probitas/builder/0.3.2/types.ts", |
| 555 | + "line": 139, |
556 | 556 | "col": 0, |
557 | | - "byteIndex": 3678 |
| 557 | + "byteIndex": 4203 |
558 | 558 | }, |
559 | 559 | "declarationKind": "export", |
560 | 560 | "jsDoc": { |
|
613 | 613 | "doc": "Step function to execute" |
614 | 614 | }, |
615 | 615 | "location": { |
616 | | - "filename": "https://jsr.io/@probitas/builder/0.3.1/types.ts", |
617 | | - "line": 131, |
| 616 | + "filename": "https://jsr.io/@probitas/builder/0.3.2/types.ts", |
| 617 | + "line": 146, |
618 | 618 | "col": 2, |
619 | | - "byteIndex": 3918 |
| 619 | + "byteIndex": 4443 |
620 | 620 | }, |
621 | 621 | "params": [], |
622 | 622 | "readonly": true, |
|
768 | 768 | ] |
769 | 769 | } |
770 | 770 | } |
771 | | - ], |
772 | | - "generatedAt": "2025-12-16T18:17:30.878Z" |
| 771 | + ] |
773 | 772 | } |
0 commit comments