# The manifest

> Every field of songstress.json, read from the SDK's own schema, and what a listing asks on top.

Page: https://songstress.app/docs/develop/manifest/

The manifest, `songstress.json`, sits at the root of your extension. It says what the extension is, what it adds to
Songstress, and what it may do. The tables on this page are the manifest's types in `songstress/manifest`, which
the SDK generates from its JSON Schema (`songstress/schema/extension.v1.json`), so they say exactly what a server
checks. Open a field to see its full type and what it means.

Point an editor at the schema and it checks the file as you type:

```json title="songstress.json"
{ "$schema": "https://songstress.app/schema/extension/v1.json" }
```

## The rules of the file [#the-rules-of-the-file]

- It is UTF-8 JSON, at most 256 KiB, with objects and lists nested at most 16 deep, and no key written twice in one
  object. No comments, no trailing commas, no byte-order mark.
- Every object is closed: a field the schema doesn't name is an error, not something ignored.
- Text is one line in one language, with no control character and nothing that draws nothing or turns the direction
  of text (`TEXT_UNSAFE`). The joiners and marks that scripts and emoji need are fine. Lengths count characters.
- Every path is a plain path from the package root with forward slashes, like `assets/icon.png`: no `.` or `..`, no
  leading or doubled slash, none of `\ : * ? " < > | % #`.

## The manifest's fields [#the-manifests-fields]

The songstress.json file at the root of an extension's package: what the extension is, how it is listed, the code it ships, the permissions it asks for and everything it adds to Songstress.

| Field | Type | Description |
|---|---|---|
| `$schema?` | `string \| undefined` | The address of this schema, so an editor can check the file as you type. |
| `manifestVersion` | `1` | The version of the manifest format. Always 1. |
| `id` | `string` | The extension's identity, as publisher.name. It never changes once the extension is installed anywhere. |
| `name` | `string` | The name people see. |
| `version` | `string` | The extension's own version, as a semantic version (1.4.0). A release is tagged with it. |
| `description` | `string` | One or two sentences on what the extension does, shown under its name. |
| `engines` | `Engines` | The extension API the extension was written for. |
| `license?` | `string \| undefined` | The licence of the extension's code, as an SPDX identifier (MIT, Apache-2.0). |
| `repository?` | `string \| undefined` | Where the source lives. |
| `sponsor?` | `Sponsor \| undefined` | Where people can support the author. |
| `categories?` | `Category[] \| undefined` | The one category the extension is listed under. |
| `keywords?` | `string[] \| undefined` | Free tags that help people find the extension. |
| `platforms?` | `Platform[] \| undefined` | The Songstress apps the extension's interface and client code work in. Left out, it means all of them. Code in the server entry reaches every app whatever this says. |
| `icon?` | `Icon \| undefined` | The extension's icon. |
| `banner?` | `Banner \| undefined` | The wide image on the extension's card. |
| `screenshots?` | `Screenshot[] \| undefined` | Captures of the extension at work. The official list asks for three to six. |
| `entry?` | `Entry \| undefined` | The extension's code: one JavaScript bundle for each side it runs on. |
| `hooks?` | `Hooks \| undefined` | The hooks the extension's code listens to. Songstress starts the code when one of them fires. |
| `permissions?` | `Permissions \| undefined` | What the extension asks to be allowed to do. Nothing is allowed unless it is asked for here and then granted by a person. |
| `contributes?` | `Contributes \| undefined` | What the extension adds to Songstress. |

### The id [#the-id]

`id` is `publisher.name`. Each part is lowercase letters, digits and single hyphens, 80 characters in all. A publisher
may not be named like a part of the API (`commands`, `hooks`, `host`, `jobs`, `library`, `listening`, `net`,
`network`, `player`, `providers`, `queue`, `routes`, `secrets`, `settings`, `storage`, `themes`, `ui`, `users`).
The publisher `songstress` is Songstress's own: a server installs a `songstress.*` id from the official list alone.

### Engines [#engines]

The extension API versions the extension runs on.

| Field | Type | Description |
|---|---|---|
| `songstress` | `string` | The versions of the extension API the extension runs on, as a range: ^1.2.0, ~1.2.0, >=1.2.0, >=1.2.0 <2.0.0 or one exact version. Never *. |

