CodeSampleX

샘플

pino-abstract-transport 3.0.0

검증된 샘플 — npm pino-abstract-transport 3.0.0. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: build returns a transform stream that parses JSON…

sha256:eb58fa0486b3785d387373f1cdc7a80770ae15fa597a283e2d84cae66cdffa7e

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
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-19

케이스

HOW
목표
verify pkg:npm/pino-abstract-transport@3.0.0
패키지
환경
node 22.23.2
생성일
2026-09-18T14:33:48Z

컨트랙트

  1. build returns a transform stream that parses JSON lines and delivers parsed log objects to an async iterator
  2. build tracks metadata on the transport stream updating lastLevel, lastTime, and lastObj by default
  3. build supports opts.metadata set to false to disable metadata properties on the transport stream
  4. build supports parse: 'lines' option to deliver raw line strings to the async iterator
  5. build supports custom parseLine option to transform line strings before processing
  6. build emits unknown event when unparseable content is written to the stream
  7. build emits unknown event when parsed value is null
  8. build invokes custom opts.close handler when the transport stream is destroyed or ended
  9. build supports enablePipelining returning a duplex stream for chained transformations
  10. build emits error when opts.expectPinoConfig is true without workerData pinoWillSendConfig

파일

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

소스 아티팩트 내려받기 (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/pino-abstract-transport@3.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/pino-abstract-transport@3.0.0

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:bdc5322da493ad77af11c6d397357ee09ce6b639749db38979aa24271f83221f","contract":["build returns a transform stream that parses JSON lines and delivers parsed log objects to an async iterator","build tracks metadata on the transport stream updating lastLevel, lastTime, and lastObj by default","build supports opts.metadata set to false to disable metadata properties on the transport stream","build supports parse: 'lines' option to deliver raw line strings to the async iterator","build supports custom parseLine option to transform line strings before processing","build emits unknown event when unparseable content is written to the stream","build emits unknown event when parsed value is null","build invokes custom opts.close handler when the transport stream is destroyed or ended","build supports enablePipelining returning a duplex stream for chained transformations","build emits error when opts.expectPinoConfig is true without workerData pinoWillSendConfig"],"goal":"verify pkg:npm/pino-abstract-transport@3.0.0","kind":"HOW","packages":["pkg:npm/pino-abstract-transport@3.0.0"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"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/pino-abstract-transport@3.0.0"],"schemaVersion":1,"subject":"pkg:npm/pino-abstract-transport@3.0.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "pino-abstract-transport-verification",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "pino-abstract-transport-verification",
      "version": "1.0.0",
      "dependencies": {
        "pino-abstract-transport": "3.0.0"
      }
    },
    "node_modules/pino-abstract-transport": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-3.0.0.tgz",
      "integrity": "sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==",
      "license": "MIT",
      "dependencies": {
        "split2": "^4.0.0"
      }
    },
    "node_modules/split2": {
      "version": "4.2.0",
      "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz",
      "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==",
      "license": "ISC",
      "engines": {
        "node": ">= 10.x"
      }
    }
  }
}
package.json
{
  "name": "pino-abstract-transport-verification",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for pino-abstract-transport",
  "dependencies": {
    "pino-abstract-transport": "3.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/pino-abstract-transport@3.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/pino-abstract-transport@3.0.0"
  ]
}
test/contract.cjs
const assert = require('node:assert');
const { Transform } = require('node:stream');
const build = require('pino-abstract-transport');

