{"_id":"@cool-ai/beach-a2ui-test","name":"@cool-ai/beach-a2ui-test","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@cool-ai/beach-a2ui-test","version":"0.1.0","description":"Test utilities for asserting on Beach A2UI surface-builder output (SurfaceCommand[] / keyed-envelope inspection).","license":"Apache-2.0","repository":{"type":"git","url":"git+https://gitlab.com/johncandrew/beach.git","directory":"packages/a2ui-test"},"homepage":"https://cool-ai.org","bugs":{"url":"https://gitlab.com/johncandrew/beach/-/issues"},"type":"module","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"publishConfig":{"access":"public"},"devDependencies":{"typescript":"^5.5.0","vitest":"^2.0.0"},"scripts":{"build":"tsc --project tsconfig.json","dev":"tsc --project tsconfig.json --watch","test":"vitest run","coverage":"vitest run --coverage","test:watch":"vitest","typecheck":"tsc --noEmit"},"_id":"@cool-ai/beach-a2ui-test@0.1.0","_integrity":"sha512-xxET4P28GSiPBUfUlHz/MRXpu08X/mtWk71R3x4naC3L8hZjewEfBUOMEmgaapHy97ah35FKEViH2sXULngyeA==","_resolved":"/tmp/ce8f00c08a1f61e731064268b3421f87/cool-ai-beach-a2ui-test-0.1.0.tgz","_from":"file:cool-ai-beach-a2ui-test-0.1.0.tgz","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-xxET4P28GSiPBUfUlHz/MRXpu08X/mtWk71R3x4naC3L8hZjewEfBUOMEmgaapHy97ah35FKEViH2sXULngyeA==","shasum":"967d6ae50823cca3b2d35bb95b37e69d3e68c97d","tarball":"https://registry.npmjs.org/@cool-ai/beach-a2ui-test/-/beach-a2ui-test-0.1.0.tgz","fileCount":11,"unpackedSize":24861,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICgvB09c4Ct2Pg+4pT8PQ6SQ9jzoa6430ZnpCt4Wj1xCAiEA6d6U74yfhoRh1GAnlIe5PpT9qtVcrCNK3f0WxViLoXE="}]},"_npmUser":{"name":"johncandrew","email":"johncandrew@yahoo.co.uk"},"directories":{},"maintainers":[{"name":"johncandrew","email":"johncandrew@yahoo.co.uk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/beach-a2ui-test_0.1.0_1778509726502_0.7669857494073933"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-11T14:28:46.423Z","0.1.0":"2026-05-11T14:28:46.687Z","modified":"2026-05-11T14:28:46.889Z"},"maintainers":[{"name":"johncandrew","email":"johncandrew@yahoo.co.uk"}],"description":"Test utilities for asserting on Beach A2UI surface-builder output (SurfaceCommand[] / keyed-envelope inspection).","homepage":"https://cool-ai.org","repository":{"type":"git","url":"git+https://gitlab.com/johncandrew/beach.git","directory":"packages/a2ui-test"},"bugs":{"url":"https://gitlab.com/johncandrew/beach/-/issues"},"license":"Apache-2.0","readme":"# @cool-ai/beach-a2ui-test\n\nTest utility for packages that build A2UI surfaces. Parses a `SurfaceCommand[]` stream and exposes a typed view for assertions — no raw message JSON in your tests.\n\n> **Home:** [cool-ai.org](https://cool-ai.org) · **Documentation:** [cool-ai.org/docs](https://cool-ai.org/docs)\n\n## Install\n\n```sh\nnpm install --save-dev @cool-ai/beach-a2ui-test\n```\n\nNo peer dependencies. Works with any test framework.\n\n## Usage\n\n```typescript\nimport { surfaceOf } from '@cool-ai/beach-a2ui-test';\nimport { productCard } from '@cool-ai/beach-a2ui-patterns';\n\nconst cmds = productCard({\n  surfaceId: 'order-123',\n  title: 'Your Order',\n  items: [{ label: 'Flight LHR-FCO', amount: '£299' }],\n  total: { label: 'Total', amount: '£299' },\n});\n\nconst s = surfaceOf(cmds, 'order-123');\n\ns.surfaceId   // 'order-123'\ns.catalogId   // 'https://a2ui.org/specification/v0_9/basic_catalog.json'\n\ns.find('Card')              // first Card node in the tree, or undefined\ns.findAll('Text')           // every Text node, depth-first\ns.toJSON()                  // serialisable snapshot for toMatchSnapshot()\n```\n\n## API\n\n### `surfaceOf(commands, surfaceId?)`\n\nExtracts a single surface from a `SurfaceCommand[]` (or any `unknown[]`) stream.\n\n- `commands` — the array returned by a surface builder.\n- `surfaceId` — when provided, selects the surface with that id. When omitted, selects the first surface found.\n- Throws if no matching `createSurface` message exists.\n\nReturns a `SurfaceView`:\n\n| Member | Description |\n|---|---|\n| `surfaceId` | The id from the `createSurface` message. |\n| `catalogId` | The catalog id from the `createSurface` message. |\n| `components` | The raw components array from the first matching `updateComponents` message. |\n| `find(type)` | Depth-first search for the first component whose `component` field equals `type`. Walks `children` arrays and singular `child` references. Returns `undefined` if not found. |\n| `findAll(type)` | Collects every matching component across the tree, depth-first. |\n| `toJSON()` | Returns `{ surfaceId, catalogId, components }` — suitable for snapshot assertions. |\n\n`find` and `findAll` walk inline-nested trees (the format used by pattern helpers). They do not resolve keyed id references.\n","readmeFilename":"README.md","_rev":"1-86b7e022965926cd74a8692326d40387"}