# 5. Building tools for Blackslate

This chapter is for the AI that writes a tool, and for the person who asks it. A Blackslate tool is **one self-contained HTML file**.
When it runs inside Blackslate, it gets an object `window.leavenit` to save data and to work with tables. Outside Blackslate, the same file must still work.

## 5.1 The rules of the tool page

Blackslate runs every tool in a sealed frame on another domain (leavenit-tools.com). What this means for the code:

| Rule | Detail |
|---|---|
| One HTML file | HTML, CSS and JavaScript in the same file. No local files next to it. |
| No network | `fetch`, `XMLHttpRequest`, WebSocket, EventSource and WebRTC don't work. The tool can't call any API. Data comes from the person, from `window.leavenit`, or from files they pick. |
| Libraries from 4 CDNs only | `<script src>` from `https://cdnjs.cloudflare.com`, `https://cdn.jsdelivr.net`, `https://unpkg.com`, `https://esm.sh`. Styles from cdnjs, jsdelivr and `https://fonts.googleapis.com` (fonts from `fonts.gstatic.com`). |
| Images | only `data:` and `blob:` (embed small images as data URLs, or draw them with SVG/canvas). Remote image URLs are blocked. |
| No dialogs | `alert()` shows a small notice, `confirm()` always returns `false`, `prompt()` returns `null`. Show messages and confirmations inside the page instead. |
| No Web Workers | `new Worker()` is blocked. Do the work on the main thread, in small steps if needed. |
| Forms | `<form action>` is blocked; handle submit events in JavaScript. |
| Downloads | a link `<a download href="blob:…">` or a data URL works (20 MB maximum per file); Blackslate asks the person to confirm. |
| Links | `mailto:`, `sms:`, `tel:`, `https://wa.me/…` open the person's apps; other `https://` links open in a new tab after a confirmation; `window.leavenit.open(url)` from a click. See chapter 9. |
| Vibration, sound, screen | `navigator.vibrate`, sounds without a fresh tap and the screen wake lock are blocked inside the tool. Use `window.leavenit.alert()` (vibrates on Android, plays a short sound; resolves with `{ vibrated, sound }`; at most one every 2 seconds) and `window.leavenit.keepAwake(true)` / `keepAwake(false)` (keeps the screen on while the tool shows; resolves with `{ awake }`). The sound works once the person has tapped in the tool at least once (starting a timer); iPhones can't vibrate from a web page, so also show the alert on screen. **Even with the screen off or the tool closed**: `window.leavenit.alert.at(when, text)` sends the person a notification at that time (a `Date`, a timestamp or an ISO date; 5 seconds to 7 days ahead, 200 characters; within about 10 seconds), on their devices with notifications on (**Settings → Notifications on this device**). It resolves with `{ scheduled, id, at, devices }` (`devices` 0: notifications aren't on anywhere; tell the person) or `{ scheduled: false, reason }`; `alert.cancel(id)` cancels it (a paused or reset timer), `alert.list()` lists those waiting. Only for a signed-in person, in a saved tool, and only for themselves. Browser notifications (`Notification`) don't work inside a tool: use this instead. |
| `localStorage` | works, and Blackslate saves it for the person automatically. Prefer `window.leavenit` for anything that matters (versions, sharing). |

## 5.2 Saving data: `window.leavenit`

```js
const lv = window.leavenit;   // undefined when the file is opened outside Blackslate
```

All methods return Promises.

| Method | Does |
|---|---|
| `lv.get(key, options?)` | the saved value, or `null` |
| `lv.set(key, value, options?)` | saves a value (anything JSON can hold: 1 MB maximum for personal data, 256 KB for shared data) |
| `lv.delete(key, options?)` | removes it |
| `lv.list(prefix?, options?)` | every key starting with `prefix`: `[{ key, value, updated_at }]` (personal) or `[{ key, value, version, updatedAt, updatedBy }]` (shared) |

- **Keys**: 1 to 200 characters. Use prefixes to group them: `notes/2026-10-27`, `settings`.
- **Pace**: about 20 requests per second at most; beyond, calls fail with `rate_limited`. Save on change with a short delay, not on every keystroke.
- **Never rename a key** once people use the tool: their data stays under the old key. Add a `schema_version` field inside values to migrate formats.
- `lv.connected` is `true` when the person is signed in and the data is saved on Blackslate; `false` for a visitor (data then lives in memory only, until the page closes).
- `lv.version` is the version of this interface (currently `1`).

### Personal and shared data

By default, data belongs to the person (`scope: 'me'`). When the tool is opened inside a **shared folder**, it can also use the data of that folder, shared by its members:

```js
await lv.set('menu', items, { scope: 'shared' });
const menu = await lv.get('menu', { scope: 'shared' });
```

`lv.context` tells where the tool is opened:

```js
// { type: 'me' }   or
// { type: 'group', group: { id, name, role, memberCount }, space: { id, name }, permission: 'read' | 'write', canWrite: true | false,
//   role: 'manager' | 'editor' | 'viewer' }
if (lv.context.type === 'group' && !lv.context.canWrite) hideEditButtons();
if (lv.context.role === 'manager') showManagerControls();   // approve, assign, see everyone's answers…
```

**A sold tool** (chapter 2.9): `window.leavenit.context.access` is the person's access, `{ level: 'Pro', until: '2026-12-08' }` (`until` null: for life; `{ level: 'maker' }` for its makers). Use it to show what the level includes; the published tables reserved to a level answer `forbidden` to the others: that, not the tool's code, is the protection.

`lv.context.user.name` is the signed-in person's name, as their colleagues see it (to sign a note or a request); there is no `user` for a visitor.

`lv.context.role` is the person's role in the shared folder: `'manager'` (**Can manage**, or the owner), `'editor'` (**Can edit**) or `'viewer'` (**Can view**). Use it to show what only managers do; Blackslate checks it again on every change, so hiding a button is only for comfort.

### Not overwriting someone else's change

For **shared** values that several people edit (these options apply to `scope: 'shared'` only), read with `withMeta`, then write with `ifVersion`:

```js
const cur = await lv.get('menu', { scope: 'shared', withMeta: true });   // { value, version, updatedAt, updatedBy }
try {
  await lv.set('menu', updated, { scope: 'shared', ifVersion: cur.version });   // returns { version }
} catch (e) {
  if (e.code === 'conflict') showMessage('Someone changed the menu. Reload to see their version.');
}
```

