CodeSampleX

サンプル

@types/json-schema 7.0.15

検証済みサンプル — npm @types/json-schema 7.0.15. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: package manifest specifies index.d.ts type declarations…

sha256:56a0a22d0265c2a7f0c8e18a7c46047d5d8a0199d725debc1ac95c43deed8fcb

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

実行証拠

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

証拠の基準
署名済みコントラクト合格
検証レシート
3
ビルドした署名鍵
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 SKIPPED compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-08
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/%40types/json-schema@7.0.15
パッケージ
環境
node 22.23.2
作成日
2026-08-23T07:05:48Z

コントラクト

  1. package manifest specifies index.d.ts type declarations and TypeScript version
  2. declares JSONSchema4 types and interfaces for draft-04 schema specifications
  3. declares JSONSchema6 types and interfaces for draft-06 schema specifications
  4. declares JSONSchema7 types, definitions, and keyword properties for draft-07 schema specifications
  5. declares validation utility function signatures and ValidationResult interfaces

ファイル

  • 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/%40types/json-schema@7.0.15
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40types/json-schema@7.0.15
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:d5ad61040eec0ccb7cd45fe9e60593038e64bf98034cc7695d0d6a315265eff5","constraints":{"executionContext":"node"},"contract":["package manifest specifies index.d.ts type declarations and TypeScript version","declares JSONSchema4 types and interfaces for draft-04 schema specifications","declares JSONSchema6 types and interfaces for draft-06 schema specifications","declares JSONSchema7 types, definitions, and keyword properties for draft-07 schema specifications","declares validation utility function signatures and ValidationResult interfaces"],"goal":"verify pkg:npm/%40types/json-schema@7.0.15","kind":"HOW","packages":["pkg:npm/%40types/json-schema@7.0.15"],"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/%40types/json-schema@7.0.15"],"schemaVersion":1,"subject":"pkg:npm/%40types/json-schema@7.0.15","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-types-json-schema",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-types-json-schema",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@types/json-schema": "7.0.15"
      }
    },
    "node_modules/@types/json-schema": {
      "version": "7.0.15",
      "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
      "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-types-json-schema",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@types/json-schema": "7.0.15"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40types/json-schema@7.0.15",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/json-schema@7.0.15"
  ],
  "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';
import fs from 'node:fs';
import path from 'node:path';

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

// 1. Resolve @types/json-schema package manifest and verify type declaration entry points
const pkgPath = require.resolve('@types/json-schema/package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));

assert.equal(pkg.name, '@types/json-schema', 'Package name must be @types/json-schema');
assert.equal(pkg.version, '7.0.15', 'Package version must be 7.0.15');
assert.equal(pkg.types, 'index.d.ts', 'Package types entry must point to index.d.ts');
assert.equal(pkg.typeScriptVersion, '4.5', 'TypeScript version must be 4.5');

const typesDir = path.dirname(pkgPath);
const dtsContent = fs.readFileSync(path.join(typesDir, 'index.d.ts'), 'utf8');

// 2. Verify JSONSchema4 types and interfaces for draft-04 schema specifications
assert.ok(
  dtsContent.includes('export type JSONSchema4TypeName =') &&
  dtsContent.includes('"string"') &&
  dtsContent.includes('"number"') &&
  dtsContent.includes('"integer"') &&
  dtsContent.includes('"boolean"') &&
  dtsContent.includes('"object"') &&
  dtsContent.includes('"array"') &&
  dtsContent.includes('"null"') &&
  dtsContent.includes('"any";'),
  'JSONSchema4TypeName must declare primitive type names including any'
);
assert.ok(
  dtsContent.includes('export type JSONSchema4Type =') &&
  dtsContent.includes('export interface JSONSchema4Object') &&
  dtsContent.includes('export interface JSONSchema4Array extends Array<JSONSchema4Type>'),
  'JSONSchema4Type, JSONSchema4Object, and JSONSchema4Array must be declared'
);
assert.ok(
  dtsContent.includes('export interface JSONSchema4 {') &&
  dtsContent.includes('id?: string | undefined;') &&
  dtsContent.includes('$ref?: string | undefined;') &&
  dtsContent.includes('$schema?: JSONSchema4Version | undefined;') &&
  dtsContent.includes('multipleOf?: number | undefined;') &&
  dtsContent.includes('maximum?: number | undefined;') &&
  dtsContent.includes('exclusiveMaximum?: boolean | undefined;'),
  'JSONSchema4 interface must declare draft-04 schema properties'
);

// 3. Verify JSONSchema6 types and interfaces for draft-06 schema specifications
assert.ok(
  dtsContent.includes('export type JSONSchema6TypeName =') &&
  dtsContent.includes('export type JSONSchema6Type =') &&
  dtsContent.includes('export type JSONSchema6Definition = JSONSchema6 | boolean;') &&
  dtsContent.includes('export interface JSONSchema6 {') &&
  dtsContent.includes('$id?: string | undefined;') &&
  dtsContent.includes('exclusiveMaximum?: number | undefined;') &&
  dtsContent.includes('exclusiveMinimum?: number | undefined;'),
  'JSONSchema6 types, definition, and numeric exclusive boundaries must be declared'
);

// 4. Verify JSONSchema7 types, definitions, and keyword properties for draft-07 schema specifications
assert.ok(
  dtsContent.includes('export type JSONSchema7TypeName =') &&
  dtsContent.includes('export type JSONSchema7Type =') &&
  dtsContent.includes('export type JSONSchema7Definition = JSONSchema7 | boolean;') &&
  dtsContent.includes('export interface JSONSchema7 {') &&
  dtsContent.includes('$defs?: {') &&
  dtsContent.includes('if?: JSONSchema7Definition | undefined;') &&
  dtsContent.includes('then?: JSONSchema7Definition | undefined;') &&
  dtsContent.includes('else?: JSONSchema7Definition | undefined;') &&
  dtsContent.includes('readOnly?: boolean | undefined;') &&
  dtsContent.includes('writeOnly?: boolean | undefined;'),
  'JSONSchema7 interface must declare draft-07 condition keywords, $defs, and annotations'
);

// 5. Verify validation utility function signatures and ValidationResult interfaces
assert.ok(
  dtsContent.includes('export interface ValidationResult {') &&
  dtsContent.includes('valid: boolean;') &&
  dtsContent.includes('errors: ValidationError[];') &&
  dtsContent.includes('export interface ValidationError {') &&
  dtsContent.includes('property: string;') &&
  dtsContent.includes('message: string;'),
  'ValidationResult and ValidationError interfaces must be declared'
);
assert.ok(
  dtsContent.includes('export function validate(instance: {}, schema: JSONSchema4 | JSONSchema6 | JSONSchema7): ValidationResult;') &&
  dtsContent.includes('export function checkPropertyChange(') &&
  dtsContent.includes('export function mustBeValid(result: ValidationResult): void;'),
  'validate, checkPropertyChange, and mustBeValid utility functions must be declared'
);

console.log('Contract tests passed successfully.');

オリジンシーダー

匿名