CodeSampleX

Ejemplo

@types/js-yaml 4.0.9: name

Muestra verificada para npm @types/js-yaml 4.0.9: name. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: @types/js-yaml package.json…

sha256:ce90d5d546bcbba626926d68e868ad0fa80be8d7f73f88100decf563c7e3c116

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
2
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
verify @types/js-yaml.name in pkg:npm/%40types/js-yaml@4.0.9
Paquetes
Símbolos
  • @types/js-yaml.name
Entorno
node 22.23.2
Creado
2026-08-26T12:30:11Z

Contrato

  1. @types/js-yaml package.json defines package name @types/js-yaml and version 4.0.9
  2. @types/js-yaml package.json configures types and exports entries pointing to declaration files
  3. @types/js-yaml index.d.ts declares jsyaml global namespace
  4. @types/js-yaml index.d.ts declares YAMLException error class with name property
  5. @types/js-yaml index.d.ts declares Mark interface with name property
  6. @types/js-yaml index.d.ts declares Type class with representName property

Archivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.js

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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.name 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.name

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:6977b677e416c1432bafdbbf8f15ac216f3d269fdcb9f31e8cee63ce3c608343","contract":["@types/js-yaml package.json defines package name @types/js-yaml and version 4.0.9","@types/js-yaml package.json configures types and exports entries pointing to declaration files","@types/js-yaml index.d.ts declares jsyaml global namespace","@types/js-yaml index.d.ts declares YAMLException error class with name property","@types/js-yaml index.d.ts declares Mark interface with name property","@types/js-yaml index.d.ts declares Type class with representName property"],"goal":"verify @types/js-yaml.name 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.name"]},"contractCommand":["node","test/contract.js"],"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/js-yaml@4.0.9"],"schemaVersion":1,"subject":"pkg:npm/%40types/js-yaml@4.0.9","symbols":["@types/js-yaml.name"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-types-js-yaml-name",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-types-js-yaml-name",
      "version": "1.0.0",
      "license": "MIT-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-name",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for @types/js-yaml name",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "@types/js-yaml": "4.0.9"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @types/js-yaml.name in pkg:npm/%40types/js-yaml@4.0.9",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/js-yaml@4.0.9"
  ],
  "symbols": [
    "@types/js-yaml.name"
  ]
}
src/index.js
const fs = require('node:fs');
const path = require('node:path');

/**
 * Resolves the path to the @types/js-yaml package.json and declaration file.
 * @returns {{ pkgJsonPath: string, declPath: string }} Paths to package.json and index.d.ts
 */
function resolvePackagePaths() {
  const pkgJsonPath = require.resolve('@types/js-yaml/package.json');
  const pkgDir = path.dirname(pkgJsonPath);
  const declPath = path.join(pkgDir, 'index.d.ts');
  return { pkgJsonPath, declPath };
}

/**
 * Reads and parses the @types/js-yaml package.json manifest.
 * @returns {object} Parsed package.json object
 */
function loadPackageManifest() {
  const { pkgJsonPath } = resolvePackagePaths();
  return JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
}

/**
 * Loads the declaration file content from @types/js-yaml.
 * @returns {string} The text content of index.d.ts
 */
function loadDeclarationContent() {
  const { declPath } = resolvePackagePaths();
  return fs.readFileSync(declPath, 'utf8');
}

/**
 * Inspects name-related declarations and package metadata in @types/js-yaml.
 * @returns {object} Detailed report of discovered symbols and manifest fields
 */