For shared data, `lv.list(prefix, { scope: 'shared', limit, after })` pages through long lists (`limit` up to 1000, `after` = the last key received).

### Private values in a shared folder

Some answers are for the managers' eyes only: a member's availability, a request, a personal note to the organisers. Add `private: true`:

```js
const P = { scope: 'shared', private: true };
await lv.set('availability', { days: ['sat', 'sun'] }, P);   // only this person and the managers can read it
const mine = await lv.get('availability', P);                 // each person reads their own
```

- **Each person has their own value under the same key**: ten members can each save `availability` without overwriting each other. Only its author writes it.
- **Managers read them all**: `lv.list('availability', P)` returns, for a manager, every member's value, each with `owner` (the person's id), `ownerName` and a `cursor`; for a member, only their own. To read the next page, pass `after: lastItem.cursor` (not the last key: one key comes back once per person).
- A manager reads or deletes one person's value with `owner`: `lv.get('availability', { ...P, owner: id })`, `lv.delete('availability', { ...P, owner: id })`. A member who tries gets `forbidden`.
- `withMeta` and `ifVersion` work the same way. Private values count in the folder's limits like the others.
- `private` has no effect with `scope: 'me'`: personal data is already private.

### The fallback to use in every tool

```js
const store = window.leavenit ?? {
  get: async (k) => JSON.parse(localStorage.getItem(k) ?? 'null'),
  set: async (k, v) => localStorage.setItem(k, JSON.stringify(v)),
  delete: async (k) => localStorage.removeItem(k),
  list: async (p = '') => Object.keys(localStorage).filter((k) => k.startsWith(p)).map((k) => ({ key: k, value: JSON.parse(localStorage.getItem(k)) })),
};
```

### Without a connection

When the network drops (a basement, a market, a train), the tool keeps working with its data:

- **Writes are never lost.** `set`, `delete` and the tool's `localStorage` are kept on the device as soon as they're made, then sent in order when the connection is back, or when the tool is opened again if the tab was closed. Several writes of the same key go as one.
- `set` with `scope: 'shared'` then answers `{ version: null, queued: true }` instead of the new version. `get`, `list` and `localStorage` show the tool's own waiting writes straight away.
- Reading something else without a connection fails with `offline`: show what the tool already has, and read again later (`onChange` says when something changed).
- A write Blackslate refuses when it finally arrives (`conflict` with `ifVersion`, `read_only`, `quota_exceeded`…) isn't retried forever: the person sees a message, and the tool is told with `onSync`:

```js
lv.onSync(({ pending, offline, failed }) => {
  // pending: writes still waiting on this device; offline: no connection right now
  // failed: [{ scope: 'shared' | 'me' | 'localStorage', key, op: 'set' | 'delete', code, message }]
  for (const f of failed) if (f.code === 'conflict') reloadAndShow(f.key);   // someone changed it meanwhile
});
```

- The page shows it too: in the **⋯** menu, "Offline · 3 changes kept on this device", or "1 change not saved".
- Waiting writes belong to the account: signing out of Blackslate erases them on that device.
- **Opening without a connection**: a tool already opened on a device opens again on it offline, on the data it last read: `get` and `list` give their last answer kept on the device (with the tool's waiting writes on top), and `localStorage` is as it was last on that device. What was never read on that device answers `offline`. The libraries the tool loads from cdnjs, jsdelivr or unpkg come with it (not modules that import others, such as esm.sh); Google fonts fall back to a system font.
- Tables and files work offline too (5.5 and 5.3, "Without a connection"). The inbox, e-mails and calendars still need a connection.

### Errors (`e.code`, `e.message`)

| Code | Meaning |
|---|---|
| `offline` | no connection: this can't be read right now (writes are kept and sent later) |
| `no_group_context` | `scope: 'shared'` used outside a shared folder |
| `not_member`, `forbidden` | the person lost access to the folder |
| `not_linked` | the tool isn't linked to this data area |
| `read_only` | the person (or this tool) can only read here |
| `space_suspended` | the folder is scheduled for deletion |
| `conflict` | the value changed since it was read (`ifVersion`) |
| `quota_exceeded` | the data area is full |
| `rate_limited` | too many requests: wait a moment |
| `invalid_key`, `invalid_value` | key not 1–200 characters, or value not savable (or over 1 MB) |

### Counting what people do: `window.leavenit.track`

Blackslate counts, for the tool's makers, how many people open it, from where, on what, and the errors it doesn't catch (workshop, 3.11). To also see what people **do** in it, the tool names its main actions:

```js
document.getElementById('pdf').addEventListener('click', () => {
  makePdf();
  window.leavenit?.track('quote_pdf');   // counted for the makers: how many times, how many people
});
```

- **Names**: 1 to 40 characters, letters, digits, `_`, `.` and `-` (`quote_pdf`, `client_added`, `step.2`). A name is a kind of action, never a person's data: no name, e-mail or amount inside it.
- **Limits**: 50 different names per tool (the others aren't counted), 1,000 actions per person and per day. `track` returns nothing and never fails: a wrong name is ignored.
- **Errors**: nothing to write. An error the tool doesn't catch (and a rejected Promise nobody handles) is counted with its first line, e-mail addresses and long numbers removed. Errors from `window.leavenit` that carry an `e.code` (`offline`, `conflict`…) aren't counted: the tool handles them.
- Nothing is counted for the tool's makers, offline, or in **Try it** before saving.

## 5.3 Files: `window.leavenit.files`

Photos, PDFs and other files go here, **not inside a value or a table** (a table is downloaded whole on every read). Available when the person is signed in.

```js
const f = await leavenit.files.put(fileFromInput, { scope: 'shared' });   // { id, name, type, size, scope }
await leavenit.set(`recipes/${recipeId}/photo`, f.id, { scope: 'shared' }); // keep the id, not the file
img.src = await leavenit.files.url(f.id);                                 // a blob: URL, ready for <img>
const blob = await leavenit.files.get(id);                                 // the file itself
await leavenit.files.delete(id);
const list = await leavenit.files.list({ scope: 'shared' });               // [{ id, name, type, size, created_at }], newest first
```

- `scope`: `'me'` (only this person; the default) or `'shared'` (members of the shared folder the tool is opened from; writing needs the right to edit).
- **Private files** (`{ scope: 'shared', private: true }`): only the person who sent it and the folder's managers can read it (a receipt, a document for the organisers). `files.list({ scope: 'shared' })` doesn't show them; `files.list({ scope: 'shared', private: true })` gives a member their own and a manager everyone's, each with `owner` and `ownerName`. `info` says `private: true`. Only the sender or a manager can delete one; others get `not_found`, as if it didn't exist.
- **Photos are shrunk before sending** (longest side 1600 px, JPEG): a phone photo of several MB becomes a few hundred KB. Options: `{ shrink: false }` to keep the original, `{ maxSize: 800 }` for smaller pictures.
- Types: JPEG, PNG, WebP, GIF, PDF, text, CSV, JSON. 10 MB at most per file (after shrinking).
- **A file never changes**: to replace one, `put` the new one, save its id, then `delete` the old one. A file read once stays in memory for the session, so showing it again is instant.
- Files count in the same storage limit as tables (500 MB per person in Blackslate's storage); a folder connected to its owner's own storage keeps its files there.
- Errors (`e.code`): `file_type_not_allowed`, `file_too_large`, `owner_quota_exceeded`, `read_only`, `not_found`, `no_group_context` (`'shared'` outside a shared folder), `upload_failed`, `download_failed`, `rate_limited`.

**Without a connection** (a site, a cellar, a market):

- `files.put` answers at once with the file's **final id**, chosen on the device: keep it in your data as usual (`lv.set(…, { photo: f.id })`). The answer says `queued: true`; the file leaves when the connection is back, **before** the writes made after it. Up to 50 MB of files waiting per account on a device (`offline_full` beyond).
- On that device, `files.get` and `files.url` show it at once; on other devices it appears once sent. A file opened on a device is kept on it (100 MB per account, the least recently used go first): it opens again without a connection. Another file answers `offline`.
- `files.list` gives its last answer kept on the device, with the files still waiting first (`pending: true`); `info` likewise. Deleting a file still waiting just cancels sending it; deleting another file needs the connection.
- A file refused when it arrives (folder full, rights removed meanwhile) is reported by `lv.onSync` with `scope: 'file'`, its name as `key`, its `id` and the `code`: offer to take it again.

## 5.4 Inbox and public link: `window.leavenit.inbox`

For people **outside the folder** (customers, guests, members of an association) to send something: an order, a booking, a sign-up, a message. The folder's members create a **public link** to the tool (Workshop → **⋯** on the tool → **Public link…**). Anyone with the link opens the tool **without an account**, in **visitor mode**: `window.leavenit.context.type === 'visitor'`. A visitor can only **send** and ask whether keys are **taken**; nothing else in `window.leavenit` works for them (no data, no tables, no files). One tool usually has two faces: the form for visitors, the list for members.

```js
const lv = window.leavenit;
if (lv?.context?.type === 'visitor') {
  // the form
  const taken = await lv.inbox.taken(['slot:2026-11-03T19:00', 'slot:2026-11-03T19:15']);   // [true, false]
  try {
    await lv.inbox.send({ name, phone, pizzas, slot }, { unique: `slot:${slot}` });            // a few tenths of a second
    showThanks();
  } catch (e) {
    if (e.code === 'taken') showMessage('This time was just taken. Choose another.');
    else showMessage(e.message);
  }
} else {
  // the members' screen
  const items = await lv.inbox.list({ status: 'new' });      // [{ id, data, unique, status, created_at, link }], newest first
  await lv.inbox.mark(items[0].id, 'done');                   // 'new' → 'seen' → 'done', or 'rejected'
  await lv.inbox.delete(items[0].id);
}
```

- `send(data, { unique })`: `data` is an object of at most 32 KB (no files). With `unique`, **only one living request per key** is accepted, at the moment it is sent; the second one gets `taken`. Rejecting (`mark(id, 'rejected')`) or deleting a request frees its key.
- `taken(keys)`: up to 200 keys; returns `true`/`false` for each, nothing more.
- `list({ status, limit, before })`, `mark(id, status)`, `delete(id)`: members only, with the folder's rights (reading needs access, changing needs the right to edit).
- Sending takes a few tenths of a second: the visitor's browser solves a small proof of work, checked by Blackslate, against mass spam. Show "Sending…" meanwhile. There are also limits per link (per minute and per day) and on waiting requests.
- Members get a notification (at most one per link every 10 minutes) when something arrives.
- Errors (`e.code`): `taken`, `rate_limited`, `invalid_value`, `not_found` (the link was turned off or changed), `only_members`, `only_visitors`, `read_only`.
- Never ask visitors for passwords, card numbers or health data; for a payment, show a payment link (chapter 9).

### The showcase: `window.leavenit.public`

What visitors may **read**: nothing is public except what the tool publishes on purpose, as small values (a menu, opening hours, free slots of the day). The same public link is used to read the showcase and to send to the inbox; a tool can do either or both.

```js
// members (the right to edit the folder): publish
await lv.public.set('menu', { pizzas: [{ name: 'Margherita', price: 11 }] });
await lv.public.set('hours', { tuesday: '18:30-22:00' });
await lv.public.delete('promo');

// everyone (visitors with the link, and members)
const menu = await lv.public.get('menu');          // the value, or null
const all = await lv.public.list();                // [{ key, value, updated_at }]; list('slots/') for a prefix
```

- 64 KB per value, 100 values per tool and folder; text and numbers only (for photos, publish files, below).
- Publish again whenever the private data changes (for example after editing the menu), so the showcase stays current.
- The **Public link** panel lists everything published, with **Unpublish**.

**Photos and documents in the showcase.** A member sends the file with `files.put` (5.3), then publishes it under a name:

```js
// members: publish a photo already sent to the folder ({ scope: 'shared' }, not private)
const f = await lv.files.put(photo, { scope: 'shared' });
await lv.public.setFile('pizza-regina', f.id);
await lv.public.deleteFile('pizza-regina');        // unpublish (the file itself stays)

// everyone (visitors with the link, and members)
img.src = await lv.public.fileUrl('pizza-regina'); // an address for <img>, or null; kept for the session
const pdf = await lv.public.file('menu-pdf');      // a Blob, or null
const list = await lv.public.files();              // [{ key, name, type, size, updated_at }]; files('pizza-') for a prefix
```

- Only a file of this folder that isn't private can be published; up to 50 files per tool and folder. Deleting the file removes it from the showcase.
- Cutting or changing the public link cuts access to the files too. Like the values, what is published is public: someone who kept a file's exact address can see it again while the tool has an active link.

### Sending e-mails: `window.leavenit.mail`

A tool can send an e-mail (an order confirmation), now or later (a reminder the day before an appointment). The folder's **Runner** sends it with the owner's own mail account (chapter 7.9); Blackslate doesn't send e-mails for tools.

```js
try {
  // now
  await lv.mail.send({ to: order.email, subject: 'Your order', text: 'Hello,\nyour pizza is ready at 7:30 pm.', replyTo: 'contact@pizzeria.fr' });
  // later: the day before the appointment, at 6 pm (the person's local time); keep the id with the booking
  const r = await lv.mail.send({ to: booking.email, subject: 'Reminder: your appointment tomorrow', text: '…', at: '2026-11-03T18:00' });
  booking.reminderId = r.id;   // { id, status: 'scheduled', sendAt, to, subject, from, runnerOnline }
} catch (e) {
  if (e.code === 'no_mail_runner') showMailtoLink(order);   // no Runner sends e-mails here: offer a prepared e-mail (chapter 9.2)
}
await lv.mail.cancel(booking.reminderId);           // the appointment is cancelled: so is its reminder
await lv.mail.status(id);                           // { status, error, sendAt, createdAt, sentAt }
await lv.mail.list({ status: 'scheduled' });        // this tool's e-mails to come, soonest first (also 'sent', 'failed', 'cancelled'…)
```

- `at`: a `Date`, a number (milliseconds) or a date and time like `'2026-11-03T18:00'`, read in the person's local time (a date alone is local midnight). Up to 400 days ahead; a time already past is refused (`send_at_past`), so the tool decides whether to send now instead.
- Status: `scheduled` (waiting for its time), `queued`, `sending`, `sent`, `failed` (with `error`), `cancelled`. `cancel` works until the e-mail leaves (`not_cancellable` after); any member who can edit the folder can cancel. `list` gives `to` and `subject`, so it's for members who can edit too; page with `cursor` (the `sendAt` of the last one).
- Members who can edit the folder only; visitors of a public link get `only_members`.
- Plain text (`text`, up to 20 KB); `subject` up to 200 characters, on one line; one address in `to`. `replyTo` is optional.
- Up to 200 e-mails a day per folder, and 2,000 waiting (`mail_quota` beyond).
- The Runner must be on at the time: an e-mail it couldn't send within 24 hours of its time fails (`expired`), as does one the mail server refuses. **The person who asked for it is told** (a notification, also by e-mail and push, in **Flows and Runners**), and the tool finds it with `list({ status: 'failed' })`.
- Errors: `no_mail_runner` (no Runner set up for e-mail in this folder), `invalid_address`, `invalid_value`, `send_at_past`, `send_at_too_far`, `not_cancellable`, `mail_quota`, `read_only`.
- Send only to people who expect it, about what they asked for: what the Runner sends engages the folder owner.

### Seeing other people's changes: `window.leavenit.onChange`

When someone else changes something (an order arrives, a volunteer takes a slot, a manager approves a row), people who have the tool open see it without reloading:

```js
const stop = lv.onChange((c) => {
  // c = { data, me, tables: ['orders'], inbox, files, public }: what changed since the last look
  if (c.inbox) refreshOrders();             // read again what you show: lv.inbox.list(…)
  if (c.tables.includes('orders')) refreshTable();
  if (c.data) refreshSettings();            // shared values (lv.get(…, { scope: 'shared' }))
});
// stop() when the screen that needs it closes
```

- About every **3 seconds** while the page is visible; nothing while it's hidden, and a look right away when the person comes back. Changes are grouped: one call can say several things changed.
- Fields: `data` shared values (and the private ones this person can read), `me` this person's own values (changed on another device), `tables` the names of the tables that changed, `inbox` the inbox (a new request, a status), `files` the files, `public` the showcase. Each is `true`/`false`, `tables` a list.
- It only says **what** changed, never the content: read it again with the usual functions. It only tells a person about what they can read: a member isn't told when another member writes their own rows of a protected table, or a private value.
- The person's own changes come back too: make the refresh harmless (read and show again).
- **Visitors** of a public link get `public` (the showcase changed) and `inbox` (a unique key was taken, for example a slot): refresh the free slots with `inbox.taken(keys)`.
- `localStorage` is loaded when the tool opens: a value changed on another device appears there at the next opening. For values that change while the tool is open, use `lv.get` / `lv.set`.

### Calendars to subscribe to: `window.leavenit.calendar`

A tool can publish events to a **calendar feed** (the gîte's bookings, the week's lessons) that people add to Google Calendar, Apple Calendar or Outlook. Members who can edit the folder publish; the subscription address is made in Workshop (**⋯** of the tool → **Public link** → **Calendars**).

```js
// an all-day stay: from the arrival day to the departure day (end = the day after the last night, as in calendars)
await lv.calendar.set('booking-42', { title: 'Booked', allDay: true, start: '2026-11-07', end: '2026-11-10' }, { feed: 'planning' });
// a lesson at a time (the person's local time, like mail's at); without end, one hour
await lv.calendar.set('lesson-12', { title: 'Yoga, beginners', start: '2026-11-03T18:00', end: '2026-11-03T19:30', location: 'Room 2' }, { feed: 'lessons' });
await lv.calendar.delete('booking-42', { feed: 'planning' });   // cancelled: remove it
const events = await lv.calendar.list({ feed: 'planning' });
const url = await lv.calendar.feedUrl({ feed: 'planning' });   // https://leavenit.com/cal/….ics, or null until it's made in Workshop
```

- The tool chooses what goes in the feed: keep the full booking in its data, and publish only the title, dates and place to show. Each event has an id the tool picks (setting it again updates it in subscribed calendars).
- `feed`: 1 to 40 lowercase letters, digits, `-` or `_`; `'main'` by default. Up to 20 feeds per tool and folder, 2,000 events per feed; the feed shows the last 60 days and the next 400.
- `title` up to 200 characters, `location` 200, `description` 2,000. Errors: `invalid_date`, `invalid_feed`, `invalid_value`, `quota_exceeded`, `read_only`.
- **Anyone with the address sees the events**, and Google reads it from its own servers: don't put anything sensitive in it ("Booked" rather than the guest's name and phone number, if the address is shared widely). **New address** in Workshop cuts the old one; **Turn off** stops the feed.
- **Calendars refresh on their own schedule**: Apple Calendar as set by the person (down to every 5 minutes), Outlook every few hours, Google Calendar up to about a day. Right for a schedule; for a last-minute change, send an e-mail or rely on notifications.

**Importing calendars** (the other way: Airbnb, Booking, Abritel/Vrbo, Google, Outlook, iCloud). A manager of the folder pastes the export address of a calendar in Workshop (**⋯** of the tool → **Public link** → **Imported calendars**); Blackslate reads it right away, then every hour. The tool reads what was imported:

```js
const bookings = await lv.calendar.imported({ source: 'airbnb' });   // or imported() for all
// [{ source: 'airbnb', id, title: 'Reserved', allDay: true, start: '2026-11-07', end: '2026-11-10', location }]
const sources = await lv.calendar.sources();   // [{ name, host, events, fetchedAt, error, pending }]
lv.onChange((c) => { if (c.calendar) refreshBookings(); });       // imported bookings changed
```

- Dates as in `calendar.set`: an all-day booking ends the day after the last night. Platforms usually give only "Reserved" or "Not available" and the dates, not the guest's name.
- Up to an hour of delay (the platforms' own exports aren't faster); cancelled events are left out; the last 60 days and the next 400, 2,000 per calendar, 10 calendars per tool and folder. The address (it holds the calendar's secret key) is never shown again, even to managers.
- Only those services, in https: Blackslate never reads another address. A calendar that fails (address no longer valid, not a calendar) says so in `sources()` and in Workshop.

## 5.5 Tables: `window.leavenit.sql`

For large data (thousands to millions of rows), tools use **tables**. A table of more than 2,000,000 rows is computed by the folder's Runner only: a tool reads a summary of it made by a block, or a live query (`table_too_large` otherwise). `window.leavenit.sql` exists only when tables are available on the person's account: always check it.

```js
const sql = window.leavenit?.sql;
if (!sql) showMessage('Tables are not available here.');
```

| Method | Returns |
|---|---|
| `sql.tables()` | the tables of the data area: names, rows, columns, last update |
| `sql.preview(table)` | the first 100 rows (fast, nothing to download) |
| `sql.query(table, select, params?)` | runs **one read-only SQLite query**; inside it, **the table is always called `data`** |
| `sql.exec(table, statement, params?)` | **changes rows**: one `INSERT`, `UPDATE` or `DELETE` on the table (called `data`), with `?` parameters; returns `{ seq, pending }`, or `{ changed }` (rows changed) for a protected table (see 5.5) |
| `sql.saveChanges(table)` | saves the changes waiting into a new version now (normally automatic); returns `{ version }` (`{ version: null, saved }` for a protected table) |
| `sql.importFile(file, { table, mode })` | imports a CSV file the person picked; `mode`: `'replace'` (default) or `'add'`; `allowDuplicate: true` to import the same file twice |
| `sql.export(table, { format, separator })` | downloads the table: `format` `'csv'` (default) or `'sqlite'`; `separator` `','`, `';'` or `'\t'` |
| `sql.undo(table)` | goes back to the previous version of the table |
| `sql.aiContext({ inputs, output, sampleRows })` | a text describing tables and rules, to give to an AI that writes SQL |
| `sql.blocks.list() / get(id) / save(block) / history(id) / restore(id, version) / runs(id, limit) / run(id, { dryRun })` | the SQL blocks of the data area |

```js
// A typical read: the 10 best sellers, with a parameter
const r = await sql.query('orders', 'select item, sum(qty) as total from data where shop = ? group by item order by total desc limit 10', [shop]);
```

Table names: lowercase letters, digits and `_`, starting with a letter (`orders_2026`).

**Speed**: show each change on screen **right away** (an optimistic update), then write it in the background with `exec`; if the write fails, undo it on screen and show the error. After a write, re-read **only the tables you changed**, not all of them. Re-read everything when the page comes back to the foreground (another person may have changed something). Reads started at the same moment are grouped by Blackslate into one round trip, so `Promise.all` over several tables is the fastest way to read them.

**Pace**: table calls that download or compute (`query`, `preview`, `exec`, `importFile`, `export`…) run six at a time; the others **wait their turn**, so a tool can read several tables at start-up with `Promise.all`. Up to about 40 can wait; a tool that fires more at once gets `rate_limited` and should load less at a time.

### Changing rows: `sql.exec`

```js
const id = crypto.randomUUID();
await sql.exec('recipes', 'insert into data (id, name, servings) values (?, ?, ?)', [id, 'Pizza dough', 4]);
await sql.exec('ingredients', 'update data set kcal = ? where id = ?', [364, 'flour-t65']);
await sql.exec('recipes', 'delete from data where id = ?', [id]);
const rows = (await sql.query('recipes', 'select * from data order by name')).rows;   // includes the changes above
```

How it works, and what it means for the tool:

- **Fast at any size.** A change isn't uploaded with the table: it is written to the table's **journal**, in order. Writing costs the same for 100 or 1,000,000 rows (about a tenth of a second).
- **Checked first.** The statement is tried on an empty copy of the table's columns: a mistake (unknown column, wrong syntax) is refused at once, with SQLite's message.
- **Everyone sees the same table.** Reading (`query`, `preview`, `export`, blocks, the Runner) replays the journal on the table, in order. Two people writing at the same time don't overwrite each other: both changes are kept, in the order they arrived.
- **Saved automatically.** From time to time (every 500 changes, and before an import, an undo or a block that rewrites the table), the journal is saved into a new **version** of the table. `sql.saveChanges(table)` does it now.
- **One statement at a time**: `INSERT` (also `INSERT OR REPLACE`, `INSERT OR IGNORE`), `UPDATE`, `DELETE`, on `data` only. No `SELECT`, no `WITH`, no second statement.
- **Repeatable statements only**: the journal is replayed, so a change must give the same result every time. `random()`, `randomblob()`, `datetime('now')`, `CURRENT_TIMESTAMP` and similar are refused (`sql_not_deterministic`). Make ids and dates in JavaScript and pass them as parameters: `crypto.randomUUID()`, `new Date().toISOString()`.
- **Parameters**: `?` only (no `?1`, `:name`), with text, numbers, `true`/`false` or `null`. Never build the statement by pasting values into it: always use `?`.
- **Give rows an id.** Update and delete by an id column (`where id = ?`), not by position or by name.
- **A change that becomes impossible** (for example two people creating the same id in a table with a unique id, at the same moment) is **set aside** when the journal is saved, and shown in the table's history. The others are kept.
- **Undo** (`sql.undo`) goes back to the previous **saved** version: changes waiting are saved first, so undo then removes everything since the version before.
- **Columns don't change** with `exec`: to add a column, import a new file or use a block.
- `read_only`: the person can only read here; hide the editing controls when `window.leavenit.context.canWrite` is false.

### Without a connection

- **Reading**: a table this tool read on a device is kept on it (up to 10 MB per table and 50 MB per account on the device; the least recently read go first). Offline, `sql.query` reads that copy, with the tool's own waiting changes; a table never read on that device answers `offline`.
- **Writing**: `sql.exec` keeps the change on the device, answers `{ queued: true }`, and the tool sees it at once in its queries. When the connection is back, changes go in order, by the same path as online: unique keys, reserved columns and rights apply then.
- A waiting change is applied to the table **as it is when the connection returns**, like two people's changes online. `update … where id = ?` and `insert` behave exactly as expected; a broad statement (`delete from data where done = 1`) would also touch rows others changed meanwhile. Target rows by their id.
- A change that must not run late: `sql.exec(table, statement, params, { offline: false })` fails with `offline` instead of being kept.
- A change refused when it arrives (a slot taken meanwhile: `taken`; `managers_only`, `read_only`…) is not retried forever: `lv.onSync` reports it with `scope: 'table'`, the table as `key`, the `code` and the `statement`; the person sees a message, and the table no longer shows it.

### Tables with a rule: each person sees the rows of their values

In an organisation, an admin can give a table a **rule** (chapter 3.9): each person receives only the rows the organisation's directory gives them (their region, the rows they are responsible for, their team's, or every row for some people), and linked tables follow their main table, down a chain (the exchanges of a client go with the client). **Nothing changes in the tool**: `sql.query` and `sql.exec` work as usual, on the rows this person may see.

- Give every row an `id`, and keep the rule's column filled in (a row without a value is seen by admins only). In a linked table, keep its link column (`client_id`) pointing to a row of the main table.
- Writing a row of a value the person doesn't have, or pointing to a main row they can't see, answers **`not_your_rows`**: show a message ("This client isn't in your region"). Changing a row's value moves it; a person can only move it between values they both have.
- Never hide rows in your own code to protect them: anything a tool receives can be read on the device. The rule is the protection.
- To compare a person's figures with the whole organisation, read their rows from the table with a rule and the organisation's totals from a **summary table** (chapter 9.12), filtered the same way.

### Protected tables: each member sees only their own rows

In a shared folder, a table can be **protected**: each member reads and changes **only the rows they wrote**, and the **managers** read and change all of them. Typical uses: availabilities of volunteers, answers to a form, expense reports, each member's orders.

A protected table is declared in the table plan, when the tool is added (only a manager of the folder can create it), and always starts empty:

```
LEAVENIT TABLES
slots: id, day, hour, places | managers: places
availability: id, slot_id, note, approved | protected | unique slot_id | managers: approved
END
```

- `| protected`: each member's rows are kept apart. Blackslate adds two columns, **`member`** (the id of the person who wrote the row) and **`member_name`** (their name), filled in automatically.
- `| unique slot_id`: a value only one row may have, across all members (a time slot, a seat). A second one is refused with `taken`. Only on protected tables.
- `| managers: approved`: columns that **only managers fill in**; members see them on their own rows. Also possible on a table that isn't protected.

What it means for the tool:

- **Read as usual**: `sql.query('availability', 'select * from data order by member_name')`. A member gets their own rows, a manager gets everyone's. Use `window.leavenit.context.role === 'manager'` to show the managers' view.
- **Always name the columns in `INSERT`**: `insert into data (id, slot_id, note) values (?, ?, ?)`. The table the tool sees includes `member` and `member_name`; never write them (`member_read_only`).
- **Every row needs its own id** (`crypto.randomUUID()`), and the id of a row never changes (`row_id_needed`, `id_read_only`).
- **Columns reserved for managers**: a member who tries to fill one gets `managers_only`; hide those controls when `context.role` isn't `'manager'`. They come back as **text** (`'1'`, not `1`), like every column.
- **A manager's change applies to every member's rows it matches**: `update data set approved = '1' where slot_id = ?` approves the row of whoever took that slot.
- **Duplicates**: Blackslate's tools can't write the same unique value twice. If a member bypasses them, `sql.query` returns, for managers only, `warnings: [{ code: 'duplicate_unique', column, values }]`; show it.
- **Two tables for "managers publish, members answer"**: the managers' list is an ordinary table (here `slots`, with `| managers: places` so members can't change it); each member's answer is a row of the protected table that points to it (`slot_id`).
- **Adding columns**: when the tool's new table plan has new columns for a protected table, a manager applies it (the tool's **Edit** page, or when the tool is opened in another folder). New columns can be reserved for managers or unique; they start empty on existing rows. Columns that already exist keep their rules: they can't become reserved or unique afterwards.
- **Not (yet) possible** on a protected table: importing a file, versions and undo, removing a column, reading it from a block or a flow. A folder can have up to 1,000 members writing in one protected table; beyond, use an inbox (5.4).

