CodeSampleX

サンプル

@types/chai 5.2.3

検証済みサンプル — npm @types/chai 5.2.3. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: package manifest specifies index.d.ts type declarations and…

sha256:e6097ca1a0095fac0d9e10ce3a6c3c696ac07d46f433e5f0943d8e44acc31e38

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 linux 24 · ubuntu · glibc 2.39 x64 npm

検証実行環境

環境 コントラクト ステージ 実行日
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-23

ケース

HOW
ゴール
verify pkg:npm/%40types/chai@5.2.3
パッケージ
作成日
2026-08-23T14:51:24Z

コントラクト

  1. package manifest specifies index.d.ts type declarations and TypeScript version
  2. declares top-level exports for expect, assert, should, util, config, and Assertion
  3. declares ChaiStatic, ExpectStatic, Should, and ShouldAssertion interfaces
  4. declares Assertion interface with language chains and assertion methods
  5. declares ChaiUtils plugin helper interface with method and property extension utilities
  6. declares Config interface and register-should Object interface augmentation

ファイル

  • 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/chai@5.2.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40types/chai@5.2.3

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:d0bb976f05295b6d3d9ea2b93da236bf156ba28e308e41f11720e83a90e3fa04","contract":["package manifest specifies index.d.ts type declarations and TypeScript version","declares top-level exports for expect, assert, should, util, config, and Assertion","declares ChaiStatic, ExpectStatic, Should, and ShouldAssertion interfaces","declares Assertion interface with language chains and assertion methods","declares ChaiUtils plugin helper interface with method and property extension utilities","declares Config interface and register-should Object interface augmentation"],"goal":"verify pkg:npm/%40types/chai@5.2.3","kind":"HOW","packages":["pkg:npm/%40types/chai@5.2.3"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40types/chai@5.2.3"],"schemaVersion":1,"subject":"pkg:npm/%40types/chai@5.2.3","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-types-chai",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-types-chai",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@types/chai": "5.2.3"
      }
    },
    "node_modules/@types/chai": {
      "version": "5.2.3",
      "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz",
      "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==",
      "license": "MIT",
      "dependencies": {
        "@types/deep-eql": "*",
        "assertion-error": "^2.0.1"
      }
    },
    "node_modules/@types/deep-eql": {
      "version": "4.0.2",
      "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",
      "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==",
      "license": "MIT"
    },
    "node_modules/assertion-error": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
      "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",
      "license": "MIT",
      "engines": {
        "node": ">=12"
      }
    }
  }
}
package.json
{
  "name": "sample-types-chai",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@types/chai": "5.2.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40types/chai@5.2.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/chai@5.2.3"
  ]
}
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/chai package manifest and verify type declaration entry points
const pkgPath = require.resolve('@types/chai/package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

assert.equal(pkg.name, '@types/chai', 'Package name must be @types/chai');
assert.equal(pkg.version, '5.2.3', 'Package version must be 5.2.3');
assert.equal(pkg.types, 'index.d.ts', 'Package types entry must point to index.d.ts');
assert.equal(pkg.typeScriptVersion, '5.2', 'TypeScript version must be 5.2');
assert.ok(pkg.dependencies && pkg.dependencies['@types/deep-eql'], 'Dependencies must include @types/deep-eql');
assert.ok(pkg.dependencies && pkg.dependencies['assertion-error'], 'Dependencies must include assertion-error');

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

// 2. Verify top-level exports in index.d.ts
assert.ok(
  dtsContent.includes('export const expect: Chai.ExpectStatic;') &&
  dtsContent.includes('export const assert: Chai.AssertStatic;') &&
  dtsContent.includes('export function should(): Chai.Should;') &&
  dtsContent.includes('export function Should(): Chai.Should;') &&
  dtsContent.includes('export const util: Chai.ChaiUtils;') &&
  dtsContent.includes('export const config: Chai.Config;') &&
  dtsContent.includes('export const Assertion: Chai.AssertionStatic;') &&
  dtsContent.includes('export const AssertionError: typeof ImportedAssertionError;') &&
  dtsContent.includes('export function use(fn: Chai.ChaiPlugin): Chai.ChaiStatic;'),
  'Top-level exports (expect, assert, should, util, config, Assertion, AssertionError, use) must be declared'
);

// 3. Verify ChaiStatic, ExpectStatic, and Should interfaces
assert.ok(
  dtsContent.includes('export interface ChaiStatic {') &&
  dtsContent.includes('expect: ExpectStatic;') &&
  dtsContent.includes('should(): Should;') &&
  dtsContent.includes('use(fn: ChaiPlugin): ChaiStatic;') &&
  dtsContent.includes('util: ChaiUtils;') &&
  dtsContent.includes('assert: AssertStatic;') &&
  dtsContent.includes('config: Config;') &&
  dtsContent.includes('Assertion: AssertionStatic;') &&
  dtsContent.includes('AssertionError: typeof AssertionError;') &&
  dtsContent.includes('version: string;'),
  'ChaiStatic interface must declare expect, should, use, util, assert, config, Assertion, AssertionError, version'
);
assert.ok(
  dtsContent.includes('export interface ExpectStatic {') &&
  dtsContent.includes('(val: any, message?: string): Assertion;') &&
  dtsContent.includes('fail(message?: string): never;') &&
  dtsContent.includes('fail(actual: any, expected: any, message?: string, operator?: Operator): never;'),
  'ExpectStatic interface must declare callable assertion constructor and fail methods'
);
assert.ok(
  dtsContent.includes('export interface ShouldAssertion {') &&
  dtsContent.includes('equal(value1: any, value2: any, message?: string): void;') &&
  dtsContent.includes('Throw: ShouldThrow;') &&
  dtsContent.includes('throw: ShouldThrow;') &&
  dtsContent.includes('exist(value: any, message?: string): void;') &&
  dtsContent.includes('export interface Should extends ShouldAssertion {') &&
  dtsContent.includes('not: ShouldAssertion;'),
  'Should and ShouldAssertion interfaces must declare equal, throw, exist, and not'
);

// 4. Verify Assertion interface and chain properties
assert.ok(
  dtsContent.includes('export interface Assertion extends LanguageChains, NumericComparison, TypeComparison {') &&
  dtsContent.includes('not: Assertion;') &&
  dtsContent.includes('deep: Deep;') &&
  dtsContent.includes('nested: Nested;') &&
  dtsContent.includes('own: Own;') &&
  dtsContent.includes('all: KeyFilter;') &&
  dtsContent.includes('a: Assertion;') &&
  dtsContent.includes('an: Assertion;') &&
  dtsContent.includes('include: Include;') &&
  dtsContent.includes('equal: Equal;') &&
  dtsContent.includes('property: Property;'),
  'Assertion interface must declare chaining modifiers (not, deep, nested, own, all, a, an, include, equal, property)'
);

// 5. Verify ChaiUtils plugin helper interface
assert.ok(
  dtsContent.includes('export interface ChaiUtils {') &&
  dtsContent.includes('addChainableMethod(') &&
  dtsContent.includes('overwriteChainableMethod(') &&
  dtsContent.includes('addMethod(ctx: object, name: string, method: Function): void;') &&
  dtsContent.includes('addProperty(ctx: object, name: string, getter: () => any): void;') &&
  dtsContent.includes('flag(obj: object, key: string, value?: any): any;') &&
  dtsContent.includes('inspect(obj: any, showHidden?: boolean, depth?: number, colors?: boolean): string;') &&
  dtsContent.includes('eql: typeof deepEqual;'),
  'ChaiUtils interface must declare addChainableMethod, addMethod, addProperty, flag, inspect, and eql'
);

// 6. Verify Config interface and register-should Object augmentation
assert.ok(
  dtsContent.includes('export interface Config {') &&
  dtsContent.includes('includeStack: boolean;') &&
  dtsContent.includes('showDiff: boolean;') &&
  dtsContent.includes('truncateThreshold: number;') &&
  dtsContent.includes('useProxy: boolean;') &&
  dtsContent.includes('proxyExcludedKeys: string[];') &&
  dtsContent.includes('deepEqual: <L, R>(expected: L, actual: R) => void;'),
  'Config interface must declare includeStack, showDiff, truncateThreshold, useProxy, proxyExcludedKeys, deepEqual'
);

const registerShouldPath = path.join(typesDir, 'register-should.d.ts');
assert.ok(fs.existsSync(registerShouldPath), 'register-should.d.ts file must exist');
const registerShouldContent = fs.readFileSync(registerShouldPath, 'utf8');
assert.ok(
  registerShouldContent.includes('interface Object {') &&
  registerShouldContent.includes('should: Chai.Assertion;'),
  'register-should.d.ts must augment Object interface with should property'
);

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

オリジンシーダー

匿名