CodeSampleX

Пример

@types/istanbul-lib-coverage 2.0.6

Проверенный пример — npm @types/istanbul-lib-coverage 2.0.6. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден.

sha256:e9d7ddd8cc312859b0a67d1673db033a400fa0e661ef6ee1fe240107ac139103

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Среды запусков проверки

Окружение Контракт Этапы Запуск
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-21

Кейс

HOW
Цель
verify pkg:npm/%40types/istanbul-lib-coverage@2.0.6
Пакеты
Окружение
node 22.23.2
Создан
2026-08-21T05:32:28Z

Контракт

  1. package manifest specifies index.d.ts type declarations and TypeScript version
  2. declares CoverageSummary class and CoverageSummaryData interface for summary statistics
  3. declares CoverageMap class and CoverageMapData interface with coverage aggregation methods
  4. declares FileCoverage class and FileCoverageData interface with line and branch calculation methods
  5. declares createCoverageMap, createCoverageSummary, and createFileCoverage factory functions

Файлы

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:npm/%40types/istanbul-lib-coverage@2.0.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40types/istanbul-lib-coverage@2.0.6
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:28c93f9d41106714403819d77392b04ade5a8cba8e0cde3be8be32b310c0d736","constraints":{"executionContext":"node"},"contract":["package manifest specifies index.d.ts type declarations and TypeScript version","declares CoverageSummary class and CoverageSummaryData interface for summary statistics","declares CoverageMap class and CoverageMapData interface with coverage aggregation methods","declares FileCoverage class and FileCoverageData interface with line and branch calculation methods","declares createCoverageMap, createCoverageSummary, and createFileCoverage factory functions"],"goal":"verify pkg:npm/%40types/istanbul-lib-coverage@2.0.6","kind":"HOW","packages":["pkg:npm/%40types/istanbul-lib-coverage@2.0.6"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40types/istanbul-lib-coverage@2.0.6"],"schemaVersion":1,"subject":"pkg:npm/%40types/istanbul-lib-coverage@2.0.6","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-types-istanbul-lib-coverage",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-types-istanbul-lib-coverage",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@types/istanbul-lib-coverage": "2.0.6"
      }
    },
    "node_modules/@types/istanbul-lib-coverage": {
      "version": "2.0.6",
      "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz",
      "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-types-istanbul-lib-coverage",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@types/istanbul-lib-coverage": "2.0.6"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40types/istanbul-lib-coverage@2.0.6",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/istanbul-lib-coverage@2.0.6"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import fs from 'node:fs';
import path from 'node:path';

const require = createRequire(import.meta.url);

// 1. Resolve @types/istanbul-lib-coverage package manifest and verify type declaration entry points
const pkgPath = require.resolve('@types/istanbul-lib-coverage/package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

assert.equal(pkg.name, '@types/istanbul-lib-coverage', 'Package name must be @types/istanbul-lib-coverage');
assert.equal(pkg.version, '2.0.6', 'Package version must be 2.0.6');
assert.equal(pkg.types, 'index.d.ts', 'Package types entry must point to index.d.ts');
assert.equal(pkg.typeScriptVersion, '4.5', 'TypeScript version must be 4.5');

const typesDir = path.dirname(pkgPath);
const dtsContent = fs.readFileSync(path.join(typesDir, 'index.d.ts'), 'utf8');

// 2. Verify CoverageSummary class and CoverageSummaryData interface for summary statistics
assert.ok(
  dtsContent.includes('export interface CoverageSummaryData {') &&
  dtsContent.includes('lines: Totals;') &&
  dtsContent.includes('statements: Totals;') &&
  dtsContent.includes('branches: Totals;') &&
  dtsContent.includes('functions: Totals;'),
  'CoverageSummaryData interface must declare lines, statements, branches, and functions totals'
);
assert.ok(
  dtsContent.includes('export class CoverageSummary {') &&
  dtsContent.includes('constructor(data: CoverageSummary | CoverageSummaryData);') &&
  dtsContent.includes('merge(obj: CoverageSummary): CoverageSummary;') &&
  dtsContent.includes('toJSON(): CoverageSummaryData;') &&
  dtsContent.includes('isEmpty(): boolean;'),
  'CoverageSummary class must declare constructor, merge, toJSON, and isEmpty methods'
);

// 3. Verify CoverageMap class and CoverageMapData interface with coverage aggregation methods
assert.ok(
  dtsContent.includes('export interface CoverageMapData {') &&
  dtsContent.includes('[key: string]: FileCoverage | FileCoverageData;'),
  'CoverageMapData interface must map keys to FileCoverage or FileCoverageData'
);
assert.ok(
  dtsContent.includes('export class CoverageMap {') &&
  dtsContent.includes('constructor(data: CoverageMapData | CoverageMap);') &&
  dtsContent.includes('addFileCoverage(pathOrObject: string | FileCoverage | FileCoverageData): void;') &&
  dtsContent.includes('files(): string[];') &&
  dtsContent.includes('fileCoverageFor(filename: string): FileCoverage;') &&
  dtsContent.includes('filter(callback: (key: string) => boolean): void;') &&
  dtsContent.includes('getCoverageSummary(): CoverageSummary;') &&
  dtsContent.includes('merge(data: CoverageMapData | CoverageMap): void;') &&
  dtsContent.includes('toJSON(): CoverageMapData;'),
  'CoverageMap class must declare constructor, addFileCoverage, files, fileCoverageFor, filter, getCoverageSummary, and merge methods'
);

// 4. Verify FileCoverage class, FileCoverageData, Location, Range, BranchMapping, FunctionMapping, and Totals
assert.ok(
  dtsContent.includes('export interface Location {') &&
  dtsContent.includes('export interface Range {') &&
  dtsContent.includes('export interface BranchMapping {') &&
  dtsContent.includes('export interface FunctionMapping {') &&
  dtsContent.includes('export interface Totals {') &&
  dtsContent.includes('export interface Coverage {'),
  'Location, Range, BranchMapping, FunctionMapping, Totals, and Coverage interfaces must be declared'
);
assert.ok(
  dtsContent.includes('export interface FileCoverageData {') &&
  dtsContent.includes('path: string;') &&
  dtsContent.includes('statementMap: { [key: string]: Range };') &&
  dtsContent.includes('fnMap: { [key: string]: FunctionMapping };') &&
  dtsContent.includes('branchMap: { [key: string]: BranchMapping };') &&
  dtsContent.includes('s: { [key: string]: number };') &&
  dtsContent.includes('f: { [key: string]: number };') &&
  dtsContent.includes('b: { [key: string]: number[] };'),
  'FileCoverageData interface must declare path, statementMap, fnMap, branchMap, s, f, and b'
);
assert.ok(
  dtsContent.includes('export class FileCoverage implements FileCoverageData {') &&
  dtsContent.includes('constructor(data: string | FileCoverage | FileCoverageData);') &&
  dtsContent.includes('merge(other: FileCoverageData): void;') &&
  dtsContent.includes('getBranchCoverageByLine(): { [line: number]: Coverage };') &&
  dtsContent.includes('getLineCoverage(): { [line: number]: number };') &&
  dtsContent.includes('getUncoveredLines(): number[];') &&
  dtsContent.includes('resetHits(): void;') &&
  dtsContent.includes('computeBranchTotals(): Totals;') &&
  dtsContent.includes('computeSimpleTotals(): Totals;') &&
  dtsContent.includes('toSummary(): CoverageSummary;') &&
  dtsContent.includes('toJSON(): object;'),
  'FileCoverage class must implement FileCoverageData with line, branch, summary, and hit calculation methods'
);

// 5. Verify factory functions and exported classes object
assert.ok(
  dtsContent.includes('export const classes: {') &&
  dtsContent.includes('FileCoverage: FileCoverage;'),
  'classes object must declare FileCoverage property'
);
assert.ok(
  dtsContent.includes('export function createCoverageMap(data?: CoverageMap | CoverageMapData): CoverageMap;') &&
  dtsContent.includes('export function createCoverageSummary(obj?: CoverageSummary | CoverageSummaryData): CoverageSummary;') &&
  dtsContent.includes('export function createFileCoverage(pathOrObject: string | FileCoverage | FileCoverageData): FileCoverage;'),
  'Factory functions createCoverageMap, createCoverageSummary, and createFileCoverage must be declared'
);

console.log('Contract tests passed successfully.');

Исходный сидер

аноним