`^0.1.0` is the usual answer. A feature that came with a later API version asks for that version: a status item
needs `^0.1.4`, for example. See [Versions](/docs/develop/versions/).

### Images [#images]

Each image states its path and its real size in pixels. Whoever installs or lists the package holds the files to it.

The icon:

A square PNG of 512 by 512 pixels.

| Field | Type | Description |
|---|---|---|
| `path` | `string` | The PNG file, from the package root. |
| `width` | `512` | The image's width in pixels: 512. |
| `height` | `512` | The image's height in pixels: 512. |

The banner, the wide image of the extension's card:

A 16:9 image, from 1280 by 720 up to 3840 by 2160 pixels.

| Field | Type | Description |
|---|---|---|
| `path` | `string` | The PNG, JPEG or WebP file, from the package root. |
| `width` | `number` | The image's width in pixels. |
| `height` | `number` | The image's height in pixels. |

Each screenshot:

One capture, with the size it really has.

| Field | Type | Description |
|---|---|---|
| `path` | `string` | The PNG, JPEG or WebP file, from the package root. |
| `width` | `number` | The image's width in pixels. |
| `height` | `number` | The image's height in pixels. |
| `caption?` | `string \| undefined` | What the capture shows, also read aloud by screen readers. |
| `platform?` | `Platform \| undefined` | The app the capture was taken in. |

### Code [#code]

The extension's code: the bundle that runs on the server, the one that runs in the apps, or both.

| Field | Type | Description |
|---|---|---|
| `server?` | `string \| undefined` | The bundle that runs on the user's server, in a sandbox. It hears every app's plays and does the work that must go on while no app is open. |
| `client?` | `string \| undefined` | The bundle that runs inside an app while it is open, in a sandbox. It follows this device's player live. An app may not run client code at all: what must work everywhere belongs in the server entry. |

The events the extension's code listens to, by side.

| Field | Type | Description |
|---|---|---|
| `server?` | `ServerHook[] \| undefined` | Hooks the server entry listens to. |
| `client?` | `ClientHook[] \| undefined` | Hooks the client entry listens to. |

Whatever needs code needs its entry (`ENTRY_REQUIRED`), and an entry nothing would ever start is an error too
(`ENTRY_UNUSED`). See [Hooks](/docs/develop/hooks/).

### Permissions [#permissions]

`permissions` is an object keyed by the permission's name. Each one has a reason, which the person granting it reads.
See [Permissions](/docs/develop/permissions/).

What the extension may do, each with the reason it gives.

| Field | Type | Description |
|---|---|---|
| `network?` | `NetworkPermission \| undefined` | Reach the named public hosts. |
| `network.local?` | `LocalNetworkPermission \| undefined` | Reach targets on the user's own network. |
| `library.read?` | `Permission \| undefined` | Read the catalogue and hear when it changes. |
| `users.read?` | `Permission \| undefined` | Read members' ids and display names. |
| `listening.read?` | `Permission \| undefined` | Read a member's plays, what they are playing now and what they like. Each member grants it for themselves. |
| `player.control?` | `Permission \| undefined` | Start, pause, skip and seek the player of the device the code runs on, and add to its queue. |
| `providers?` | `Permission \| undefined` | Answer beside Songstress's own sources. |
| `routes?` | `Permission \| undefined` | Serve its own signed-in routes. |
| `jobs?` | `Permission \| undefined` | Run scheduled and background work. |
| `storage?` | `Permission \| undefined` | Keep its own data, under a quota. |
| `secrets?` | `Permission \| undefined` | Keep its own credentials, sealed. |

A permission with nothing more than its reason:

A permission with nothing more to name than why it is asked for.

| Field | Type | Description |
|---|---|---|
| `reason` | `string` | Why the extension needs this, in words the person granting it will read. |

`network`:

Reaching public hosts: why, and which hosts.

| Field | Type | Description |
|---|---|---|
| `reason` | `string` | Why the extension needs this, in words the person granting it will read. |
| `hosts` | `string[]` | The public hosts the extension may reach, over http or https. |

`network.local`:

Reaching the user's own network: why, and which targets.