### Tables published by the tool's author: `window.leavenit.published`

The makers of a tool can publish tables of their own folders with it (Workshop, ⋯ on a table, **Publish with a tool**): reference data that is the same for everyone who uses the tool, such as prices per town, tariffs or a catalogue, kept up to date by the author's flows. The tool reads them read only, wherever it is used:

| Call | What it does |
|---|---|
| `published.list()` | the tables published with this tool: `[{ name, version, rows, bytes, columns, updatedAt }]` |
| `published.query(table, select, params)` | one read-only SELECT on that table (called `data`), with `?` parameters, like `sql.query`: `{ columns, rows, truncated, version }` |

```js
const { rows } = await window.leavenit.published.query('prices_by_town',
  'select median_price_m2 from data where town_code = ? and kind = ?', ['49007', 'apartment']);
```

- The tool's own tables (`sql`) stay those of the person's folder; the published ones never mix with them, and can't be written (`exec` doesn't exist here).
- Everyone downloads the whole table, then keeps it on their device (it works offline): publish **aggregated** tables (one row per town, not one per sale), a few MB at most.
- A table its author took back answers `not_found`, and the copy kept on the device is erased. Copies of the tool read it only if the author allowed it.
- No protected table, and no personal data: everyone who uses the tool reads every row.
- A sold tool (chapter 2.9) can reserve a published table to some levels: the others get `forbidden`.

