# `jadpo package`

Show, check, import and install packages.

`show <name>` prints a package's description, licence, version, kind and public surface (area 11), installed in packages/ or the app's own in shared/providers/; `show <name> <declaration>` prints one operation, function, type or failure in full with its file, and `--guide` prints the package's GUIDE.md. `check`, run in a package's own repository, checks it as the app's own integration, runs the publishing bar (no errors, a description on every public declaration, the examples in its descriptions run as tests, its tests, a version its changes since the last tag allow, a changelog that says why) and writes surface.jadpo_record and CHANGELOG.md's new section. `import openapi <file>` reads an OpenAPI 3 document, as JSON, once and offline, into the app's own integration in shared/providers/<name>/<version>/: another Jadpo application's exactly, from its x-jadpo fields, any other's by its formats, with what it leaves out listed to check; importing again merges, keeping corrections. `record <connection> <resource>.<operation>` calls the provider's sandbox once, never live, with `--input` as the operation's input, checks the answer against the operation's types and keeps it in the package's recordings/ with its values as placeholders; `jadpo test` and `check` then decode it with every decoder. `add` installs a package from its folder or from a git repository at a release tag (`<repository>@v<version>`) into packages/ and jadpo.lock, once its surface matches its code; `update` moves one to its newest release, listing what changed; `remove` takes out one the app no longer uses; `link` compiles the app against a package's live checkout, which CI refuses, and `unlink` goes back to the installed version. `recipe <package> <recipe> --into <domain>` copies one of a package's recipes into a domain, where it becomes the app's own code, never writing over a file it has.

Also: `jadpo packages`.

```text
jadpo package <action> [name] [declaration]
```

## Arguments

- `action`: What to do: show, check, import, record, conform, add, update, remove, link, unlink or recipe
- `name` (optional): The package, such as holidays; for check and link, its folder; for add, its folder or <repository>@v<version>; for import, openapi; for record, the connection; for conform and recipe, the package
- `declaration` (optional): One of its declarations, such as uk.dates; for import, the file; for record, the operation, as <resource>.<operation>; for conform, the capability, ai; for recipe, the recipe

## Flags

- `--guide`: Print the package's GUIDE.md
- `--as <name>`: For import: its name, such as Tidepool.v1
- `--input <json>`: For record: the operation's input as JSON
- `--live`: For conform: run it against the real API
- `--into <domain>`: For recipe: the domain it is copied into

## On every command

- `--json`: Print data for tools instead of text
- `--help`: Show every flag, with examples
- `--color <when>`: Choose when to use colour

`jadpo package --json` writes one JSON document to standard output instead of text, with the same exit code. The document has `schemaVersion`, `command` (`"package"`), `ok`, `data` (what the command produced, `null` when it failed) and `diagnostics` (each error with its `rule`, `reason`, `next` and `help`). A command that needs a terminal refuses `--json` and names the flags that do the same job.

## Examples

```text
# See what the holidays package offers
jadpo package show holidays
# See one of its functions in full
jadpo package show holidays uk.dates
# Run the publishing bar in a package's own repository
jadpo package check
# Import another Jadpo application's API
jadpo package import openapi ../orders/build/openapi/main.json
# Install a package from its git repository at a release
jadpo package add github.com/acme/holidays@v2.1.0
# Try the app against a package's checkout before it is released
jadpo package link ../holidays
# Copy a package's recipe into a domain
jadpo package recipe holidays closures --into scheduling
# Record a sandbox's answer to confirm an operation
jadpo package record holidays dates.list --input '{"year": 2027}'
```

## Errors

- [`cli.package_arguments`](../errors/cli.package_arguments.md): Package command has invalid arguments
- [`cli.package_not_openapi`](../errors/cli.package_not_openapi.md): Description to import is not an OpenAPI 3 document
- [`cli.package_unreadable`](../errors/cli.package_unreadable.md): Description to import could not be read as JSON
- [`recording.failed`](../errors/recording.failed.md): Sandbox or model gave no answer to record
- [`recording.refused`](../errors/recording.refused.md): Answer can't be recorded through this connection
- [`install.fetch_failed`](../errors/install.fetch_failed.md): Package's git repository or tag couldn't be read
- [`install.in_use`](../errors/install.in_use.md): Package to remove is still used by the app
- [`install.surface_mismatch`](../errors/install.surface_mismatch.md): Package's committed surface doesn't match its code
- [`package.name_taken`](../errors/package.name_taken.md): Package's name is already one of the app's
- [`publish.breaking_change`](../errors/publish.breaking_change.md): Package's surface breaks its last release within one major version
- [`publish.changelog_missing`](../errors/publish.changelog_missing.md): Package's changelog doesn't say why its new version is released
- [`publish.description_missing`](../errors/publish.description_missing.md): Package's public declaration has no description
- [`publish.example_failed`](../errors/publish.example_failed.md): Example in a package's description doesn't compile or doesn't hold
- [`publish.example_missing`](../errors/publish.example_missing.md): Package's function has no example, or a failure it raises is shown by none
- [`record.edited`](../errors/record.edited.md): Generated record was edited by hand
- [`test.failed`](../errors/test.failed.md): Test run failed
- [`toolchain.artifact_write_failed`](../errors/toolchain.artifact_write_failed.md): Generated file could not be written
- [`toolchain.not_built_yet`](../errors/toolchain.not_built_yet.md): Operation is declared but not built yet
- [`toolchain.project_not_found`](../errors/toolchain.project_not_found.md): Project could not be found
- [`toolchain.source_read_failed`](../errors/toolchain.source_read_failed.md): Jadpo source file could not be read
