CodeSampleX

Sample

@types/js-yaml 4.0.9: exports

Verified sample for npm @types/js-yaml 4.0.9: exports. The contract ran on node 22 · linux alpine/x64 · docker and passed: package.json defines an exports…

sha256:e43c71898e34cd24fe2e7529d2d2ff8a911bafbdc5c92f8978f9076033c178a2

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
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-26
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-07

Case

HOW
Goal
verify @types/js-yaml.exports in pkg:npm/%40types/js-yaml@4.0.9
Packages
Symbols
  • @types/js-yaml.exports
Environment
node 22.23.2
Created
2026-08-26T12:27:29Z

Contract

  1. package.json defines an exports field containing root '.' and './package.json' entry points
  2. exports['.'] defines TypeScript conditional types mapping with 'import' pointing to './index.d.mts' and 'default' pointing to './index.d.ts'
  3. exports['./package.json'] resolves to './package.json' allowing package metadata introspection
  4. The referenced index.d.ts declaration file exists and defines core exports (load, loadAll, dump, Type, Schema, FAILSAFE_SCHEMA, JSON_SCHEMA, CORE_SCHEMA, DEFAULT_SCHEMA, YAMLException)
  5. The referenced index.d.mts declaration file exists and provides ESM re-exports for TypeScript module resolution
  6. The legacy 'types' field in package.json points to 'index.d.ts' for backwards compatibility with legacy resolution modes

Files

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

Download the source artifact (tar.gz)

Source

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 @types/js-yaml.exports in pkg:npm/%40types/js-yaml@4.0.9
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40types/js-yaml@4.0.9
Demonstrate these symbols/APIs:
  - @types/js-yaml.exports

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:b7ba1f315ebedd1ec1808b7eb289779c924d46cfe0236b0ac6df5fb16f329131","contract":["package.json defines an exports field containing root '.' and './package.json' entry points","exports['.'] defines TypeScript conditional types mapping with 'import' pointing to './index.d.mts' and 'default' pointing to './index.d.ts'","exports['./package.json'] resolves to './package.json' allowing package metadata introspection","The referenced index.d.ts declaration file exists and defines core exports (load, loadAll, dump, Type, Schema, FAILSAFE_SCHEMA, JSON_SCHEMA, CORE_SCHEMA, DEFAULT_SCHEMA, YAMLException)","The referenced index.d.mts declaration file exists and provides ESM re-exports for TypeScript module resolution","The legacy 'types' field in package.json points to 'index.d.ts' for backwards compatibility with legacy resolution modes"],"goal":"verify @types/js-yaml.exports in pkg:npm/%40types/js-yaml@4.0.9","kind":"HOW","packages":["pkg:npm/%40types/js-yaml@4.0.9"],"schemaVersion":1,"symbols":["@types/js-yaml.exports"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","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/js-yaml@4.0.9"],"schemaVersion":1,"subject":"pkg:npm/%40types/js-yaml@4.0.9","symbols":["@types/js-yaml.exports"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-types-js-yaml",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-types-js-yaml",
      "version": "1.0.0",
      "dependencies": {
        "@types/js-yaml": "4.0.9"
      }
    },
    "node_modules/@types/js-yaml": {
      "version": "4.0.9",
      "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz",
      "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-types-js-yaml",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "@types/js-yaml": "4.0.9"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @types/js-yaml.exports in pkg:npm/%40types/js-yaml@4.0.9",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/js-yaml@4.0.9"
  ],
  "symbols": [
    "@types/js-yaml.exports"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rootDir = path.resolve(__dirname, '..');

// Locate @types/js-yaml package directory
const pkgJsonPath = path.join(rootDir, 'node_modules', '@types', 'js-yaml', 'package.json');
assert.ok(fs.existsSync(pkgJsonPath), '@types/js-yaml package.json must exist in node_modules');

const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));