### Maps: `window.leavenit.map`

A real map, moved and zoomed with the finger or the mouse, in any tool (visitors included), with no key and no setting: OpenStreetMap data served by Blackslate's own map server (metropolitan France, down to the streets and buildings). It is the only address a tool may read; the credit "© OpenStreetMap contributors" is always shown, as the licence requires.

| Call | What it does |
|---|---|
| `await map.show(element, { center: [lat, lon], zoom, dark })` | draws the map in that element (360 px high if it has no height); `zoom` 6 (France) to 18 |
| `map.markers([{ at: [lat, lon], label, popup, color }])` | replaces the markers (5,000 at most); `label` on hover, `popup` on click; `color`: `'dark'`, `'light'`, `'green'`, `'red'`, `'orange'`, `'blue'` or `#hex` |
| `map.areas(geojson, { color: p => …, label: p => … })` | GeoJSON areas, coloured by their properties (prices per neighbourhood, zones) |
| `map.onMarkerClick((i, marker) => …)` | a click on a marker |
| `map.view([lat, lon], zoom)` and `map.fit()` | moves the map; fits it to every marker and area |

```js
const map = await window.leavenit.map.show(document.getElementById('map'), { center: [47.47, -0.55], zoom: 13 });
map.markers(homes.map(h => ({ at: [h.lat, h.lon], label: h.title, popup: `${h.price} €` }))).fit();
map.onMarkerClick(i => select(homes[i]));
```

