サンプル
basic-ftp 5.3.1: FileType
検証済みサンプル — npm basic-ftp 5.3.1: FileType. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: FileType enumeration defines integer constants for…
sha256:adf11c8bdb651480a47130e90c3ec0c3c123445db823d7b8dcc20ef3a870d00a
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 2
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 npm
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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-26 |
| 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-07 |
ケース
HOW- ゴール
- verify basic-ftp.FileType in pkg:npm/basic-ftp@5.3.1
- パッケージ
- シンボル
-
- basic-ftp.FileType
- 作成日
- 2026-08-26T12:28:39Z
コントラクト
- FileType enumeration defines integer constants for Unknown (0), File (1), Directory (2), and SymbolicLink (3)
- FileType provides reverse mapping from numeric values to type name strings
- FileInfo instances use FileType values to determine isFile, isDirectory, and isSymbolicLink boolean states
- parseList parses directory listings and populates FileInfo objects with the corresponding FileType enum values
ファイル
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
ソース
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 basic-ftp.FileType in pkg:npm/basic-ftp@5.3.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/basic-ftp@5.3.1
Demonstrate these symbols/APIs:
- basic-ftp.FileType
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.
{"case":{"caseId":"case:sha256:8f0ed1c8f160292da49feeac3d5027a9a7898037c4665aa81240432d0d24462f","contract":["FileType enumeration defines integer constants for Unknown (0), File (1), Directory (2), and SymbolicLink (3)","FileType provides reverse mapping from numeric values to type name strings","FileInfo instances use FileType values to determine isFile, isDirectory, and isSymbolicLink boolean states","parseList parses directory listings and populates FileInfo objects with the corresponding FileType enum values"],"goal":"verify basic-ftp.FileType in pkg:npm/basic-ftp@5.3.1","kind":"HOW","packages":["pkg:npm/basic-ftp@5.3.1"],"schemaVersion":1,"symbols":["basic-ftp.FileType"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/basic-ftp@5.3.1"],"schemaVersion":1,"subject":"pkg:npm/basic-ftp@5.3.1","symbols":["basic-ftp.FileType"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-basic-ftp-filetype",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-basic-ftp-filetype",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"basic-ftp": "5.3.1"
}
},
"node_modules/basic-ftp": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.3.1.tgz",
"integrity": "sha512-bopVNp6ugyA150DDuZfPFdt1KZ5a94ZDiwX4hMgZDzF+GttD80lEy8kj98kbyhLXnPvhtIo93mdnLIjpCAeeOw==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
}
}
}
}
{
"name": "sample-basic-ftp-filetype",
"version": "1.0.0",
"type": "module",
"private": true,
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"basic-ftp": "5.3.1"
}
}
{
"schemaVersion": 1,
"goal": "verify basic-ftp.FileType in pkg:npm/basic-ftp@5.3.1",
"kind": "HOW",
"packages": [
"pkg:npm/basic-ftp@5.3.1"
],
"symbols": [
"basic-ftp.FileType"
]
}
import ftp from 'basic-ftp';
const { FileType, FileInfo, parseList } = ftp;
/**
* Resolves the string name for a given FileType enum value.
* @param {number} fileType - The numeric FileType value.
* @returns {string} The name of the file type.
*/
export function getFileTypeName(fileType) {
return FileType[fileType] || 'Unknown';
}
/**
* Creates a FileInfo instance with a specified name and FileType.
* @param {string} name - File or directory name.
* @param {number} type - FileType enum value.
* @returns {ftp.FileInfo} Configured FileInfo object.
*/
export function createFileInfo(name, type) {
const info = new FileInfo(name);
info.type = type;
return info;
}
/**
* Parses raw FTP list output into FileInfo objects with FileType information.
* @param {string} rawEntries - Raw directory listing string.
* @returns {ftp.FileInfo[]} Array of parsed FileInfo objects.
*/
export function parseDirectoryList(rawEntries) {
return parseList(rawEntries);
}
export { FileType, FileInfo, parseList };
export default FileType;
import assert from 'node:assert/strict';
import ftp from 'basic-ftp';
import {
FileType,
FileInfo,
parseList,
getFileTypeName,
createFileInfo,
parseDirectoryList
} from '../src/index.mjs';
// 1. FileType enumeration defines integer constants for Unknown (0), File (1), Directory (2), and SymbolicLink (3)
{
assert.equal(FileType.Unknown, 0);
assert.equal(FileType.File, 1);
assert.equal(FileType.Directory, 2);
assert.equal(FileType.SymbolicLink, 3);
}
// 2. FileType provides reverse mapping from numeric values to type name strings
{
assert.equal(FileType[0], 'Unknown');
assert.equal(FileType[1], 'File');
assert.equal(FileType[2], 'Directory');
assert.equal(FileType[3], 'SymbolicLink');
assert.equal(getFileTypeName(FileType.Unknown), 'Unknown');
assert.equal(getFileTypeName(FileType.File), 'File');
assert.equal(getFileTypeName(FileType.Directory), 'Directory');
assert.equal(getFileTypeName(FileType.SymbolicLink), 'SymbolicLink');
}
// 3. FileInfo instances use FileType values to determine isFile, isDirectory, and isSymbolicLink boolean states
{
const file = createFileInfo('example.txt', FileType.File);
assert.equal(file.name, 'example.txt');
assert.equal(file.type, FileType.File);
assert.equal(file.isFile, true);
assert.equal(file.isDirectory, false);
assert.equal(file.isSymbolicLink, false);
const dir = createFileInfo('docs', FileType.Directory);
assert.equal(dir.name, 'docs');
assert.equal(dir.type, FileType.Directory);
assert.equal(dir.isFile, false);
assert.equal(dir.isDirectory, true);
assert.equal(dir.isSymbolicLink, false);
const link = createFileInfo('link-to-doc', FileType.SymbolicLink);
assert.equal(link.name, 'link-to-doc');
assert.equal(link.type, FileType.SymbolicLink);
assert.equal(link.isFile, false);
assert.equal(link.isDirectory, false);
assert.equal(link.isSymbolicLink, true);
const unknown = createFileInfo('unknown-entry', FileType.Unknown);
assert.equal(unknown.type, FileType.Unknown);
assert.equal(unknown.isFile, false);
assert.equal(unknown.isDirectory, false);
assert.equal(unknown.isSymbolicLink, false);
}
// 4. parseList parses directory listings and populates FileInfo objects with the corresponding FileType enum values
{
const rawList = [
'-rw-r--r-- 1 owner group 1024 Jan 01 00:00 notes.txt',
'drwxr-xr-x 2 owner group 4096 Jan 01 00:00 projects',
'lrwxrwxrwx 1 owner group 9 Jan 01 00:00 shortcut -> notes.txt'
].join('\n');
const parsed = parseDirectoryList(rawList);
assert.equal(parsed.length, 3);
assert.equal(parsed[0].name, 'notes.txt');
assert.equal(parsed[0].type, FileType.File);
assert.equal(parsed[0].isFile, true);
assert.equal(parsed[1].name, 'projects');
assert.equal(parsed[1].type, FileType.Directory);
assert.equal(parsed[1].isDirectory, true);
assert.equal(parsed[2].name, 'shortcut');
assert.equal(parsed[2].type, FileType.SymbolicLink);
assert.equal(parsed[2].isSymbolicLink, true);
}
console.log('Contract tests passed successfully.');
オリジンシーダー
匿名