@albertomarturelo/sii-core

中文文档
0.19.0发布于 2026/10/29MITTypeScriptES Module近 30 天下载 2366

Shared SII domain core: rut, config (prod hostnames), contracts, tasks, seams. A Node library; external side-effects (portal, secrets, audit, clock) are injected via seams (ADR-003).

原始使用文档
文档目录5 节
  1. Install
  2. Usage
  3. Injecting your own seams
  4. What's inside
  5. Releasing (maintainers)

@albertomarturelo/sii-core

The shared SII (Servicio de Impuestos Internos, Chile) domain core — the engine behind the sii CLI and the sii-mcp server. A Node library: every legal and operational guardrail (throttling, audit, credential handling, the operate-centric identity model) lives here, so a consumer that codes against the task layer gets the same rails the first-party surfaces do.

Open source (MIT). See ADR-018 and ADR-019. Published to the public npm registry. (Earlier 0.x releases were private on GitHub Packages under the @altumstack scope — ADR-015; superseded.)

Install

pnpm add @albertomarturelo/sii-core
# or: npm install @albertomarturelo/sii-core

zod comes along as a dependency. playwright is an OPTIONAL peer (ADR-016): only the default PortalDriver (the @albertomarturelo/sii-core/node subpath) needs it. If you use that default driver — i.e. you actually drive a real browser against SII — install it plus the Chromium binary once:

pnpm add playwright
pnpm exec playwright install chromium

If you inject your own PortalDriver (or only use the tasks/primitives), skip this entirely — nothing in the main barrel imports playwright or node:*.

Usage

A consumer builds a Runtime (the composition root that wires the Node default adapters, from the ./node subpath) and calls tasks — the public operations. Never reach past the task layer into a sub-module; that bypasses the guardrails (ADR-003).

import { authStatus, rcvSummary } from '@albertomarturelo/sii-core';
import { createNodeRuntime } from '@albertomarturelo/sii-core/node';

const runtime = createNodeRuntime();

// Who is the current session operating as? (pure-local read)
const status = await authStatus(runtime);

// Read the RCV compra summary for a period (body-RUT surface — `rut` optional).
const resumen = await rcvSummary(runtime, { periodo: '2026-05', side: 'compra' });
console.log(JSON.stringify(resumen, null, 2));

Tasks return plain JSON-serializable objects (no Date/Map/Set) — that is the library contract (ADR-012). Authentication is an explicit verb: tasks consume a live session or raise NotAuthenticated; only login mints one. Logging in opens a real browser where the user types their Clave (cookies-only; the password never crosses the library boundary — ADR-006).

Injecting your own seams

The external side-effects are interfaces (PortalDriver, KeyValueStore, AuditSink, Clock, …). createNodeRuntime accepts a Partial<Runtime> of overrides, so partial reuse is a supported path — e.g. Node defaults with your own audit sink and portal driver (an embedding app's mediated browser):

import { createNodeRuntime } from '@albertomarturelo/sii-core/node';

const runtime = createNodeRuntime({ audit: myAuditSink, portal: myPortalDriver });

In-memory fakes ship under testing so a consumer's tests never touch the real SII, keyring, or clock — assemble a Runtime from them:

import { testing, type Runtime } from '@albertomarturelo/sii-core';

const runtime: Runtime = {
  clock: new testing.FixedClock(new Date('2026-06-29T12:00:00Z')),
  audit: new testing.RecordingAuditSink(),
  store: new testing.InMemoryKeyValueStore(),
  portal: new testing.FakePortalDriver({ requestPublic: () => '<html>…</html>' }),
};

What's inside

  • auth / identity — single-account, operate-centric session model (ADR-005).
  • read surfaces — rcv, f22, f29, bte, dte (authorized, public).
  • primitives — Rut (Mod-11), Periodo / Anio, prod HOSTS, audit.

See docs/ARCHITECTURE.md and docs/ROADMAP.md for the full picture, and CHANGELOG.md for release notes.

Releasing (maintainers)

The core releases in lockstep with the CLI and MCP surfaces, from a v* tag, to public npm. The procedure is in the repo's CONTRIBUTING.md § Releasing.

版本与发布记录

@albertomarturelo/sii-core 共发布 20 个版本,首次发布于 2026/07/03;过去 12 个月发布了 20 个版本。

版本发布日期距今
0.19.0latest2026/10/299 天前
0.18.12026/10/299 天前
0.18.02026/10/2712 天前
0.17.02026/10/2612 天前
0.16.02026/10/2414 天前
0.15.02026/10/2415 天前

关于 @albertomarturelo/sii-core 的常见问题

@albertomarturelo/sii-core 是什么?

Shared SII domain core: rut, config (prod hostnames), contracts, tasks, seams. A Node library; external side-effects (portal, secrets, audit, clock) are injected via seams (ADR-003).

如何安装 @albertomarturelo/sii-core?

在项目目录运行 npm install @albertomarturelo/sii-core,或使用 pnpm add / yarn add / bun add。

@albertomarturelo/sii-core 支持 TypeScript 吗?

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

@albertomarturelo/sii-core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@albertomarturelo/sii-core 可以商用吗?

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

@albertomarturelo/sii-core 的下载量有多少?

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

@albertomarturelo/sii-core 还在维护吗?

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