- Places need their latitude and longitude. Labels and popups are shown as text.
- The map needs a connection; without one, `show` answers `map_unavailable`, and the rest of the tool works as usual.

### Addresses: `window.leavenit.geo`

French addresses and their positions, with no key: Blackslate asks the IGN Géoplateforme (the national address base, a public service) for the tool. Only the address text is sent, from the person's browser.

| Call | What it does |
|---|---|
| `await geo.suggest(text)` | up to 5 addresses matching what is typed (3 characters at least): for an address field |
| `await geo.locate(address)` | the best match, or `null` |
| `await geo.reverse([lat, lon])` | the address nearest to a place, or `null` |

Each answer is `{ label, at: [lat, lon], city, postcode, citycode, type }`; `citycode` is the INSEE code of the town (to join data per town). At most 10 requests per second per tool: to place many addresses, call `locate` one after the other, and keep the positions in a table. Without a connection, the answers are empty. Say in the tool that addresses are looked up with the IGN.

```js
input.oninput = async () => { list.replaceChildren(...(await window.leavenit.geo.suggest(input.value)).map(row)); };
const home = await window.leavenit.geo.locate('12 rue Lenepveu, Angers');
if (home) map.markers([{ at: home.at, label: home.label }]).fit();
```

### Web services: `window.leavenit.web`

