Skip to content

Comments

v3.0.0: Full TypeScript rewrite#78

Draft
kwent wants to merge 2 commits intomasterfrom
3.0.0
Draft

v3.0.0: Full TypeScript rewrite#78
kwent wants to merge 2 commits intomasterfrom
3.0.0

Conversation

@kwent
Copy link
Owner

@kwent kwent commented Feb 21, 2026

Summary

Full rewrite of syno from CoffeeScript to modern TypeScript for v3.0.0.

  • TypeScript (strict) with ESM + CJS dual output via tsdown
  • Native fetch (Node 24+) replaces deprecated request package
  • Async/await only — callbacks removed entirely
  • Proxy-based dynamic methods — replaces new Function() + __proto__ mutation
  • Real DSM 7.x API definitions — 778 APIs extracted from encrypted SPK packages
  • Synology Photos stationSYNO.Foto.* / SYNO.FotoTeam.* for DSM 7.x
  • Two-factor auth (OTP), session reuse, binary response handling, per-request API version override
  • Automated SPK fetcher (scripts/fetch-definitions.ts) — downloads, decrypts (XChaCha20-Poly1305), extracts definitions
  • CLI rewrite with Commander v12
  • CI workflow (lint, typecheck, test, build) + Dependabot + branch protection
  • Runtime deps: 3 (down from 9) — commander, js-yaml, pluralize

Bug Fixes

  1. SurveillanceStation error resolver — CoffeeScript or bug (always truthy)
  2. SID stored as string instead of object (caused re-auth every call)
  3. CLI missing process.exit(1) on unknown method
  4. CLI program.parse called twice

Breaking Changes

  • Node 24+ required
  • Callbacks removed (async/await only)
  • Browser support dropped
  • DSM 5.x support dropped
  • Default API version changed from 6.0.2 to 7.2

Closes

#73, #72, #75, #77, #42, #40, #29, #48, #39, #41

Test plan

  • npm run typecheck — zero errors
  • npm run lint — zero errors
  • npm run build — produces dist/index.js, dist/index.cjs, dist/index.d.ts, dist/cli.cjs
  • npm test — 89 tests pass
  • CJS import works: node -e "const { Syno } = require('./dist/index.cjs')"
  • ESM import works: node -e "import('./dist/index.js')"
  • CLI works: node dist/cli.cjs --help
  • Test against live DSM 7.x NAS

PLAN.md outlines the full rewrite from CoffeeScript to TypeScript:
tsdown build, native fetch, async/await, Proxy-based dynamic methods,
Vitest tests, Node 24+, and reduction from 9 to 3 runtime deps.
- Rewrite CoffeeScript → TypeScript (strict, ESM + CJS dual output)
- Replace `request` with native `fetch` (Node 24+)
- Async/await only, callbacks removed
- Proxy-based dynamic method generation (replaces `new Function()` + `__proto__` mutation)
- Add DSM 7.x API definitions (778 APIs extracted from real SPK packages)
- Add Synology Photos station (SYNO.Foto / SYNO.FotoTeam) for DSM 7.x
- Add two-factor auth (OTP), session reuse, binary response handling
- Add automated SPK fetcher (scripts/fetch-definitions.ts)
- CLI rewrite with Commander v12, single parseAsync()
- Fix SurveillanceStation error resolver CoffeeScript `or` bug
- Fix SID stored as string instead of object (re-auth every call)
- Fix CLI missing process.exit(1) on unknown method
- Drop browser support, DSM 5.x support
- Runtime deps: 3 (down from 9)
- Add CI workflow, Dependabot config, branch protection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant