occam-server
raw JSON → 7.0.13 verified Sat May 09 auth: no javascript
Server-side functionality for the Occam IDE, version 7.0.13. Provides file system operations such as loading and saving files, projects, and releases. Exports functions like loadFile, saveFile, loadFiles, loadProject, loadRelease, loadProjects, loadReleases, removeRelease, moveProjectEntries, removeProjectEntries, renameProjectEntries, createProjectEntries. Unlike typical REST APIs, it works over a JSON-based protocol (e.g., via occam-open-cli) and returns plain JSON rather than model instances. Release cadence is irregular; primarily maintained by djalbat. Depends on Node.js and is not browser-compatible.
Common errors
error Cannot find module 'occam-server' ↓
cause Package not installed or not in node_modules.
fix
Run 'npm install occam-server'
error Uncaught TypeError: loadFiles is not a function ↓
cause Incorrect import: trying to use default import instead of named import.
fix
Use const { loadFiles } = require('occam-server');
error TypeError: Cannot read properties of null (reading 'fromJSON') ↓
cause Assuming loadFiles always returns a non-null JSON.
fix
Check if result is null before calling Files.fromJSON(result).
Warnings
gotcha loadFiles returns JSON, not a Files instance; you must instantiate Files.fromJSON yourself. ↓
fix Check for null and use Files.fromJSON(json) from occam-open-cli.
deprecated Some functions may be renamed or removed in future versions; not actively developed. ↓
fix Monitor the repository for updates or consider alternative solutions.
gotcha All callbacks receive a second 'error' argument? The docs show single argument but ensure error handling. ↓
fix Review source code to confirm callback signature; use try/catch for synchronous parts.
Install
npm install occam-server yarn add occam-server pnpm add occam-server Imports
- loadFiles
import { loadFiles } from 'occam-server' - loadFile wrong
import loadFile from 'occam-server'correctconst { loadFile } = require('occam-server') - saveFile wrong
import { saveFile } from 'occam-server'correctconst { saveFile } = require('occam-server')
Quickstart
const server = require('occam-server');
const { loadFiles, saveFile } = server;
const projectsDirectoryPath = '/path/to/projects';
const filePaths = ['README.md', 'package.json'];
const json = { filePaths };
loadFiles(projectsDirectoryPath, json, (result) => {
if (result !== null) {
console.log('Files loaded:', JSON.stringify(result, null, 2));
} else {
console.error('Failed to load files');
}
});