async function testContract() {
  // 1. build returns a transform stream that parses JSON lines and delivers parsed log objects to an async iterator
  {
    const receivedLogs = [];
    const transport = build(async function (source) {
      for await (const obj of source) {
        receivedLogs.push(obj);
      }
    });

    transport.write(JSON.stringify({ level: 30, time: 1000, msg: 'log 1' }) + '\n');
    transport.write(JSON.stringify({ level: 40, time: 2000, msg: 'log 2' }) + '\n');
    transport.end();

    await new Promise((resolve) => transport.on('close', resolve));
    assert.strictEqual(receivedLogs.length, 2);
    assert.strictEqual(receivedLogs[0].msg, 'log 1');
    assert.strictEqual(receivedLogs[1].msg, 'log 2');
  }

  // 2. build tracks metadata on the transport stream updating lastLevel, lastTime, and lastObj by default
  {
    const transport = build(async function (source) {
      for await (const _ of source) {}
    });

    assert.strictEqual(transport.lastLevel, 0);
    assert.strictEqual(transport.lastTime, 0);
    assert.strictEqual(transport.lastObj, null);

    transport.write(JSON.stringify({ level: 50, time: 123456, msg: 'error occurred' }) + '\n');
    transport.end();

    await new Promise((resolve) => transport.on('close', resolve));
    assert.strictEqual(transport.lastLevel, 50);
    assert.strictEqual(transport.lastTime, 123456);
    assert.deepStrictEqual(transport.lastObj, { level: 50, time: 123456, msg: 'error occurred' });
  }

  // 3. build supports opts.metadata set to false to disable metadata properties on the transport stream
  {
    const receivedLogs = [];
    const transport = build(async function (source) {
      for await (const obj of source) {
        receivedLogs.push(obj);
      }
    }, { metadata: false });

    assert.strictEqual(transport.lastLevel, undefined);
    assert.strictEqual(transport.lastTime, undefined);
    assert.strictEqual(transport.lastObj, undefined);

    transport.write(JSON.stringify({ level: 20, time: 9999, msg: 'debug' }) + '\n');
    transport.end();

    await new Promise((resolve) => transport.on('close', resolve));
    assert.strictEqual(receivedLogs.length, 1);
  }

  // 4. build supports parse: 'lines' option to deliver raw line strings to the async iterator
  {
    const receivedLines = [];
    const transport = build(async function (source) {
      for await (const line of source) {
        receivedLines.push(line);
      }
    }, { parse: 'lines' });

    const rawLine = '{"custom":"json"}';
    transport.write(rawLine + '\n');
    transport.end();

    await new Promise((resolve) => transport.on('close', resolve));
    assert.strictEqual(receivedLines.length, 1);
    assert.strictEqual(receivedLines[0], rawLine);
  }

  // 5. build supports custom parseLine option to transform line strings before processing
  {
    const receivedLogs = [];
    const transport = build(async function (source) {
      for await (const obj of source) {
        receivedLogs.push(obj);
      }
    }, {
      parseLine: (str) => ({ customParsed: str.trim().toUpperCase() })
    });

    transport.write('sample line\n');
    transport.end();

    await new Promise((resolve) => transport.on('close', resolve));
    assert.strictEqual(receivedLogs.length, 1);
    assert.strictEqual(receivedLogs[0].customParsed, 'SAMPLE LINE');
  }

  // 6. build emits unknown event when unparseable content is written to the stream
  {
    let unknownEvent = null;
    const transport = build(async function (source) {
      for await (const _ of source) {}
    });

    transport.on('unknown', (line, err) => {
      unknownEvent = { line, hasErr: !!err };
    });

    transport.write('invalid json payload\n');
    transport.end();

    await new Promise((resolve) => transport.on('close', resolve));
    assert.ok(unknownEvent);
    assert.strictEqual(unknownEvent.line, 'invalid json payload');
    assert.strictEqual(unknownEvent.hasErr, true);
  }

  // 7. build emits unknown event when parsed value is null
  {
    let nullUnknown = null;
    const transport = build(async function (source) {
      for await (const _ of source) {}
    });

    transport.on('unknown', (line, reason) => {
      nullUnknown = { line, reason };
    });

    transport.write('null\n');
    transport.end();

    await new Promise((resolve) => transport.on('close', resolve));
    assert.ok(nullUnknown);
    assert.strictEqual(nullUnknown.line, 'null');
    assert.strictEqual(nullUnknown.reason, 'Null value ignored');
  }

  // 8. build invokes custom opts.close handler when the transport stream is destroyed or ended
  {
    let closedCalled = false;
    const transport = build(async function (source) {
      for await (const _ of source) {}
    }, {
      close(err, cb) {
        closedCalled = true;
        cb(err);
      }
    });

    transport.write(JSON.stringify({ msg: 'test' }) + '\n');
    transport.end();

    await new Promise((resolve) => transport.on('close', resolve));
    assert.strictEqual(closedCalled, true);
  }

  // 9. build supports enablePipelining returning a duplex stream for chained transformations
  {
    const transformStream = new Transform({
      objectMode: true,
      transform(chunk, enc, cb) {
        chunk.pipelined = true;
        cb(null, JSON.stringify(chunk) + '\n');
      }
    });

    const transport = build(function (source) {
      return source.pipe(transformStream);
    }, { enablePipelining: true });

    let collectedOutput = '';
    transport.on('data', (chunk) => {
      collectedOutput += chunk.toString();
    });

    transport.write(JSON.stringify({ msg: 'pipe' }) + '\n');
    transport.end();

    await new Promise((resolve) => transport.on('end', resolve));
    const parsed = JSON.parse(collectedOutput.trim());
    assert.strictEqual(parsed.msg, 'pipe');
    assert.strictEqual(parsed.pipelined, true);
  }

  // 10. build emits error when opts.expectPinoConfig is true without workerData pinoWillSendConfig
  {
    let caughtError = null;
    const transport = build(async function (source) {
      for await (const _ of source) {}
    }, { expectPinoConfig: true });

    await new Promise((resolve) => {
      transport.on('error', (err) => {
        caughtError = err;
        resolve();
      });
    });

    assert.ok(caughtError);
    assert.match(caughtError.message, /This transport is not compatible with the current version of pino/);
  }

  console.log('Contract passed');
}

testContract().catch((err) => {
  console.error(err);
  process.exit(1);
});

오리진 시더

익명