Skip to content
Logic SDK
Esc
↑↓navigate↵open⌘Jpreview
On this page

CLI commands

List, inspect, and graph logic-sdk definitions from the terminal.

The logic-sdk CLI inspects definitions and their relationships.

npm install -D @logic-sdk/cli
npx logic-sdk list

Run from the app root. logic-sdk delegates to @logic-sdk/cli.

Command Result Flags
list Definitions, with unregistered ones separate. Omits registered events. --module <name>, --kind <kind>, --json
show <name> Details for one definition. --json
graph Runs, schedules, emits, and listens. --module <name>, --format text|mermaid|json
All Load environment files before imports. --env-file <path> (repeatable)

--kind accepts query, mutation, action, listener, cron, event, and error. The graph filter keeps edges touching the module.

Registry and environment

Input Rule
Registry Defaults to src/registry.ts. Set "logic-sdk": { "registry": "lib/registry.ts" } in package.json to change it.
Modules Reads createRegistry({ modules }) and follows imports and re-exports, including workspace packages.
Env files Loads .env, .env.local, then each --env-file. Later files win. Process variables take precedence.
Import failures app-load-failed includes the import error and any source location. Imports run top-level code.
Exit status 0 for success, 1 for load or read failure, 2 for usage errors.
Streams Data on stdout, diagnostics on stderr. Pipes disable color. JSON errors use { error: { code, message, fix } }.

List

Run bun run logic-sdk list in examples/bookings.

NAME                             KIND               POLICY   DESCRIPTION
properties.get                   query              anyone   Get a property by id
properties.create                mutation           owner    Add a property to the account
availability.check               query              anyone   Is a property free for a date range? Check-out day is free for the next check-in.
availability.block               mutation           owner    Block dates as the owner (personal use, maintenance)
availability.hold                mutation           none     Reserve a date range on a property's calendar
availability.release             mutation           none     Free every date held by a source (e.g. a cancelled booking)
pricing.priceStay                query              anyone   Price a stay: nights × nightly rate + cleaning fee. Enforces minimum nights.
enquiries.list                   query              agent    Enquiries for the account, newest first
enquiries.create                 mutation           anyone   A guest asks about a property
enquiries.markWon                mutation           none     An enquiry turned into a confirmed booking
bookings.get                     query              staff    Get a booking
bookings.cancel                  mutation           staff    Cancel a booking and free its dates
bookings.confirm                 mutation           staff    Confirm a pending booking: holds its dates and tells the other modules
bookings.request                 mutation           anyone   Request a booking. Prices it and checks the dates are free; nothing is held yet.
bookings.checkout                action             anyone   Charge the guest and confirm the booking; refunds if confirming fails
tasks.list                       query              agent    Open tasks for the account
tasks.create                     mutation           none     Create an operations task
bookings.(private) amountDue     query private      none     What the guest owes for a pending booking
bookings.(private) confirmPaid   mutation private   none     Confirm a booking the guest has just paid for
enquiries.winOnBooking           listener           -        Mark the enquiry won when its booking is confirmed
tasks.prepareStay                listener           -        Create the key-handover task and email the guest in their language
availability.datesUnavailable    error              -        conflict · raised by availability.block, availability.hold
pricing.minNights                error              -        rejected · raised by pricing.priceStay
bookings.alreadyCancelled        error              -        rejected · raised by bookings.cancel
bookings.datesUnavailable        error              -        conflict · raised by bookings.request
bookings.notPending              error              -        rejected · raised by bookings.confirm, bookings.(private) amountDue, bookings.(private) confirmPaid

26 of 26 · logic-sdk show <name> for details

Policy is a name, inline, or none. The scan skips tests and node_modules.

Show

Run bun run logic-sdk show bookings.confirm in examples/bookings.

bookings.confirm  mutation
Confirm a pending booking: holds its dates and tells the other modules
src/bookings/mutations.ts:37:14

policy      staff
input       { bookingId: uuid }
output      { id: uuid, propertyId: uuid, enquiryId: uuid | null, guestEmail: string, checkIn: string, checkOut: string, total: int, status: "pending" | "confirmed" | "cancelled" }
runs        availability.hold
emits       bookings.confirmed → enquiries.winOnBooking, tasks.prepareStay
fails with  bookings.notPending
            availability.datesUnavailable  via availability.hold
            bookings.confirm.forbidden, bookings.confirm.invalidInput, bookings.notFound
called by   nothing in this app (an entry point)
Row Meaning
checks Detected can* record checks.
config Read keys, without values.
runs Possible calls and visible scope changes.
when The listener filters its event.
fails with App and built-in codes. via marks nested calls. Omits nested invalidInput.
called by Definitions that run or schedule this function.

Graph

Run bun run logic-sdk graph in examples/bookings.

properties
├─ get     query
└─ create  mutation

availability
├─ check    query
├─ block    mutation
├─ hold     mutation
└─ release  mutation

pricing
└─ priceStay  query  runs properties.get

enquiries
├─ list          query
├─ create        mutation
├─ markWon       mutation
└─ winOnBooking  listener  on bookings.confirmed
                           runs enquiries.markWon

bookings
├─ get                    query
├─ cancel                 mutation  runs availability.release
│                                   emits bookings.cancelled → no listeners
├─ confirm                mutation  runs availability.hold
│                                   emits bookings.confirmed → enquiries.winOnBooking, tasks.prepareStay
├─ request                mutation  runs availability.check, pricing.priceStay
├─ checkout               action    runs bookings.(private) amountDue, bookings.(private) confirmPaid
├─ (private) amountDue    query
└─ (private) confirmPaid  mutation  runs availability.hold
                                    emits bookings.confirmed → enquiries.winOnBooking, tasks.prepareStay

tasks
├─ list         query
├─ create       mutation
└─ prepareStay  listener  on bookings.confirmed
                          runs tasks.create

ctx.schedule adds a schedules edge. JSON lists nodes and edges.

Static reading

  • Runtime. Imports supply registered names and JSON Schema. Source supplies private definitions.
  • Source. The CLI follows named helpers and definer aliases. Arbitrary callbacks can hide calls.
  • Possible edges. Computed targets can appear as (dynamic). Branches and caught errors can appear.

See also

Was this page helpful?