| Field | Type | Description |
|---|---|---|
| `reason` | `string` | Why the extension needs this, in words the person granting it will read. |
| `targets?` | `string[] \| undefined` | The targets on the user's own network the extension asks for. Left out, the admin names them when granting. |

## What it contributes [#what-it-contributes]

Everything an extension adds is under `contributes`. An id there is lowercase letters, digits and single hyphens,
starts with a letter, is at most 40 characters, and is unique among its kind (`DUPLICATE_ID`). A title is 1 to 60
characters and a description 1 to 160. An `icon` names one from Songstress's icon set; a name an app doesn't know is
drawn as the extension's mark.

What the extension adds to Songstress: commands, menus, settings, pages, panels, status items, views, themes, providers, jobs, routes and a sign-in.

| Field | Type | Description |
|---|---|---|
| `commands?` | `Command[] \| undefined` | Named actions the extension's code carries out. |
| `menus?` | `Menus \| undefined` | Where the extension's commands appear in the apps. |
| `settings?` | `Setting[] \| undefined` | The settings Songstress draws and keeps for the extension, in the order they are shown. |
| `pages?` | `Page[] \| undefined` | Pages the apps draw from a tree of Songstress's own components. |
| `panels?` | `Panel[] \| undefined` | Sections drawn inside Songstress's own screens. |
| `status?` | `StatusItem[] \| undefined` | Status items in the player: an icon and a few words each, the extension's state at a glance. |
| `views?` | `View[] \| undefined` | Free-form pages: the extension's own HTML, opened in the browser apart from the app, with no API. An app may not open them at all. |
| `themes?` | `Theme[] \| undefined` | The themes the extension adds to the picker: each a dark look, a light one, or both. |
| `providers?` | `SourcesByKind \| undefined` | Sources the extension adds beside Songstress's own, by kind. |
| `jobs?` | `Job[] \| undefined` | Scheduled and background work, shown in Activity. |
| `routes?` | `Route[] \| undefined` | Signed-in JSON routes under the extension's own prefix. |
| `signIn?` | `SignIn \| undefined` | A sign-in to the service the extension reaches, which a person starts and ends in Songstress. |

Each kind has its own page: [commands, menus and settings](/docs/develop/commands/),
[pages, panels, status items and views](/docs/develop/interface/), [themes](/docs/develop/themes/),
[providers](/docs/develop/providers/), and jobs, routes and sign-in in [the host API](/docs/develop/api/).

## Install and listing [#install-and-listing]

One validator checks a manifest everywhere: in your editor's tools, when a server installs, when a listing is
submitted. It has two profiles.

- **`install`** is what a server takes from a GitHub link or a file. Everything above.
- **`listing`** is what the official list and the Marketplace ask on top: a `license` (one of `MIT`, `Apache-2.0`,
  `BSD-2-Clause`, `BSD-3-Clause`, `ISC`, `0BSD`, `MPL-2.0`, `LGPL-3.0-only`, `LGPL-3.0-or-later`,
  `GPL-3.0-only` or `GPL-3.0-or-later`), a `repository` at `https://github.com/owner/name`, one category, the icon,
  and three to six screenshots.

`songstress check --profile listing` tells you what a listing still needs. Every code it can report is in
[Validation codes](/docs/develop/validation/).

From API 0.1.8, an extension with a `play` or `download` provider may be listed like any other. Both kinds stay
switched off on a server until its admin turns each one on.

## Check it from code [#check-it-from-code]

`songstress/manifest` runs anywhere JavaScript does, with no host:

```ts title="check.ts"
import { parseManifest } from 'songstress/manifest'

declare const bytes: Uint8Array // the file's bytes, as read from disk

const result = parseManifest(bytes, { profile: 'install' })
if (result.valid) {
  console.log(result.manifest.id)
} else {
  for (const issue of result.issues) console.log(issue.code, issue.pointer, issue.message)
}
```

`parseManifest` takes the file's bytes (best: only they can show a file that isn't UTF-8) or its text, and
`validateManifest` a value that is already parsed. `apiVersion`, when given, is the API version of the host that is
checking: a manifest whose `engines.songstress` leaves it out is refused. Each issue has a stable code, a JSON
Pointer to where it is, and a sentence. The code and the pointer are the contract; the sentence may be reworded.