function inspectNameDefinitions() {
  const manifest = loadPackageManifest();
  const declContent = loadDeclarationContent();

  const packageName = manifest.name;
  const packageVersion = manifest.version;
  const hasTypesField = Boolean(manifest.types && manifest.types === 'index.d.ts');
  const hasExportsMapping = Boolean(
    manifest.exports &&
    manifest.exports['.'] &&
    manifest.exports['.'].types
  );

  const hasNamespaceDeclaration = declContent.includes('export as namespace jsyaml;');
  const hasYAMLExceptionName = declContent.includes('export class YAMLException extends Error') &&
    declContent.includes('name: string;');
  const hasMarkName = declContent.includes('export interface Mark') &&
    declContent.includes('name: string;');
  const hasTypeRepresentName = declContent.includes('export class Type') &&
    declContent.includes('representName: ((data: object) => any) | null;');

  return {
    packageName,
    packageVersion,
    hasTypesField,
    hasExportsMapping,
    hasNamespaceDeclaration,
    hasYAMLExceptionName,
    hasMarkName,
    hasTypeRepresentName
  };
}

module.exports = {
  resolvePackagePaths,
  loadPackageManifest,
  loadDeclarationContent,
  inspectNameDefinitions
};
test/contract.js
const assert = require('node:assert/strict');
const fs = require('node:fs');
const {
  resolvePackagePaths,
  loadPackageManifest,
  loadDeclarationContent,
  inspectNameDefinitions
} = require('../src/index.js');

// Contract 1: @types/js-yaml package.json defines package name @types/js-yaml and version 4.0.9
const manifest = loadPackageManifest();
assert.strictEqual(manifest.name, '@types/js-yaml', 'package name must be @types/js-yaml');
assert.strictEqual(manifest.version, '4.0.9', 'package version must be 4.0.9');

// Contract 2: @types/js-yaml package.json configures types and exports entries pointing to declaration files
assert.strictEqual(manifest.types, 'index.d.ts', 'types field must point to index.d.ts');
assert.ok(manifest.exports && manifest.exports['.'], 'exports dot entry must be defined');
assert.strictEqual(manifest.exports['.'].types.default, './index.d.ts', 'exports default types must point to ./index.d.ts');
assert.strictEqual(manifest.exports['.'].types.import, './index.d.mts', 'exports import types must point to ./index.d.mts');

// Contract 3: @types/js-yaml index.d.ts declares jsyaml global namespace
const { declPath } = resolvePackagePaths();
assert.strictEqual(fs.existsSync(declPath), true, 'index.d.ts declaration file must exist on disk');
const declContent = loadDeclarationContent();
assert.strictEqual(
  declContent.includes('export as namespace jsyaml;'),
  true,
  'index.d.ts must declare global jsyaml namespace'
);

// Contract 4: @types/js-yaml index.d.ts declares YAMLException error class with name property
assert.strictEqual(
  declContent.includes('export class YAMLException extends Error'),
  true,
  'index.d.ts must declare YAMLException class'
);
assert.strictEqual(
  declContent.includes('name: string;'),
  true,
  'index.d.ts must declare name property on error/mark constructs'
);

// Contract 5: @types/js-yaml index.d.ts declares Mark interface with name property
assert.strictEqual(
  declContent.includes('export interface Mark'),
  true,
  'index.d.ts must declare Mark interface'
);

// Contract 6: @types/js-yaml index.d.ts declares Type class with representName property
assert.strictEqual(
  declContent.includes('export class Type'),
  true,
  'index.d.ts must declare Type class'
);
assert.strictEqual(
  declContent.includes('representName: ((data: object) => any) | null;'),
  true,
  'Type class must declare representName property'
);

// High-level inspection verification
const inspection = inspectNameDefinitions();
assert.strictEqual(inspection.packageName, '@types/js-yaml');
assert.strictEqual(inspection.packageVersion, '4.0.9');
assert.strictEqual(inspection.hasTypesField, true);
assert.strictEqual(inspection.hasExportsMapping, true);
assert.strictEqual(inspection.hasNamespaceDeclaration, true);
assert.strictEqual(inspection.hasYAMLExceptionName, true);
assert.strictEqual(inspection.hasMarkName, true);
assert.strictEqual(inspection.hasTypeRepresentName, true);

console.log('Contract tests for @types/js-yaml.name in pkg:npm/%40types/js-yaml@4.0.9 passed successfully.');

Seeder de origen

anónimo