CodeSampleX

サンプル

json-schema-traverse 0.4.1

検証済みサンプル — npm json-schema-traverse 0.4.1. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: traverse recursively visits root and nested schema…

sha256:724ed455fcbef38e0f40566db0ccc7124ccc9b8e9966afd6ec06c96d1479589c

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
2
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

検証実行環境

環境 コントラクト ステージ 実行日
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

ケース

HOW
ゴール
verify pkg:npm/json-schema-traverse@0.4.1
パッケージ
環境
node 22.23.2
作成日
2026-08-23T06:56:05Z

コントラクト

  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

ファイル

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

ソースアーティファクトをダウンロード (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/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'
]);

オリジンシーダー

匿名