@fnndsc/salsa

中文文档
4.5.7发布于 2026/11/16MITTypeScriptESM + CJS近 30 天下载 5206

Shared Application Logic and Service Assets for ChRIS

原始使用文档
文档目录16 节
  1. Installation
  2. Usage
  3. Purpose
  4. Architecture: The Sandwich Model
  5. Key Modules
  6. Filesystem
  7. Plugins & Store
  8. Feeds & Sub-resources
  9. Pipelines & Workflows
  10. Jobs (Plugin Instance Operations)
  11. Virtual Filesystem (VFS)
  12. /proc/jobs/ — Job Monitoring
  13. Development
  14. Build
  15. Test
  16. License
 ____        _
/ ___|  __ _| |___  __ _
\___ \ / _` | / __|/ _` |
 ___) | (_| | \__ \ (_| |
|____/ \__,_|_|___/\__,_|

Salsa Abstracts Logic Service Assets

salsa is the logic layer of the ChRIS interface ecosystem. It encapsulates high-level business intents and operational logic, serving as the bridge between user-facing interfaces (chell, chili) and the underlying infrastructure (cumin and chrisapi).

Installation

npm install @fnndsc/salsa

Requires Node.js ≥ 20.12. Ships with TypeScript type definitions. Depends on @fnndsc/cumin.

Usage

import { files_listAll, fileContent_get, vfsDispatcher } from "@fnndsc/salsa";

// Salsa returns pure data / typed objects — no CLI dependencies
const listing = await files_listAll({ limit: 1000, offset: 0 }, "files", "/home/chris");
const content = await fileContent_get("/home/chris/uploads/notes.txt");

See Key Modules for the full intent catalogue.

Purpose

  • Consolidate Business Logic: Centralises intents such as "list directory", "upload file", "register plugin", "fetch feed note". All frontends share identical behaviour.
  • Frontend Agnostic: No CLI-specific dependencies (commander, process.stdout). Returns pure data or typed objects.
  • Virtual Filesystem: Owns the VFS dispatcher that maps ChRIS API resources onto Unix-style paths — see VFS below.

Architecture: The Sandwich Model

[ ChELL (REPL) ]  [ Chili (CLI) ]  [ Web App ]  [ Mobile App ]
       |                 |               |              |
       +-----------------+---------------+              |
                         |                              |
                         v                              v
              [      Salsa (Logic / Intents)        ]  <-- YOU ARE HERE
                         |
                         v
              [      Cumin (State / Infrastructure) ]
                         |
                         v
              [      @fnndsc/chrisapi (Client)      ]

Key Modules

Filesystem

FunctionDescription
vfsDispatcherRoutes list/read calls to the correct VFS provider by path prefix
files_listList a directory (paginated)
files_listAllFull directory listing (all pages)
fileContent_getRead remote file content
files_uploadPathUpload a local file or directory tree to ChRIS
files_touchCreate an empty file
files_mkdirCreate a directory
files_rmDelete a file or directory
files_cp / files_mvCopy / move

Plugins & Store

FunctionDescription
plugins_list / plugins_listAllFetch plugin list
plugin_checkExistsCheck if a plugin is already registered
plugin_registerWithAdminRegister a plugin via the admin endpoint
plugin_assignToComputeResourcesAssign plugin to compute environments
plugins_searchPeersSearch peer ChRIS stores (e.g. cube.chrisproject.org)
plugin_importFromStoreImport a plugin from peer store data
plugin_searchPeersByImageResolve a Docker image to a peer-store plugin

Feeds & Sub-resources

FunctionDescription
feeds_list / feeds_listAllFetch feeds
feedNote_get / feedNote_updateRead or update the singleton note on a feed
feedComments_listList comments on a feed
feedComment_create / feedComment_update / feedComment_deleteComment CRUD

Pipelines & Workflows

FunctionDescription
pipelines_listList registered pipelines
workflow_createInstantiate a pipeline as a workflow on a feed

Jobs (Plugin Instance Operations)

FunctionDescription
job_cancel(id)Cancel a running/scheduled instance (PUT {status: cancelled})
job_delete(id)Delete a terminal instance record
job_statusFetch(id)Live-fetch current status from API (bypasses cache)
job_logFetch(id)Fetch stdout/stderr log for an instance
procCache_refresh([feedID])Rebuild the /proc job cache, optionally scoped to one feed

Virtual Filesystem (VFS)

vfsDispatcher translates a ChRIS path into a provider call. Each provider handles a path prefix and maps API resources onto filesystem semantics:

Path prefixProviderBacked by
/home/<user>/HomeVfsProviderChRIS user-file API
/home/<user>/feeds/FeedVfsProviderFeed resources
/binBinVfsProviderRegistered plugins (virtual executables)
/usr/binUsrBinVfsProviderBuilt-in shell commands (whoami, whereami)
/etcEtcVfsProviderConfig files (compute.yaml, group, passwd, cube)
/net/pacs/queries/PacsVfsProviderPACS query results
/proc/jobs/ProcVfsProviderJob monitoring DAG (backed by ProcCache in cumin)
*.chrislinkresolved by dispatcherSymlinks to other ChRIS paths

Providers implement a common interface: list(path) → Result<VFSItem[]> and read(path) → Result<string>.

/proc/jobs/ — Job Monitoring

ProcVfsProvider mirrors the computation DAG of every visible feed. Each plugin instance is a directory; virtual files inside expose live status, params, and log:

/proc/jobs/feed_123/
├── status                  ← aggregate: running | finishedSuccessfully | finishedWithError
├── title
└── pl-dircopy_456/         ← type=job in VFSItem; ls -l shows colour-coded status
    ├── status              ← live API fetch if non-terminal
    ├── params              ← complete effective key=value run parameters, cached permanently
    ├── log                 ← never cached; decoded from CUBE's `raw` response
    └── pl-fshack_789/
        └── …

The cache (ProcCache in cumin) holds flat topology maps for O(1) lookup and O(depth) path reconstruction. The daemon restores this normalized graph from an identity-scoped local checkpoint, validates visible feeds, then reconciles only new, changed, and active feeds; proc refresh explicitly runs the paginated global CUBE sweep. Terminal status persists; active status remains live. Freshness is visit-driven: revisiting a feed merges the nodes created or finished since the last visit (min_end_date from a per-feed cursor) and re-sweeps the active ones, a settled feed is re-checked at most once per ten minutes, and a /proc/jobs visit picks up feeds newer than the highest known id (walking the whole index once the roster is ten minutes old). params reads the complete PluginInstance.parameters collection, rather than instance-detail metadata. Logs remain uncached: ChELL decodes CUBE's base64/zlib-compressed PluginInstance.raw response and reads compute.logs; it never fetches from a spoke.

Development

Build

npm run build

Test

npm run test

License

MIT — part of the ChRIS Project.


-30-

版本与发布记录

@fnndsc/salsa 共发布 56 个版本,首次发布于 2026/06/20;过去 12 个月发布了 56 个版本。

版本发布日期距今
4.5.7latest2026/11/16今天
4.5.62026/11/16今天
4.5.52026/11/15今天
4.5.42026/11/15今天
4.5.32026/11/151 天前
4.5.22026/11/141 天前

关于 @fnndsc/salsa 的常见问题

@fnndsc/salsa 是什么?

Shared Application Logic and Service Assets for ChRIS

如何安装 @fnndsc/salsa?

在项目目录运行 npm install @fnndsc/salsa,或使用 pnpm add / yarn add / bun add。

@fnndsc/salsa 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fnndsc/salsa 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@fnndsc/salsa 可以商用吗?

@fnndsc/salsa 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fnndsc/salsa 的下载量有多少?

根据 npm 官方下载统计,@fnndsc/salsa 在 2026/10/15 – 2026/11/13 这 30 天内被下载 5,206 次,日均约 174 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fnndsc/salsa 还在维护吗?

最新版本 4.5.7 发布于 2026/11/16(今天);至今共发布 56 个版本,其中过去 12 个月发布了 56 个;首次发布于 2026/06/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。