// 1. package.json defines an exports field containing root '.' and './package.json' entry points
{
  assert.ok(pkg.exports !== undefined && typeof pkg.exports === 'object', 'pkg.exports must be defined as an object');
  assert.ok('.' in pkg.exports, "pkg.exports must include '.' root entry point");
  assert.ok('./package.json' in pkg.exports, "pkg.exports must include './package.json' subpath entry point");
}

// 2. exports['.'] defines TypeScript conditional types mapping with 'import' pointing to './index.d.mts' and 'default' pointing to './index.d.ts'
{
  const dotExport = pkg.exports['.'];
  assert.ok(dotExport && typeof dotExport === 'object', "exports['.'] must be an object");
  assert.ok('types' in dotExport && typeof dotExport.types === 'object', "exports['.'].types must be defined");
  assert.equal(dotExport.types.import, './index.d.mts', "exports['.'].types.import must point to './index.d.mts'");
  assert.equal(dotExport.types.default, './index.d.ts', "exports['.'].types.default must point to './index.d.ts'");
}

// 3. exports['./package.json'] resolves to './package.json' allowing package metadata introspection
{
  assert.equal(pkg.exports['./package.json'], './package.json', "exports['./package.json'] must map to './package.json'");
}

// 4. The referenced index.d.ts declaration file exists and defines core exports (load, loadAll, dump, Type, Schema, FAILSAFE_SCHEMA, JSON_SCHEMA, CORE_SCHEMA, DEFAULT_SCHEMA, YAMLException)
{
  const dtsPath = path.join(rootDir, 'node_modules', '@types', 'js-yaml', 'index.d.ts');
  assert.ok(fs.existsSync(dtsPath), 'index.d.ts referenced by exports must exist');
  const dtsContent = fs.readFileSync(dtsPath, 'utf8');
  assert.ok(dtsContent.includes('export function load('), 'index.d.ts must export function load');
  assert.ok(dtsContent.includes('export function loadAll('), 'index.d.ts must export function loadAll');
  assert.ok(dtsContent.includes('export function dump('), 'index.d.ts must export function dump');
  assert.ok(dtsContent.includes('export class Type'), 'index.d.ts must export class Type');
  assert.ok(dtsContent.includes('export class Schema'), 'index.d.ts must export class Schema');
  assert.ok(dtsContent.includes('export let FAILSAFE_SCHEMA: Schema;'), 'index.d.ts must export FAILSAFE_SCHEMA');
  assert.ok(dtsContent.includes('export let JSON_SCHEMA: Schema;'), 'index.d.ts must export JSON_SCHEMA');
  assert.ok(dtsContent.includes('export let CORE_SCHEMA: Schema;'), 'index.d.ts must export CORE_SCHEMA');
  assert.ok(dtsContent.includes('export let DEFAULT_SCHEMA: Schema;'), 'index.d.ts must export DEFAULT_SCHEMA');
  assert.ok(dtsContent.includes('export class YAMLException extends Error'), 'index.d.ts must export class YAMLException');
}

// 5. The referenced index.d.mts declaration file exists and provides ESM re-exports for TypeScript module resolution
{
  const dmtsPath = path.join(rootDir, 'node_modules', '@types', 'js-yaml', 'index.d.mts');
  assert.ok(fs.existsSync(dmtsPath), 'index.d.mts referenced by exports must exist');
  const dmtsContent = fs.readFileSync(dmtsPath, 'utf8');
  assert.ok(dmtsContent.includes('export * from "./index.js";'), 'index.d.mts must contain wildcard re-export from ./index.js');
  assert.ok(dmtsContent.includes('export { default } from "./index.js";'), 'index.d.mts must contain default re-export from ./index.js');
}

// 6. The legacy 'types' field in package.json points to 'index.d.ts' for backwards compatibility with legacy resolution modes
{
  assert.equal(pkg.types, 'index.d.ts', "Legacy 'types' field must point to 'index.d.ts'");
}

console.log('Contract test passed successfully: all 6 assertions passed.');

Origin Seeder

anonymous