CodeSampleX

Beispiel

json-schema-traverse 0.4.1

Verifiziertes Beispiel für npm json-schema-traverse 0.4.1. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:724ed455fcbef38e0f40566db0ccc7124ccc9b8e9966afd6ec06c96d1479589c

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
2
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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
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-08

Fall

HOW
Ziel
verify pkg:npm/json-schema-traverse@0.4.1
Pakete
Umgebung
node 22.23.2
Erstellt
2026-08-23T06:56:05Z

Contract

  1. traverse recursively visits root and nested schema definitions with standard JSON pointer paths
  2. callback receives schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, and keyIndex
  3. supports separate pre and post traversal callbacks on schema nodes
  4. allKeys option traverses custom keywords while ignoring scalar skip keywords
  5. properly escapes special characters tilde and slash in property JSON pointers

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/json-schema-traverse@0.4.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/json-schema-traverse@0.4.1
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:cf3969bcf5ce492603c6c2e4ca612c755fbb876698db00aeafaf038f34360149","constraints":{"executionContext":"node"},"contract":["traverse recursively visits root and nested schema definitions with standard JSON pointer paths","callback receives schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, and keyIndex","supports separate pre and post traversal callbacks on schema nodes","allKeys option traverses custom keywords while ignoring scalar skip keywords","properly escapes special characters tilde and slash in property JSON pointers"],"goal":"verify pkg:npm/json-schema-traverse@0.4.1","kind":"HOW","packages":["pkg:npm/json-schema-traverse@0.4.1"],"schemaVersion":1},"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/json-schema-traverse@0.4.1"],"schemaVersion":1,"subject":"pkg:npm/json-schema-traverse@0.4.1","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-json-schema-traverse",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-json-schema-traverse",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "json-schema-traverse": "0.4.1"
      }
    },
    "node_modules/json-schema-traverse": {
      "version": "0.4.1",
      "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
      "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-json-schema-traverse",
  "version": "1.0.0",
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "json-schema-traverse": "0.4.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/json-schema-traverse@0.4.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/json-schema-traverse@0.4.1"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const traverse = require('json-schema-traverse');

// 1. traverse recursively visits root and nested schema definitions with standard JSON pointer paths
const schema = {
  type: 'object',
  properties: {
    name: { type: 'string' },
    tags: {
      type: 'array',
      items: [{ type: 'string' }, { type: 'number' }]
    }
  },
  definitions: {
    custom: { type: 'boolean' }
  },
  allOf: [
    { required: ['name'] }
  ]
};

const visitedPointers = [];
traverse(schema, (subSchema, jsonPtr) => {
  visitedPointers.push(jsonPtr);
});

assert.deepEqual(visitedPointers, [
  '',
  '/properties/name',
  '/properties/tags',
  '/properties/tags/items/0',
  '/properties/tags/items/1',
  '/definitions/custom',
  '/allOf/0'
]);

// 2. callback receives schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, and keyIndex
const details = [];
traverse(schema, (subSchema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) => {
  details.push({
    jsonPtr,
    isRoot: rootSchema === schema,
    parentJsonPtr,
    parentKeyword,
    keyIndex
  });
});

assert.deepEqual(details[0], {
  jsonPtr: '',
  isRoot: true,
  parentJsonPtr: undefined,
  parentKeyword: undefined,
  keyIndex: undefined
});

assert.deepEqual(details[1], {
  jsonPtr: '/properties/name',
  isRoot: true,
  parentJsonPtr: '',
  parentKeyword: 'properties',
  keyIndex: 'name'
});

assert.deepEqual(details[3], {
  jsonPtr: '/properties/tags/items/0',
  isRoot: true,
  parentJsonPtr: '/properties/tags',
  parentKeyword: 'items',
  keyIndex: 0
});

// 3. supports separate pre and post traversal callbacks on schema nodes
const prePostLog = [];
const smallSchema = {
  properties: {
    a: { type: 'string' }
  }
};

traverse(smallSchema, {
  cb: {
    pre: (subSchema, jsonPtr) => prePostLog.push(`pre:${jsonPtr}`),
    post: (subSchema, jsonPtr) => prePostLog.push(`post:${jsonPtr}`)
  }
});

assert.deepEqual(prePostLog, [
  'pre:',
  'pre:/properties/a',
  'post:/properties/a',
  'post:'
]);

// 4. allKeys option traverses custom keywords while ignoring scalar skip keywords
const customSchema = {
  customSection: {
    subProperty: { type: 'number' }
  },
  title: 'Sample Title',
  minimum: 10
};

const customVisited = [];
traverse(customSchema, { allKeys: true }, (subSchema, jsonPtr) => {
  customVisited.push(jsonPtr);
});

assert.deepEqual(customVisited, [
  '',
  '/customSection',
  '/customSection/subProperty'
]);

// 5. properly escapes special characters tilde and slash in property JSON pointers
const specialKeysSchema = {
  properties: {
    'a~b': { type: 'string' },
    'c/d': { type: 'number' },
    'e~/f': { type: 'boolean' }
  }
};

const specialPointers = [];
traverse(specialKeysSchema, (subSchema, jsonPtr) => {
  specialPointers.push(jsonPtr);
});

assert.deepEqual(specialPointers, [
  '',
  '/properties/a~0b',
  '/properties/c~1d',
  '/properties/e~0~1f'
]);

Ursprungs-Seeder

anonym