To call an API from a tool (directions, weather, a shop's orders), with or without a key, through the folder's **Runner** (use `window.leavenit.web` if it exists: not in a preview): the folder's owner or admins declare the address once (Workshop, **⋯** on the folder, **Web services**), with its key if it needs one. The Runner adds the key; the tool never sees it, and can't call any other address.

| Call | What it does |
|---|---|
| `await web.get(url, query)` | a GET; `query` (optional) is an object of parameters added to the address |
| `await web.post(url, body)` | a POST with a JSON body (64 KB at most) |

The answer is `{ status, data }` for JSON, `{ status, text }` for text, `{ status, contentType, base64 }` otherwise. A 4xx or 5xx answer of the service comes back as it is (check `status`). Errors: `web_not_allowed` (the address is not a web service of the folder: the message says which), `no_runner`, `web_timeout` (the Runner didn't answer within a minute), `web_failed` (the service couldn't be reached), `rate_limited` (30 calls per minute per tool and person).

```js
const r = await window.leavenit.web.post('https://api.openrouteservice.org/v2/directions/driving-car',
  { coordinates: [[-0.5521, 47.4712], [-0.5636, 47.4785]] });
if (r.status === 200) showRoute(r.data.routes[0]);
```

- The first call takes a few seconds (the Runner checks every 5 s); then about one second while the tool is in use.
- Only https addresses with a public name; no redirection is followed; 2 MB and 15 seconds at most per answer.

### Live queries: `window.leavenit.warehouse`

To show the company's data live (a store's dashboard, a customer card), a tool calls a **live query** the folder's owner declared on one of its data warehouses (Workshop, **⋯** on the folder, **Data warehouses** → **Live queries**): one select with typed parameters, like `orders_by_store` with `store_id` and `since`. The tool can't send its own SQL: it gives the query's name and values, and the folder's Runner runs it with the warehouse's own parameters (use `window.leavenit.warehouse` if it exists: not in a preview).

| Call | What it does |
|---|---|
| `await warehouse.query(name, values)` | `{ columns: [{ name, type }], rows: [[…]], truncated, at, cached }`; `type` is INTEGER, REAL or TEXT (dates are text like `2026-10-01`) |
| `await warehouse.list()` | the folder's live queries: `{ name, description, params, warehouse, maxRows }` |

Errors (`e.code`): `wh_query_unknown` (no query of that name: the message lists the folder's), `wh_param` (a missing value or one of the wrong type, said in the message), `no_runner`, `wh_timeout` (more than 30 seconds), `wh_query_failed` (the warehouse refused it), `web_timeout` (the Runner didn't answer within a minute), `rate_limited` (60 calls per minute per tool and person).

```js
const r = await window.leavenit.warehouse.query('orders_by_store', { store_id: 12, since: '2026-10-01' });
drawChart(r.rows);   // [['2026-10-01', 214, 18402.5], …]
```

