CodeSampleX

Exemplo

undici-types 8.3.0: types

Amostra verificada para npm undici-types 8.3.0: types. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: undici-types package.json declares…

sha256:e291880c9c94e553433ec5cff5d41456712b74bb0d7c45272d1e680d9219c977

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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-27

Caso

HOW
Objetivo
verify undici-types.types in pkg:npm/undici-types@8.3.0
Pacotes
Símbolos
  • undici-types.types
Ambiente
node 22.23.2
Criado
2026-08-27T11:28:22Z

Contrato

  1. undici-types package.json declares type definitions entry point index.d.ts and version 8.3.0
  2. undici-types index.d.ts exports core HTTP client types and classes including Dispatcher, Client, Pool, and Agent
  3. undici-types index.d.ts re-exports Web standard type definitions for fetch, Headers, Request, Response, and FormData
  4. undici-types index.d.ts exports global dispatcher and origin configuration functions and interceptors
  5. undici-types index.d.ts exports default Undici namespace containing typed client and utility constructors
  6. undici-types dispatcher.d.ts declares Dispatcher class with dispatch, request, stream, pipeline, and lifecycle methods

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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 undici-types.types in pkg:npm/undici-types@8.3.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/undici-types@8.3.0
Demonstrate these symbols/APIs:
  - undici-types.types

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:784d3a07ae2339e00e3b7e751785ade4aaca70a54ca104674f284d298057c539","contract":["undici-types package.json declares type definitions entry point index.d.ts and version 8.3.0","undici-types index.d.ts exports core HTTP client types and classes including Dispatcher, Client, Pool, and Agent","undici-types index.d.ts re-exports Web standard type definitions for fetch, Headers, Request, Response, and FormData","undici-types index.d.ts exports global dispatcher and origin configuration functions and interceptors","undici-types index.d.ts exports default Undici namespace containing typed client and utility constructors","undici-types dispatcher.d.ts declares Dispatcher class with dispatch, request, stream, pipeline, and lifecycle methods"],"goal":"verify undici-types.types in pkg:npm/undici-types@8.3.0","kind":"HOW","packages":["pkg:npm/undici-types@8.3.0"],"schemaVersion":1,"symbols":["undici-types.types"]},"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/undici-types@8.3.0"],"schemaVersion":1,"subject":"pkg:npm/undici-types@8.3.0","symbols":["undici-types.types"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-undici-types",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-undici-types",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "undici-types": "8.3.0"
      }
    },
    "node_modules/undici-types": {
      "version": "8.3.0",
      "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",
      "integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-undici-types",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "license": "MIT-0",
  "dependencies": {
    "undici-types": "8.3.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify undici-types.types in pkg:npm/undici-types@8.3.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/undici-types@8.3.0"
  ],
  "symbols": [
    "undici-types.types"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { createRequire } from 'node:module';

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

// 1. undici-types package.json declares type definitions entry point index.d.ts and version 8.3.0
const pkgJsonPath = require.resolve('undici-types/package.json');
assert.ok(fs.existsSync(pkgJsonPath));
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
assert.equal(pkgJson.name, 'undici-types');
assert.equal(pkgJson.version, '8.3.0');
assert.equal(pkgJson.types, 'index.d.ts');

const pkgDir = path.dirname(pkgJsonPath);

// 2. undici-types index.d.ts exports core HTTP client types and classes including Dispatcher, Client, Pool, and Agent
const indexDtsPath = path.join(pkgDir, 'index.d.ts');
assert.ok(fs.existsSync(indexDtsPath));
const indexDts = fs.readFileSync(indexDtsPath, 'utf8');

assert.ok(indexDts.includes("import Dispatcher from './dispatcher'"));
assert.ok(indexDts.includes("import Pool from './pool'"));
assert.ok(indexDts.includes("import Client from './client'"));
assert.ok(indexDts.includes("import Agent from './agent'"));
assert.ok(indexDts.includes("export { Dispatcher, BalancedPool, RoundRobinPool, Pool, Client, buildConnector, errors, Agent, Dispatcher1Wrapper, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, interceptors, cacheStores, MockClient, MockPool, MockAgent, SnapshotAgent, MockCallHistory, MockCallHistoryLog, mockErrors, ProxyAgent, Socks5ProxyAgent, EnvHttpProxyAgent, RedirectHandler, DecoratorHandler, RetryHandler, RetryAgent, H2CClient, globalThisInstall as install }"));

// 3. undici-types index.d.ts re-exports Web standard type definitions for fetch, Headers, Request, Response, and FormData
assert.ok(indexDts.includes("export * from './fetch'"));
assert.ok(indexDts.includes("export * from './formdata'"));
assert.ok(indexDts.includes("export * from './websocket'"));
assert.ok(indexDts.includes("export * from './eventsource'"));
assert.ok(indexDts.includes("export * from './cookies'"));

const fetchDtsPath = path.join(pkgDir, 'fetch.d.ts');
assert.ok(fs.existsSync(fetchDtsPath));
const fetchDts = fs.readFileSync(fetchDtsPath, 'utf8');
assert.ok(fetchDts.includes('export declare function fetch ('));
assert.ok(fetchDts.includes('export class BodyMixin {'));

// 4. undici-types index.d.ts exports global dispatcher and origin configuration functions and interceptors
assert.ok(indexDts.includes("import { setGlobalDispatcher, getGlobalDispatcher } from './global-dispatcher'"));
assert.ok(indexDts.includes("import { setGlobalOrigin, getGlobalOrigin } from './global-origin'"));
assert.ok(indexDts.includes("import interceptors from './interceptors'"));

// 5. undici-types index.d.ts exports default Undici namespace containing typed client and utility constructors
assert.ok(indexDts.includes('export default Undici'));
assert.ok(indexDts.includes('declare namespace Undici {'));
assert.ok(indexDts.includes("const Dispatcher: typeof import('./dispatcher').default"));
assert.ok(indexDts.includes("const Pool: typeof import('./pool').default"));
assert.ok(indexDts.includes("const Client: typeof import('./client').default"));
assert.ok(indexDts.includes("const fetch: typeof import('./fetch').fetch"));

// 6. undici-types dispatcher.d.ts declares Dispatcher class with dispatch, request, stream, pipeline, and lifecycle methods
const dispatcherDtsPath = path.join(pkgDir, 'dispatcher.d.ts');
assert.ok(fs.existsSync(dispatcherDtsPath));
const dispatcherDts = fs.readFileSync(dispatcherDtsPath, 'utf8');

assert.ok(dispatcherDts.includes('declare class Dispatcher extends EventEmitter {'));
assert.ok(dispatcherDts.includes('dispatch (options: Dispatcher.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean'));
assert.ok(dispatcherDts.includes('request<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, callback: (err: Error | null, data: Dispatcher.ResponseData<TOpaque>) => void): void'));
assert.ok(dispatcherDts.includes('stream<TOpaque = null>(options: Dispatcher.RequestOptions<TOpaque>, factory: Dispatcher.StreamFactory<TOpaque>, callback: (err: Error | null, data: Dispatcher.StreamData<TOpaque>) => void): void'));
assert.ok(dispatcherDts.includes('pipeline<TOpaque = null>(options: Dispatcher.PipelineOptions<TOpaque>, handler: Dispatcher.PipelineHandler<TOpaque>): Duplex'));
assert.ok(dispatcherDts.includes('close (callback: () => void): void'));
assert.ok(dispatcherDts.includes('destroy (err: Error | null, callback: () => void): void'));

console.log('All contract tests passed.');

Seeder de origem

anônimo