@skerry/shared

v0.8.3

Published

Shared TypeScript types and helpers for Skerry — the contract between the dive log's backend, frontend and any module that plugs into them.

Readme

@skerry/shared

The contract types for Skerry, a scuba dive logbook: Dive, GearItem, Kit, Certification, DiveSite, Buddy, User, the ApiResponse envelope, and the gear-schedule maths that the service reminders and the gear cards both need.

It is published so code outside this repository can implement Skerry's module contract against the same types the app itself uses — see DESIGN §14 for why the social layer lives in a separate repository.

npm install @skerry/shared
import type { Dive, ApiResponse } from '@skerry/shared'
import { gearDueDates } from '@skerry/shared'

Implementing a module

Three entry points. The root is dependency-free; the two contract subpaths pull in framework types, declared as optional peer dependencies so importing the root never obliges you to install them.

| Import | Contains | Needs | | --- | --- | --- | | @skerry/shared | Domain types + helpers | — | | @skerry/shared/module | SkerryModule, ModuleTable, ModuleContext | @types/express | | @skerry/shared/ui | SkerryUiModule, ModuleTab, ModuleSettingsSection | @types/react |

import type { SkerryModule } from '@skerry/shared/module'

export const socialModule: SkerryModule = {
  name: 'social',
  tables: [{ name: 'connections', sql: '…', backup: 'data', dependsOn: ['users'] }],
  register({ app, apiLimiter }) {
    /* mount your routes */
  },
}

ModuleTable.backup is required on purpose — a table that never says how it is treated by backup/restore is how data goes missing quietly. ModuleTab's icon is a type parameter, so it accepts any string here and the app narrows it to its own set.

Licensing

This package is MIT, deliberately — it is a contract, and anything that has to speak it should be able to without inheriting a copyleft obligation.

The rest of Skerry (the server and the web app) is AGPL-3.0-only. The two are not the same licence and that is on purpose; see the repository's LICENSE.

Stability

Pre-1.0 and versioned in lockstep with the application, so 0.1.x releases track the app rather than the contract. Pin a range you're comfortable with and read the release notes before bumping — types can change under 0.x.