- The first call takes a few seconds (the Runner checks every 5 s); then about one second while the tool is in use. An answer the owner chose to keep ("Keep the answer for") comes back at once for the same values (`cached: true`).
- 10,000 rows (`truncated` beyond the query's At most), 2 MB and 30 seconds at most per answer.

### Apps in several files: `window.leavenit.pages`

A tool can be an **app in several files**, for several screens that share their data: `pages/` (one HTML page per screen, `pages/index.html` first), `shared/` (scripts and styles used by several pages) and `data/` (fixed JSON). Each file starts with a one-line comment saying its role; keep files short (a few hundred lines). A page declares what it uses with ordinary tags, relative to it, and Blackslate puts their contents in the page when it opens (the tool still reaches no network):

```html
<link rel="stylesheet" href="../shared/style.css">
<script src="../shared/calculs.js"></script>
<script type="application/json" src="../data/prix.json"></script>
```

| Call | What it does |
|---|---|
| `pages.open(name, params)` | opens another page (`'comparateur'` for `pages/comparateur.html`); `params`: strings only |
| `pages.current`, `pages.params`, `pages.list` | the page shown, the parameters it was opened with, the app's pages |
| `pages.json(path)` | the content of a `data/` file the page declares |

The data (tables, saved values) is the same on every page. To give an app, answer with one heading per file, `### File: pages/index.html`, then the whole file in one code block. Limits: 100 files, 2 MB per file, 10 MB in all; paths in lowercase.

### The SQL dialect (SQLite 3.49)

- The whole block script is one transaction: all or nothing.
- Allowed: `SELECT`, `WITH`, `VALUES`, `INSERT`, `UPDATE`, `DELETE`, `REPLACE`, `CREATE TABLE / INDEX / VIEW`, `DROP`, `ALTER`, `ANALYZE`, `EXPLAIN`. Refused: `PRAGMA`, `ATTACH`, `DETACH`, `VACUUM`, transactions, triggers, virtual tables.
- **Imported columns are text**, and empty cells are `''`, not `NULL`: use `nullif(x, '')`.
- Clean values with the functions Blackslate adds: `to_number(x)` (`'1 250,50 €'` → `1250.5`, `'n/a'` → `NULL`), `to_date(x)` (dd/mm/yyyy, yyyy-mm-dd, `'4 Mar 2026'` → `'yyyy-mm-dd'`), `upper(x)` and `lower(x)` (Unicode), `regexp_replace(text, pattern, replacement)` (JavaScript regular expressions).
- Don't clean with `CAST`: `CAST('n/a' AS INTEGER)` gives `0` silently. Use `to_number`.
- `7/2` gives `3`: write `7*1.0/2`. Always add `ORDER BY` after `GROUP BY`. No `ILIKE` (use `lower(x) LIKE …`), no `::`, no `QUALIFY`, no `try_cast`. Window functions, `WITH` and `FULL JOIN` work.

### Table errors

| Code | Message shown |
|---|---|
| `sql_syntax` | The SQL query has an error. |
| `sql_not_allowed` | This SQL statement is not allowed here. |
| `sql_timeout` | Time limit reached. The query was stopped. |
| `sql_out_of_memory`, `sql_too_large` | the table is too large for this device or plan |
| `table_too_large` | a large table (more than 2,000,000 rows or 300 MB) can't be read whole in a browser: read the smaller table a block makes from it (a summary), or a live query |
| `sql_conflict` | someone changed the table at the same time: try again |
| `sql_duplicate_file` | this file was already imported into this table |
| `sql_import_empty`, `sql_import_encoding` | empty file, or mixed encodings: save it as UTF-8 |
| `nothing_to_undo` | there is no earlier version |
| `not_found` | the table or block doesn't exist in this data area |
| `read_only`, `forbidden`, `not_linked` | the person (or the tool) can't write or can't reach this data area |
| `table_expired`, `input_expired` | a temporary table expired: run the block that makes it |
| `upload_failed`, `download_failed`, `checksum_mismatch` | transfer problem: check the connection and try again |
| `sql_change_not_allowed` | `exec` only accepts one INSERT, UPDATE or DELETE on the table called `data` |
| `sql_one_statement` | `exec` received two statements: send them one by one |
| `sql_not_deterministic` | `exec` used random() or the current date or time: pass the value as a parameter |
| `changes_pending` | changes are being saved: try again in a moment |
| `changes_backlog` | too many changes waiting (20,000): call `sql.saveChanges(table)`, then try again |
| `taken` | a protected table: this unique value is already taken by another row |
| `not_your_rows` | a table with a rule: this row's value isn't one of yours (or its main row is one you can't see) |
| `managers_only` | a protected table: only managers fill in this column |
| `member_read_only`, `id_read_only` | a protected table: `member`, `member_name` and a row's id can't be written |
| `row_id_needed` | a protected table: each row needs its own id |
| `protected_table` | a protected table can't be imported into, undone or rewritten as a whole |
| `protected_input`, `protected_output` | a block can't read or write a protected table yet |
| `members_limit` | a protected table already has 1,000 members |

## 5.6 The prompt to give your AI

People can paste this into the AI that writes their tool:

> Write a single self-contained HTML file. It must work offline and without any network request. Libraries only from cdnjs, jsdelivr, unpkg or esm.sh. No remote images. Don't use alert(), confirm() or prompt(): show messages inside the page. To save data, use window.leavenit if it exists (async get(key, options), set(key, value, options), delete(key, options), list(prefix, options)), otherwise localStorage. Never rename existing data keys. For data shared with a group, use { scope: 'shared' }, check window.leavenit.context.canWrite before showing edit buttons, and pass { ifVersion } when updating a shared value. For tables, use window.leavenit.sql if it exists: read with query(table, select, params) where the table is always called data; change rows with exec(table, statement, params), one INSERT, UPDATE or DELETE on data with ? parameters, never random() or the current date (pass ids from crypto.randomUUID() and dates as parameters), and update or delete rows by an id column. The SQL dialect is SQLite 3.49 with to_number, to_date and regexp_replace. In a shared folder, window.leavenit.context.role is 'manager', 'editor' or 'viewer': show the managers' controls only to managers. In a protected table, each member reads and changes only their own rows (managers see all), Blackslate adds the columns member and member_name: always name the columns in INSERT, give every row an id, never write member or member_name, and handle the error codes taken and managers_only. For a value or a file (files.put) that only its author and the managers may read, use { scope: 'shared', private: true }. To send an e-mail, use window.leavenit.mail.send({ to, subject, text }) (plain text, sent by the folder's Runner), with at: '2026-11-03T18:00' to send it later (a reminder; keep its id to cancel it with window.leavenit.mail.cancel(id)); if it fails with the code no_mail_runner, offer a mailto: link with the e-mail prepared instead. Without a connection, writes are kept on the device and sent later: set with scope 'shared' may answer { version: null, queued: true } and sql.exec { queued: true } (target rows by id; pass { offline: false } as 4th argument for a change that must not run late), files.put answers at once with the file's final id (keep it in your data as usual), reads of other data fail with the code offline, and window.leavenit.onSync(({ pending, offline, failed }) => …) reports waiting and refused writes. To show other people's changes without reloading, call window.leavenit.onChange((c) => …) and read again what changed (c.data, c.tables, c.inbox, c.files, c.public). To put events in a calendar people subscribe to (Google, Apple, Outlook), use window.leavenit.calendar.set(id, { title, start, end, allDay }, { feed }) with only what may be seen by anyone with the address. Bookings imported from Airbnb, Booking or Google (added by a manager in Workshop) are read with window.leavenit.calendar.imported({ source }).
