@poli-page/cli 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -58
- package/dist/api-client.d.ts +62 -2
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +172 -13
- package/dist/api-client.js.map +1 -1
- package/dist/api-origin.d.ts +28 -0
- package/dist/api-origin.d.ts.map +1 -0
- package/dist/api-origin.js +84 -0
- package/dist/api-origin.js.map +1 -0
- package/dist/auth.d.ts +4 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +19 -13
- package/dist/auth.js.map +1 -1
- package/dist/cloud-context.d.ts +8 -0
- package/dist/cloud-context.d.ts.map +1 -1
- package/dist/cloud-context.js +14 -9
- package/dist/cloud-context.js.map +1 -1
- package/dist/cloud-link.d.ts +41 -0
- package/dist/cloud-link.d.ts.map +1 -0
- package/dist/cloud-link.js +112 -0
- package/dist/cloud-link.js.map +1 -0
- package/dist/commands/auth.d.ts +31 -8
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +72 -23
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/clone.d.ts +32 -0
- package/dist/commands/clone.d.ts.map +1 -0
- package/dist/commands/clone.js +266 -0
- package/dist/commands/clone.js.map +1 -0
- package/dist/commands/dev.d.ts +58 -3
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +335 -63
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/documents/delete.d.ts.map +1 -1
- package/dist/commands/documents/delete.js +2 -9
- package/dist/commands/documents/delete.js.map +1 -1
- package/dist/commands/documents/document-id.d.ts +2 -0
- package/dist/commands/documents/document-id.d.ts.map +1 -0
- package/dist/commands/documents/document-id.js +10 -0
- package/dist/commands/documents/document-id.js.map +1 -0
- package/dist/commands/documents/get.d.ts.map +1 -1
- package/dist/commands/documents/get.js +2 -9
- package/dist/commands/documents/get.js.map +1 -1
- package/dist/commands/documents/preview.d.ts +1 -0
- package/dist/commands/documents/preview.d.ts.map +1 -1
- package/dist/commands/documents/preview.js +89 -14
- package/dist/commands/documents/preview.js.map +1 -1
- package/dist/commands/documents/thumbnails.d.ts.map +1 -1
- package/dist/commands/documents/thumbnails.js +35 -20
- package/dist/commands/documents/thumbnails.js.map +1 -1
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +4 -19
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +41 -34
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/link.d.ts +15 -0
- package/dist/commands/link.d.ts.map +1 -1
- package/dist/commands/link.js +88 -21
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +14 -13
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/publish.d.ts +6 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +32 -16
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/render.d.ts.map +1 -1
- package/dist/commands/render.js +23 -12
- package/dist/commands/render.js.map +1 -1
- package/dist/commands/sync.d.ts +52 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +224 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -1
- package/dist/credentials.d.ts +15 -0
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +52 -22
- package/dist/credentials.js.map +1 -1
- package/dist/dev-page.d.ts +7 -0
- package/dist/dev-page.d.ts.map +1 -1
- package/dist/dev-page.js +42 -0
- package/dist/dev-page.js.map +1 -1
- package/dist/dev-server.d.ts +19 -0
- package/dist/dev-server.d.ts.map +1 -1
- package/dist/dev-server.js +70 -8
- package/dist/dev-server.js.map +1 -1
- package/dist/draft-bases.d.ts +54 -0
- package/dist/draft-bases.d.ts.map +1 -0
- package/dist/draft-bases.js +253 -0
- package/dist/draft-bases.js.map +1 -0
- package/dist/draft-files.d.ts +96 -0
- package/dist/draft-files.d.ts.map +1 -0
- package/dist/draft-files.js +447 -0
- package/dist/draft-files.js.map +1 -0
- package/dist/exit-codes.d.ts +3 -1
- package/dist/exit-codes.d.ts.map +1 -1
- package/dist/exit-codes.js +16 -7
- package/dist/exit-codes.js.map +1 -1
- package/dist/file-watcher.d.ts +4 -1
- package/dist/file-watcher.d.ts.map +1 -1
- package/dist/file-watcher.js +26 -11
- package/dist/file-watcher.js.map +1 -1
- package/dist/format-resolver.d.ts +6 -0
- package/dist/format-resolver.d.ts.map +1 -1
- package/dist/format-resolver.js +14 -6
- package/dist/format-resolver.js.map +1 -1
- package/dist/manifest.d.ts +8 -0
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +37 -7
- package/dist/manifest.js.map +1 -1
- package/dist/manifest.schema.d.ts +4 -2
- package/dist/manifest.schema.d.ts.map +1 -1
- package/dist/manifest.schema.js +40 -7
- package/dist/manifest.schema.js.map +1 -1
- package/dist/output.d.ts +5 -0
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +7 -0
- package/dist/output.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +55 -22
- package/dist/program.js.map +1 -1
- package/dist/project-files.d.ts +26 -0
- package/dist/project-files.d.ts.map +1 -1
- package/dist/project-files.js +46 -7
- package/dist/project-files.js.map +1 -1
- package/dist/project-loader.d.ts +6 -3
- package/dist/project-loader.d.ts.map +1 -1
- package/dist/project-loader.js +36 -61
- package/dist/project-loader.js.map +1 -1
- package/dist/project-sync.d.ts +123 -18
- package/dist/project-sync.d.ts.map +1 -1
- package/dist/project-sync.js +449 -80
- package/dist/project-sync.js.map +1 -1
- package/dist/security/paths.d.ts +29 -0
- package/dist/security/paths.d.ts.map +1 -0
- package/dist/security/paths.js +109 -0
- package/dist/security/paths.js.map +1 -0
- package/dist/slug.d.ts +8 -0
- package/dist/slug.d.ts.map +1 -0
- package/dist/slug.js +15 -0
- package/dist/slug.js.map +1 -0
- package/dist/sync-engine.d.ts +14 -9
- package/dist/sync-engine.d.ts.map +1 -1
- package/dist/sync-engine.js +26 -29
- package/dist/sync-engine.js.map +1 -1
- package/dist/template-importer.d.ts.map +1 -1
- package/dist/template-importer.js +170 -59
- package/dist/template-importer.js.map +1 -1
- package/package.json +1 -1
- package/dist/commands/watch.d.ts +0 -26
- package/dist/commands/watch.d.ts.map +0 -1
- package/dist/commands/watch.js +0 -102
- package/dist/commands/watch.js.map +0 -1
package/README.md
CHANGED
|
@@ -85,7 +85,8 @@ poli dev
|
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
`poli dev` is the code-first alternative to the desktop editor. If you only want
|
|
88
|
-
the sync half, without a browser, use `poli
|
|
88
|
+
the sync half, without a browser, use `poli dev --no-preview`. To start from a
|
|
89
|
+
project that already exists in the cloud, `poli clone <org>/<project>`.
|
|
89
90
|
|
|
90
91
|
---
|
|
91
92
|
|
|
@@ -98,10 +99,10 @@ The CLI supports two authentication modes. Both flow through the same internal r
|
|
|
98
99
|
```bash
|
|
99
100
|
poli login # device authorization flow — opens your browser
|
|
100
101
|
poli whoami # show the current session and active org
|
|
101
|
-
poli logout #
|
|
102
|
+
poli logout # delete ~/.polipage/credentials, then revoke the session
|
|
102
103
|
```
|
|
103
104
|
|
|
104
|
-
After `poli login`, the session token is stored at `~/.polipage/credentials
|
|
105
|
+
After `poli login`, the session token is stored at `~/.polipage/credentials` and used by every command that needs it (while `POLI_PAGE_API_KEY` is set, the commands that accept a key use the key instead: see [Precedence](#precedence)).
|
|
105
106
|
|
|
106
107
|
### Programmatic (CI / CD / scripts)
|
|
107
108
|
|
|
@@ -113,7 +114,7 @@ Set the `POLI_PAGE_API_KEY` environment variable. Every key is bound to one envi
|
|
|
113
114
|
| `pp_live_…` | `name@live` — counted in the monthly quota |
|
|
114
115
|
| `pp_<environment>_…` | `name@<environment>` — counted in the monthly quota |
|
|
115
116
|
|
|
116
|
-
A key renders only its own environment, and never the draft: the draft (`poli render name`) needs `poli login
|
|
117
|
+
A key renders only its own environment, and never the draft: the draft (`poli render name`) needs `poli login`, with `POLI_PAGE_API_KEY` unset (see [Precedence](#precedence)).
|
|
117
118
|
|
|
118
119
|
```bash
|
|
119
120
|
export POLI_PAGE_API_KEY=pp_live_xxx
|
|
@@ -126,13 +127,11 @@ Standard keys and service keys share the `pp_<environment>_…` format; the CLI
|
|
|
126
127
|
- a **standard key** renders only. `poli publish` refuses it before any upload (exit `5`).
|
|
127
128
|
- a **service key** (recommended for CI) also publishes, into its own environment only: `--env` is still required and must name the environment in the key (exit `2` otherwise). Its role decides on a protected environment: an `admin` service key can publish to one, a `developer` one gets `ENVIRONMENT_PROTECTED` (exit `5`). Nothing prompts.
|
|
128
129
|
|
|
129
|
-
The other workspace commands (`link`, `
|
|
130
|
+
The other workspace commands (`link`, `clone`, `sync`, `dev`) need `poli login`.
|
|
130
131
|
|
|
131
132
|
### Precedence
|
|
132
133
|
|
|
133
|
-
When **both** `~/.polipage/credentials
|
|
134
|
-
|
|
135
|
-
This means a developer can keep `POLI_PAGE_API_KEY` set in `.zshrc` for occasional CI-style commands without it interfering with their interactive workflow.
|
|
134
|
+
When **both** `~/.polipage/credentials` (a session) and `POLI_PAGE_API_KEY` are set, **the key wins** for every command that accepts either credential (`whoami`, `publish`, `render`, `documents`): a set key is an explicit choice, so exporting a `pp_sandbox_…` key makes those commands act as that key, not as your full session. The session-only commands (`link`, `clone`, `sync`, `dev`, `env`) keep using your session. While the key wins, what it cannot do is refused even though a session is stored: `poli render <name>` (the draft), `poli render <name>@<environment>` for another environment than the key's, `poli publish` with a standard key, with an `--env` other than the key's or with a key of another organization than the linked one, and any of those commands with a malformed key fail, and their error says to unset `POLI_PAGE_API_KEY` to use the session. In a terminal, `poli whoami` says when the key is used instead of a stored session (its JSON is the `GET /v1/me` response, unchanged), and `poli publish` prints which credential it used (`Auth:` in its summary, `credential` in its JSON). `poli login` does not refuse if the env var is set: it shows an info-message and proceeds, but the key keeps winning until you unset it.
|
|
136
135
|
|
|
137
136
|
---
|
|
138
137
|
|
|
@@ -159,7 +158,8 @@ Flags:
|
|
|
159
158
|
|
|
160
159
|
- `--with-template <ref>` — pre-install a starter template, format `<collection>/<template>`. Skips the interactive prompt.
|
|
161
160
|
- `--template-name <name>` — override the imported template's destination name
|
|
162
|
-
- `--source <repo>` — source repo, format `github:<owner>/<repo>` (default: `github:poli-page/templates`)
|
|
161
|
+
- `--source <repo>` — source repo, format `github:<owner>/<repo>` (default: `github:poli-page/templates`); `<owner>` and `<repo>` are each one name of letters, digits, `.`, `_` and `-`, not `.` or `..`
|
|
162
|
+
A source's collection and template names, and the `template`, `mock`, `fonts[].src` and `images[]` paths of its template manifests, must be relative paths of letters, digits, `.`, `_` and `-` segments (no `..`, no leading `.` or `/`); the first one that is not refuses the whole import before anything is written. No imported file is written outside the project or the cache, including through a symlink that is there when the import starts, and no file of the project (the template files, fonts, images, `tailwind.css`, the files of `--starter` and its `poli-page.json`) is written through a symlink, even one that stays inside the project: each is written to a temp file and renamed into place; the paths are checked before the writes, so another process changing the project's folders during the import is not covered.
|
|
163
163
|
- `--no-cache` — bypass the 24-hour template cache
|
|
164
164
|
|
|
165
165
|
##### `--starter getting-started` — start from your org's getting-started project
|
|
@@ -171,22 +171,42 @@ poli init --starter getting-started my-start # writes ./my-start
|
|
|
171
171
|
|
|
172
172
|
Writes the whole `getting-started/` project of [`poli-page/templates`](https://github.com/poli-page/templates) (templates, mocks, `poli-page.json`, `tailwind.css`, fonts and images) into `dir` (default: `./getting-started`). The files come from the public templates repo — the same source your org's `getting-started` project was created from — nothing is downloaded from the cloud.
|
|
173
173
|
|
|
174
|
-
When you are logged in, the folder is linked to the **existing** `getting-started` project of your organization (it never creates a cloud project). If you belong to several organizations, pass `--org <slug>` (or pick one at the prompt). Logged out, or when the organization has no `getting-started` project, the starter is written unlinked and the command tells you how to link it (`poli login`, then `poli link`).
|
|
174
|
+
When you are logged in, the folder is linked to the **existing** `getting-started` project of your organization (it never creates a cloud project). Linking forgets the folder's [draft bases](#draft-bases), so the first `poli dev` or `poli sync` compares the starter with that project's draft and reports each file that differs as a [conflict](#conflicts) instead of sending the starter over it. If you belong to several organizations, pass `--org <slug>` (or pick one at the prompt). Logged out, or when the organization has no `getting-started` project, the starter is written unlinked and the command tells you how to link it (`poli login`, then `poli link`).
|
|
175
175
|
|
|
176
176
|
A non-empty target directory is refused unless you pass `--force`. Then:
|
|
177
177
|
|
|
178
178
|
```bash
|
|
179
179
|
cd getting-started
|
|
180
|
-
poli
|
|
180
|
+
poli dev --no-preview # sync each save to the cloud draft
|
|
181
181
|
poli publish --env sandbox # publish the project to the sandbox environment
|
|
182
182
|
```
|
|
183
183
|
|
|
184
184
|
and re-run the dashboard snippet to see your change.
|
|
185
185
|
|
|
186
|
-
Piped, or with `--json`, it prints `{ starter, projectDir, link }` as JSON instead (`link` is `{ status: "linked", orgSlug }` or `{ status: "unlinked", reason }`) and never prompts. `<name>` is one top-level folder of the source (no `/`).
|
|
186
|
+
Piped, or with `--json`, it prints `{ starter, projectDir, link }` as JSON instead (`link` is `{ status: "linked", orgSlug }` or `{ status: "unlinked", reason }`) and never prompts. `<name>` is one top-level folder of the source (no `/`). Every file path in that folder must be made of letters, digits, `.`, `_` and `-` segments (dotfiles allowed, no `.` or `..` segment); the first one that is not refuses the starter before any file is fetched.
|
|
187
187
|
|
|
188
188
|
Flags: `--starter <name>`, `--org <slug>`, `--force`, `--json`, plus `--source` and `--no-cache` as above.
|
|
189
189
|
|
|
190
|
+
#### `poli clone <org>/<project> [dir]`
|
|
191
|
+
|
|
192
|
+
Write the cloud draft of an existing project into a new folder, linked to it and ready for `poli dev`. `<org>` and `<project>` are slugs, as in the editor's URL; `dir` defaults to the project slug.
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
poli clone acme/invoices # writes ./invoices
|
|
196
|
+
poli clone acme/invoices my-invoices # writes ./my-invoices
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
- The target must not exist, or be an empty directory (dot files such as `.git` are allowed). A symbolic link is refused.
|
|
200
|
+
- The target must not be inside a Poli Page project: when its parent folder, or any folder above it, holds a `poli-page.json`, the clone is refused (exit `2`) rather than nesting one project in another. When that project, or the target folder itself, already is a clone of `<org>/<project>`, it says so: run `poli sync` there instead.
|
|
201
|
+
- It needs `poli login` and edit access to the project: a project you can only view exits `5`; one that does not exist or that you cannot see exits `2`.
|
|
202
|
+
- Every path of the draft is checked before anything is written: a path outside the project file set, or one some systems cannot hold (`:`, a reserved name such as `con`, a name ending in `.` or a space), refuses the clone. A draft over 1000 files or 20 MiB is refused too.
|
|
203
|
+
- Every file is downloaded and checked against the size and SHA-256 the draft lists before the first write. Any failure removes what the clone wrote (the folder, when it created it), so you can run it again.
|
|
204
|
+
- A listing it refuses (an unsafe path, over the caps) or a download that fails or does not match exits `3`.
|
|
205
|
+
- The written `poli-page.json` gets the `cloud:` block, the folder is recorded as a [confirmed link](#confirmed-links), and every file gets its [draft base](#draft-bases): `poli dev` syncs it without asking and without overwriting anyone's change.
|
|
206
|
+
- Piped, or with `--json`, it prints `{ dir, orgSlug, projectSlug, files }`.
|
|
207
|
+
|
|
208
|
+
Stopping a clone while it writes the files (Ctrl-C) can leave a partial folder: delete it before you run `poli clone` again.
|
|
209
|
+
|
|
190
210
|
#### `poli new <name>`
|
|
191
211
|
|
|
192
212
|
Create a new template inside an existing project from a remote starter.
|
|
@@ -204,16 +224,19 @@ Flags:
|
|
|
204
224
|
- `--from-template <ref>` — collection/template. Skips the interactive prompt.
|
|
205
225
|
- `--source <repo>` — override the source
|
|
206
226
|
- `--no-cache` — bypass cache
|
|
227
|
+
- `--format <format>`, `--orientation <orientation>` — set the template's page format and orientation (see [Manifest format](#manifest-format)); an unknown value exits `2` before anything is imported
|
|
207
228
|
|
|
208
229
|
### Authentication commands
|
|
209
230
|
|
|
210
231
|
#### `poli login`
|
|
211
232
|
|
|
212
|
-
Opens your browser for the device authorization flow and stores the session token at `~/.polipage/credentials
|
|
233
|
+
Opens your browser for the device authorization flow and stores the session token at `~/.polipage/credentials`.
|
|
234
|
+
|
|
235
|
+
It first prints the API host it logs into. The browser opens only an `https` page on the API's own site (`poli.page` or a subdomain; a local page when the API is local): any other verification URL the API sends is printed, not opened, and login exits `3`. The API URL is stored in the credentials file only when you chose it: `--api-url`, your own `POLI_API_URL`, or the `apiUrl` an earlier login stored. A `poli-page.json` `cloud.apiUrl` is never stored.
|
|
213
236
|
|
|
214
237
|
#### `poli logout`
|
|
215
238
|
|
|
216
|
-
|
|
239
|
+
Deletes the local credentials file, then revokes the session it held on the API origin that issued it (`POST /api/auth/sign-out`), so the file is gone even if the revoke hangs or is interrupted. If the revoke fails (network error, API error, an origin the CLI does not trust), a warning says the session stays valid until it expires; the exit code is `0` either way. If the file cannot be deleted (for example a read-only `~/.polipage`), the CLI still tries to revoke the session (a failed revoke gets the same warning), an error asks you to delete the file by hand, and the exit code is `6`.
|
|
217
240
|
|
|
218
241
|
#### `poli whoami`
|
|
219
242
|
|
|
@@ -244,29 +267,77 @@ Flag: `--json` to dump the raw `/v1/me` payload (or, in `session-no-org` mode, `
|
|
|
244
267
|
|
|
245
268
|
#### `poli link`
|
|
246
269
|
|
|
247
|
-
|
|
270
|
+
Pick an organization, create the cloud project, and write the `cloud:` section into `poli-page.json` with the four fields the API needs (`orgSlug`, `orgId`, `projectSlug`, `projectId`). No API key is stored in the manifest: the file is safe to commit. It also records the folder as a [confirmed link](#confirmed-links) on this machine, so `poli dev` and `poli sync` sync it without asking, and forgets the folder's [draft bases](#draft-bases): linking never sends the folder over a draft.
|
|
271
|
+
|
|
272
|
+
The organization is the one `--org <slug>` names; an unknown or empty slug fails with exit `2`, listing your organizations. Without `--org`, an account with a single organization uses it, and one with several asks in a terminal; when it cannot ask (stdin or stdout not a TTY, e.g. in CI or a script), it exits `2`, listing the slugs, and tells you to pass `--org <slug>`.
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
poli link --org acme
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
When the organization already has a project whose slug is the one `project.name` gives (say, a teammate's), `poli link` links to it instead of creating one. Its draft is someone's work, so it first names the project and organization and asks; a no leaves the folder unlinked (exit `1`). When it cannot ask (stdin or stdout not a TTY, e.g. its output piped), it refuses with exit `2` and writes nothing, unless you pass `--existing`, which links to that project without asking. In a script, pass both: `poli link --org <slug> --existing`. `poli init --starter` is not affected: it links only to the organization's existing starter project. Linking to an existing project sends nothing: the first `poli dev` or `poli sync` compares the folder with its draft, sends only the files the draft does not have, and reports each file that differs as a [conflict](#conflicts).
|
|
279
|
+
|
|
280
|
+
The slug `project.name` gives is the API's: accents dropped, lowercase letters and digits, every run of anything else one `-` (`Société Générale` gives `societe-generale`). For a project whose slug is not that one, name it: `poli link --org <slug> --project <project-slug>` links to that existing project without asking and never creates one. A slug that is none of the organization's projects you can see exits `2`; a project you can only view exits `5`.
|
|
281
|
+
|
|
282
|
+
The new cloud project is created from the files [`poli publish`](#poli-publish) would send (regular files only, never a symlink), restricted to the templates and mocks the manifest names, `tailwind.css`, the image files under `assets/images/` and `assets/icons/` and the font files under `assets/fonts/`; partials and other files reach the project on the first sync or publish. A template or mock file the manifest names that is not in that set (missing, symlinked, outside `templates/<name>/`, or under a `node_modules`, `.git`, `output`, `dist` or `.poli` folder, e.g. a template named `output`) fails the link before the project is created.
|
|
283
|
+
|
|
284
|
+
#### Confirmed links
|
|
285
|
+
|
|
286
|
+
A `cloud:` block can come with a cloned repository, and every sync writes to the cloud draft of the project it names. So `poli dev` and `poli sync` sync only a folder whose link you confirmed on this machine. The confirmed links are kept per user in `~/.polipage/links.json` (mode `0600`), keyed by the folder's real path and the project id; `poli link` and `poli init --starter` (when it links) write them, `poli unlink` removes the folder's. The first time you run `poli dev` or `poli sync` in a folder that is not there, or whose `projectId` changed, the command names the organization and project and asks once; a yes is recorded, a no stops the command before any sync. Without a terminal to ask in (stdin or stdout not a TTY), it refuses with exit `2`.
|
|
287
|
+
|
|
288
|
+
Before syncing, `poli dev` and `poli sync` also check with the API that the manifest's `orgSlug`, `orgId`, `projectId` and `projectSlug` all name the same project (sync writes to `projectId` in the `orgSlug` organization; render and publish address `projectSlug` with `orgId`). A manifest whose ids disagree, or whose `orgSlug` names none of your organizations, is refused before any write (exit `6`); `poli publish` with a session refuses it too.
|
|
289
|
+
|
|
290
|
+
#### Draft bases
|
|
291
|
+
|
|
292
|
+
Next to the confirmed links, `~/.polipage/draft-bases.json` (mode `0600`) keeps, per folder (its real path) and project id, the SHA-256 of each file's bytes as the draft and the folder last agreed on it, and the [conflicts](#conflicts) not resolved yet. Every sync sends each change with that base, and the API refuses the whole sync when a file changed in the draft since (someone else's change is never overwritten). `poli clone` writes the folder's bases; `poli link`, `poli init --starter` and `poli unlink` forget them. A linked folder with none (just linked, or linked by an older CLI) is reconciled by the next `poli dev` or `poli sync` before anything is sent: a file with the draft's bytes (for `poli-page.json`, the same content the API stores, whatever its formatting and `cloud:` block) gets its base, a file only the folder has is sent as new, and a file that differs, or one only the draft has, is a conflict. Deleting the file is safe: the next sync reconciles.
|
|
248
293
|
|
|
249
294
|
#### `poli unlink`
|
|
250
295
|
|
|
251
|
-
Removes the `cloud:` section from `poli-page.json
|
|
296
|
+
Removes the `cloud:` section from `poli-page.json`, even one whose ids are invalid, and forgets the folder's [confirmed link](#confirmed-links) and [draft bases](#draft-bases), so a `cloud:` block that comes back later (a pull, a checkout) is asked about again. Local files are preserved.
|
|
252
297
|
|
|
253
|
-
#### `poli
|
|
298
|
+
#### `poli dev --no-preview`
|
|
254
299
|
|
|
255
|
-
|
|
300
|
+
Syncs each save to the cloud draft, with no server, no browser and no render: [`poli dev`](#poli-dev-template)'s sync, start-up and conflict handling, for when the editor or another tool shows the result. It needs no TTY, so it runs in a script or next to another dev server. A template argument, `--port`, `--data` or `--no-open` with it exits `2`: they only configure the preview.
|
|
256
301
|
|
|
257
302
|
```bash
|
|
258
|
-
poli
|
|
303
|
+
poli dev --no-preview
|
|
259
304
|
```
|
|
260
305
|
|
|
261
|
-
|
|
306
|
+
It syncs the same file set as [`poli publish`](#poli-publish), each file with its encoding (`base64` for assets, `utf8` otherwise), 300 ms after the last save. A file whose name some systems cannot hold (`:`, a reserved name such as `con`, a name ending in `.` or a space) is named once and never sent nor deleted. Network errors are retried with an exponential backoff (1s up to 30s), `503 ORGANIZATION_MIGRATING` after 5 seconds; other errors are shown and the next save retries.
|
|
307
|
+
|
|
308
|
+
#### `poli sync`
|
|
309
|
+
|
|
310
|
+
Syncs the folder with its cloud draft once, and settles [conflicts](#conflicts). A folder with no [draft bases](#draft-bases) is reconciled first.
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
poli sync # send what changed since the last sync
|
|
314
|
+
poli sync --keep-mine -- templates/invoice/invoice.html # settle a conflict with your file
|
|
315
|
+
poli sync --take-theirs -- tailwind.css # settle it with the draft's file
|
|
316
|
+
```
|
|
262
317
|
|
|
263
|
-
-
|
|
264
|
-
- `
|
|
265
|
-
-
|
|
318
|
+
- `--keep-mine <path...>`: your files win: each is sent over the draft's (a file the draft deleted is sent as new, and a file you do not have is deleted from the draft).
|
|
319
|
+
- `--take-theirs <path...>`: the draft's files win: each replaces yours (for `poli-page.json`, the fields the API stores; your `cloud:` block and other keys stay), or your file is deleted when the draft deleted it. A file that changed again, in the draft or here, since the conflict was reported is not written and stays in conflict.
|
|
320
|
+
- Put `--` before the paths so none is read as a flag. Every path must be an open conflict: one that is not, or a path given to both flags, exits `2` with no flag applied.
|
|
321
|
+
- Conflicts left: printed with the two commands that settle them, exit `7`.
|
|
322
|
+
- Piped, or with `--json`, it prints `{ synced, conflicts }` (`synced`: the files sent; `conflicts`: `{ path, remoteSha256 }`, `remoteSha256` `null` when the draft deleted the file).
|
|
323
|
+
- Network errors are retried 4 times (1, 2, 4 then 8 s apart), then it exits `3`, so a script or a CI job never hangs on a network that is down. Ctrl-C stops it between requests and during a wait, with exit `130` (`143` on SIGTERM), the shell's codes for an interrupted command; a second Ctrl-C exits at once.
|
|
266
324
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
325
|
+
#### Conflicts
|
|
326
|
+
|
|
327
|
+
A file changed both here and in the cloud draft since the last sync (by a teammate, the editor or another machine) is a conflict: nothing is overwritten, `poli sync` still sends every other change, and the file stays out of every sync until it is settled. A file whose bytes are the same on both sides is not one. A file found by the reconciliation of a folder with no [draft bases](#draft-bases) is said to differ from the cloud draft: nobody knows which side changed it.
|
|
328
|
+
|
|
329
|
+
- `poli dev` in a terminal asks for each file: **Keep mine**, **Take the cloud's** or **Skip for now** (left out for the session, listed in the status line and on the preview page). A file the draft has and this folder does not (deleted here, or never synced) is asked with **Keep mine (delete it from the draft)**, and **Skip for now** as the default.
|
|
330
|
+
- In the printed list, such a file is marked `(not in this folder: keep-mine deletes it from the draft)`.
|
|
331
|
+
- `poli dev` without a terminal (piped, `concurrently`, a Procfile) and `poli sync` print the files and the commands that settle them, then exit `7`:
|
|
332
|
+
|
|
333
|
+
```
|
|
334
|
+
1 file(s) changed both here and in the cloud draft since the last sync:
|
|
335
|
+
templates/invoice/invoice.html
|
|
336
|
+
Keep your version:
|
|
337
|
+
poli sync --keep-mine -- templates/invoice/invoice.html
|
|
338
|
+
Or take the cloud's:
|
|
339
|
+
poli sync --take-theirs -- templates/invoice/invoice.html
|
|
340
|
+
```
|
|
270
341
|
|
|
271
342
|
### Live development
|
|
272
343
|
|
|
@@ -291,8 +362,9 @@ poli dev -d ./big.json # render every template against your own data
|
|
|
291
362
|
| Flag | Default | Meaning |
|
|
292
363
|
| -------------------- | ------------------ | ---------------------------------------------------------- |
|
|
293
364
|
| `-p, --port <n>` | `7654` | Port to bind on `127.0.0.1`. Walks upwards when it is busy. |
|
|
294
|
-
| `-d, --data <path>` | the template mock | JSON data file, same shape as `poli render -d
|
|
365
|
+
| `-d, --data <path>` | the template mock | JSON data file, same shape as `poli render -d`; saving it re-renders when it is inside the project. |
|
|
295
366
|
| `--no-open` | opens the browser | Skip launching a browser on start. |
|
|
367
|
+
| `--no-preview` | preview | Only sync: see [`poli dev --no-preview`](#poli-dev---no-preview). |
|
|
296
368
|
| `[template]` | first in manifest | Which template to show first. |
|
|
297
369
|
|
|
298
370
|
The served page gives you:
|
|
@@ -316,17 +388,25 @@ The served page gives you:
|
|
|
316
388
|
|
|
317
389
|
Notes:
|
|
318
390
|
|
|
319
|
-
- **No TTY required.**
|
|
320
|
-
|
|
391
|
+
- **No TTY required.** `poli dev` is a server and runs happily with its stdout
|
|
392
|
+
piped, so you can compose it into your own dev script:
|
|
321
393
|
|
|
322
394
|
```json
|
|
323
395
|
{ "scripts": { "dev": "concurrently \"poli dev --no-open\" \"vite\"" } }
|
|
324
396
|
```
|
|
325
397
|
|
|
398
|
+
- It syncs only a [confirmed link](#confirmed-links). In a terminal the first
|
|
399
|
+
run in a cloned folder asks first; piped, an unconfirmed folder is refused
|
|
400
|
+
with exit `2`: run `poli dev` once in a terminal, or `poli unlink`, then `poli link`.
|
|
326
401
|
- It binds to `127.0.0.1` only — the rendered draft is never exposed to the
|
|
327
402
|
local network.
|
|
328
|
-
-
|
|
329
|
-
|
|
403
|
+
- Only its own page can change the view: a `POST` from another site (or from
|
|
404
|
+
any client that sends neither `Sec-Fetch-Site: same-origin` nor the server's
|
|
405
|
+
own `Origin`) gets a `403`, and no other site can frame the page.
|
|
406
|
+
- On start it sends the files changed since the last sync, including those
|
|
407
|
+
changed while it was stopped, so the first render reflects your local files.
|
|
408
|
+
A folder with no [draft bases](#draft-bases) is reconciled first: nothing is
|
|
409
|
+
sent over the draft, and each file that differs is a [conflict](#conflicts).
|
|
330
410
|
- Failures are surfaced, not fatal: a render that errors, a rejected sync, a
|
|
331
411
|
broken `poli-page.json`, or a dropped connection leave the server up and the
|
|
332
412
|
page serving.
|
|
@@ -337,7 +417,7 @@ Notes:
|
|
|
337
417
|
|
|
338
418
|
#### `poli publish`
|
|
339
419
|
|
|
340
|
-
Publishes the local project, the files on disk, to an environment of your organization: `POST /v1/projects/<projectSlug>/publish`, with your `poli login` session and the manifest's `cloud.orgId
|
|
420
|
+
Publishes the local project, the files on disk, to an environment of your organization: `POST /v1/projects/<projectSlug>/publish`, with a service key in `POLI_PAGE_API_KEY` when one is set (see below), or else with your `poli login` session and the manifest's `cloud.orgId`; with a session, a manifest whose `cloud` ids do not all name the same project is refused before the upload (exit `6`, see [confirmed links](#confirmed-links)). The environment's copy of the project is replaced in place. There is no rollback: to go back, check out the earlier state from your own version control and publish again.
|
|
341
421
|
|
|
342
422
|
```bash
|
|
343
423
|
poli publish --env sandbox
|
|
@@ -353,12 +433,13 @@ poli publish --env live --yes # protected environment, no prompt (scripts)
|
|
|
353
433
|
| `--json` | Print the API response as JSON (also the default when stdout is not a TTY). |
|
|
354
434
|
|
|
355
435
|
- **Environment names** are 1-20 characters: lowercase letters, digits and single inner hyphens, starting with a letter. A name that breaks this rule is refused before any call (exit `2`). An environment that does not exist in the organization is refused with the list of the ones that do (exit `2`).
|
|
356
|
-
- **The bundle** is the project file set: `poli-page.json`, `tailwind.css`, the `.html`, `.json` and `.css` files under `templates/<slug>/`, the `.html` files under `partials/`,
|
|
357
|
-
- **
|
|
358
|
-
- **
|
|
436
|
+
- **The bundle** is the project file set: `poli-page.json`, `tailwind.css`, the `.html`, `.json` and `.css` files under `templates/<slug>/`, the `.html` files under `partials/`, the `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp` and `.svg` files under `assets/images/` and `assets/icons/` (the image types the engine renders), and the `.woff2`, `.woff`, `.ttf` and `.otf` files under `assets/fonts/`, extensions in any letter case. Anything else (`.gitignore`, `README.md`, `*.log`, `.DS_Store`) is left out, a file of another type under `assets/images/` or `assets/icons/` with a warning that names it (but not `.gitkeep`, `.keep`, `.DS_Store`, `Thumbs.db` or `desktop.ini`), and so is every `node_modules/`, `.git/`, `output/`, `dist/` and `.poli/` directory at any depth. Assets are sent base64-encoded, every other file as UTF-8. A bundle over 5 MiB, or a message over 500 characters, is refused before any call (exit `2`).
|
|
437
|
+
- **Limits.** Only `poli-page.json`, `tailwind.css`, `templates/`, `partials/` and `assets/` are walked, and every file's size is checked before any is read. A file over 4 MiB, more than 1000 files, or files adding up to more than 5 MiB fail the command before any call, naming the file or the limit (exit `2`); nothing is sent. These are the API's limits, and `poli link`, `poli dev` and `poli sync` apply them too.
|
|
438
|
+
- **Protected environments** (`live` by default) accept a publish from an owner or an admin only. In a terminal, `poli publish` asks for confirmation first; without a TTY it needs `--yes`. `CI=true` does not stand in for `--yes`. Without the role, the API refuses with `ENVIRONMENT_PROTECTED` (exit `5`).
|
|
439
|
+
- **With a service key** (`POLI_PAGE_API_KEY`; the key wins over a `poli login` session when both are there): the CLI calls `GET /v1/me`, then publishes to the manifest's `cloud.projectSlug` with no organization header, since the key carries its organization. `--env` must name the key's own environment, or the publish is refused before any upload, naming it (exit `2`). When the manifest has a `cloud.orgId`, the key must belong to that organization (the one `GET /v1/me` names), or the publish is refused before any upload, naming both organizations (exit `2`): the key would otherwise publish to a project of the same slug in its own organization. A standard key is refused with "Standard API keys can only render. Use a service key or `poli login`." (exit `5`); with a session stored, the standard-key, `--env` and organization refusals all say to unset `POLI_PAGE_API_KEY` to use the session instead. There is no prompt and no environment check on the CLI side: the API applies the protected-environment rule, and a service key without the `admin` role gets `ENVIRONMENT_PROTECTED` (exit `5`).
|
|
359
440
|
- **One publish at a time** per project and environment: while one runs, a second gets `PUBLISH_IN_PROGRESS` (exit `3`). It is not retried; run it again once the first one is done.
|
|
360
441
|
|
|
361
|
-
On success it prints the environment, the project, the short bundle hash, the file count
|
|
442
|
+
On success it prints the environment, the project, the short bundle hash, the file count, the publish log id and the credential used (`POLI_PAGE_API_KEY` or `session (poli login)`).
|
|
362
443
|
|
|
363
444
|
#### `poli env list`
|
|
364
445
|
|
|
@@ -429,7 +510,7 @@ Spec rules:
|
|
|
429
510
|
Flags:
|
|
430
511
|
|
|
431
512
|
- `--data <file>` — JSON data overrides the mock
|
|
432
|
-
- `-o <file>` — output PDF path. Incompatible with `--no-download`
|
|
513
|
+
- `-o <file>` — output PDF path. Incompatible with `--no-download`. Without it the PDF goes to `output/<name>/<format-orientation>/<name>.pdf` in the project, which is refused if it is a symlink or resolves outside the project through one; the PDF is written to a temp file and renamed into place. `-o` is written as given
|
|
433
514
|
- `--no-download` — skip the presigned URL fetch (CI/CD pipelines). Environment renders only
|
|
434
515
|
- `--json` — force JSON output even in a TTY
|
|
435
516
|
|
|
@@ -492,9 +573,11 @@ poli documents thumbnails doc_abc123 -o ./out
|
|
|
492
573
|
|
|
493
574
|
Flags: `-w/--width`, `-f/--format png|jpeg`, `-q/--quality`, `--pages 1,3`, `-o/--output`, `--json`.
|
|
494
575
|
|
|
576
|
+
The default folder is `./output/thumbnails/<id>/`, with `page-<n>.<ext>` files. The `<id>` must be letters, digits, `.`, `_` and `-`, starting with a letter or digit, without `..`; another one is refused before any request (exit `2`). A page number from the API that is not a positive integer refuses the whole set before anything is written. A default file that is a symlink, or resolves outside the current directory through one, refuses the whole set before any page is written; `-o` is written as given.
|
|
577
|
+
|
|
495
578
|
#### `poli documents preview <id>`
|
|
496
579
|
|
|
497
|
-
Fetch the stored canonical HTML re-wrapped as preview-mode (free, no quota cost). Default writes the file at `./output/documents/<id>.preview.html` and opens the browser.
|
|
580
|
+
Fetch the stored canonical HTML re-wrapped as preview-mode (free, no quota cost). Default writes the file at `./output/documents/<id>.preview.html` and opens the browser: the `<id>` is checked as for `thumbnails` before any request, and that file is refused if it is a symlink or resolves outside the current directory through one (`-o` is written as given). The written file carries a Content-Security-Policy meta that blocks scripts, network loads, form submissions and `<base>` (inline styles and `data:` images and fonts still render; a `<meta http-equiv="refresh">` in the HTML can still navigate away, which CSP cannot block; a second meta turns off DNS prefetching of hyperlinks, which CSP does not cover, but a `<link rel="dns-prefetch">` can still resolve its hostname); `--json` prints the HTML as received.
|
|
498
581
|
|
|
499
582
|
```bash
|
|
500
583
|
poli documents preview doc_abc123
|
|
@@ -523,8 +606,8 @@ poli documents preview doc_abc123 -o ./preview.html
|
|
|
523
606
|
"templates": [
|
|
524
607
|
{
|
|
525
608
|
"name": "invoice",
|
|
526
|
-
"template": "
|
|
527
|
-
"mock": "
|
|
609
|
+
"template": "invoice.html",
|
|
610
|
+
"mock": "invoice.json",
|
|
528
611
|
"format": "A4",
|
|
529
612
|
"orientation": "portrait"
|
|
530
613
|
}
|
|
@@ -538,8 +621,17 @@ poli documents preview doc_abc123 -o ./preview.html
|
|
|
538
621
|
}
|
|
539
622
|
```
|
|
540
623
|
|
|
624
|
+
Each `templates[]` entry is checked when the manifest is read, and a bad value fails with the field it is in (`templates[0].mock: …`):
|
|
625
|
+
|
|
626
|
+
- `name` — the template's folder under `templates/`: lowercase letters, digits and inner `-`.
|
|
627
|
+
- `template`, `mock` — paths relative to `templates/<name>/`, made of segments of letters, digits, `.`, `_` and `-`, each starting with a letter or digit (no `..`, absolute path, `\`, `?`, `#` or `%`). The files are read only when they resolve inside the project, symlinks included.
|
|
628
|
+
- `format` (default `A4`) — one of `A3`, `A4`, `A5`, `A6`, `B4`, `B5`, `Letter`, `Legal`, `Tabloid`, `Statement`, `Executive`, `Folio`, in any letter case.
|
|
629
|
+
- `orientation` (default `portrait`) — `portrait` or `landscape`, in any letter case.
|
|
630
|
+
|
|
541
631
|
The `cloud:` block is written by `poli link`, removed by `poli unlink`. **No API keys here** — the credentials file (or `POLI_PAGE_API_KEY`) carries the secret.
|
|
542
632
|
|
|
633
|
+
`cloud.orgId` and `cloud.projectId` must be UUIDs (8-4-4-4-12 hex digits): any other value makes the manifest invalid (`Invalid poli-page.json — cloud.projectId: must be a UUID`, from every command that reads it), so a hand-edited id cannot change the API path the CLI calls with your session. `poli unlink` still removes such a block, and `poli init --starter` ignores the starter's own `cloud:` block. A `cloud.projectSlug` of `.` or `..` is refused by `poli publish` (`Invalid project ID.`).
|
|
634
|
+
|
|
543
635
|
A manifest from before environments may still carry `project.version` or `cloud.track`. Both are ignored, and dropped the next time the CLI writes the file (`poli link`, `poli unlink`, `poli new`).
|
|
544
636
|
|
|
545
637
|
---
|
|
@@ -550,14 +642,16 @@ A manifest from before environments may still carry `project.version` or `cloud.
|
|
|
550
642
|
|
|
551
643
|
| Variable | Effect |
|
|
552
644
|
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
553
|
-
| `POLI_PAGE_API_KEY` | Single env var for any API key in CI/CD: `pp_<environment>_` followed by 32 lowercase hex characters, checked in full before any call. The key renders only its own environment; a service key also publishes to it. **Precedence**: when a credentials file is also present, the
|
|
554
|
-
| `POLI_API_URL` | Override the API base URL (precedence: `--api-url` flag → `POLI_API_URL` → `poli-page.json` `cloud.apiUrl
|
|
645
|
+
| `POLI_PAGE_API_KEY` | Single env var for any API key in CI/CD: `pp_<environment>_` followed by 32 lowercase hex characters, checked in full before any call. The key renders only its own environment; a service key also publishes to it. **Precedence**: when a credentials file is also present, the key wins for `whoami`, `publish`, `render` and `documents`. |
|
|
646
|
+
| `POLI_API_URL` | Override the API base URL (precedence: `--api-url` flag → `POLI_API_URL` → `poli-page.json` `cloud.apiUrl`, when allowed (see below) → `~/.polipage/credentials` `apiUrl` → default `https://api.poli.page`). The URL must be an origin only (no user, path, query or hash) on `https://poli.page` or `https://*.poli.page`; anything else exits `2` before any request. `poli-page.json` `cloud.apiUrl` is ignored, with a warning, unless it equals the stored `apiUrl` or the default: a cloned folder cannot choose where your credentials go. A session is only sent to the API origin that issued it; log in again to use another one. |
|
|
647
|
+
| `POLI_ALLOW_INSECURE_API` | Set to `1` to allow a local API URL (`http://localhost`, `http://127.0.0.1`), like `--allow-insecure-api`. |
|
|
555
648
|
| `NO_COLOR` | Disable ANSI colors (Unix standard). |
|
|
556
|
-
| `CI` |
|
|
649
|
+
| `CI` | Not read. `CI=true` is not consent: without a TTY, a prompt needs `--yes`. |
|
|
557
650
|
|
|
558
651
|
### Common flags
|
|
559
652
|
|
|
560
|
-
- `--api-url <url>` — override the API base URL for one invocation
|
|
653
|
+
- `--api-url <url>` — override the API base URL for one invocation (a Poli Page origin; see `POLI_API_URL`)
|
|
654
|
+
- `--allow-insecure-api` — allow a local API URL (`localhost`, `127.0.0.1`) for one invocation
|
|
561
655
|
- `-y` / `--yes` — skip confirmation prompts
|
|
562
656
|
- `-h` / `--help` — show help for any command or sub-command
|
|
563
657
|
- `-v` / `--version` — print the CLI version and exit
|
|
@@ -574,9 +668,9 @@ Every command that returns a payload (renders, descriptors, publishes) follows t
|
|
|
574
668
|
|
|
575
669
|
Either the summary **or** the JSON — never both at once. Errors always go to stderr with a clear message.
|
|
576
670
|
|
|
577
|
-
Commands that take this contract: `render`, `documents get`, `documents preview`, `documents thumbnails`, `whoami`, `publish`, `env list`, `env remove-project`, `init --starter`.
|
|
671
|
+
Commands that take this contract: `render`, `documents get`, `documents preview`, `documents thumbnails`, `whoami`, `publish`, `env list`, `env remove-project`, `init --starter`, `clone`, `sync`.
|
|
578
672
|
|
|
579
|
-
Imperative commands (`init` without `--starter`, `new`, `link`, `unlink`, `logout`, `documents delete`, `
|
|
673
|
+
Imperative commands (`init` without `--starter`, `new`, `link`, `unlink`, `logout`, `documents delete`, `login`) don't have a JSON payload to forward: they just acknowledge with a `✓` line on success.
|
|
580
674
|
|
|
581
675
|
---
|
|
582
676
|
|
|
@@ -588,9 +682,10 @@ Imperative commands (`init` without `--starter`, `new`, `link`, `unlink`, `logou
|
|
|
588
682
|
| `1` | Recoverable inconsistency (already logged in, already linked) |
|
|
589
683
|
| `2` | Invalid usage (bad args, template not found, project not published in that environment, non-TTY context where TTY is required) |
|
|
590
684
|
| `3` | Network / API error (timeout, 5xx, unspecified 4xx) |
|
|
591
|
-
| `4` | Not authenticated
|
|
592
|
-
| `5` | Not authorized (insufficient role, protected environment, `THUMBNAILS_NOT_AVAILABLE`)
|
|
593
|
-
| `6` | Invalid local state (no project, project not linked, empty folder where required)
|
|
685
|
+
| `4` | Not authenticated: run `poli login` or set `POLI_PAGE_API_KEY`; or the API answered `MISSING_API_KEY`, `INVALID_API_KEY` or `API_KEY_EXPIRED` |
|
|
686
|
+
| `5` | Not authorized (insufficient role, protected environment, `PROJECT_OUT_OF_SCOPE`, `THUMBNAILS_NOT_AVAILABLE`) |
|
|
687
|
+
| `6` | Invalid local state (no project, invalid `poli-page.json`, project not linked, empty folder where required) |
|
|
688
|
+
| `7` | Conflict: files changed both here and in the cloud draft, not settled (see [conflicts](#conflicts)) |
|
|
594
689
|
|
|
595
690
|
These map to the centralised `ExitCode` constants in `src/exit-codes.ts`. Every handler routes errors through `errorToExitCode(err)`.
|
|
596
691
|
|
|
@@ -687,27 +782,55 @@ Either run `poli login` interactively, or export `POLI_PAGE_API_KEY` for CI use.
|
|
|
687
782
|
|
|
688
783
|
### `POLI_PAGE_API_KEY must be a Poli Page API key: \`pp_<environment>_…\`...`
|
|
689
784
|
|
|
690
|
-
You set the variable but its value is not a whole key: `pp_`, the environment name, `_`, then 32 lowercase hex characters. Copy the key again, or create one from the dashboard's API keys page. Exit code `4`.
|
|
785
|
+
You set the variable but its value is not a whole key: `pp_`, the environment name, `_`, then 32 lowercase hex characters. Copy the key again, or create one from the dashboard's API keys page. If you are logged in, the key wins over your session while it is set, so a malformed key is refused even then (the message then says so): fix it, or unset `POLI_PAGE_API_KEY` to use the session. Exit code `4`.
|
|
691
786
|
|
|
692
787
|
### `Standard API keys can only render. Use a service key or \`poli login\`.`
|
|
693
788
|
|
|
694
|
-
`poli publish` with `POLI_PAGE_API_KEY` set to a standard key. Only a service key, or a `poli login` session, can publish. Exit code `5`.
|
|
789
|
+
`poli publish` with `POLI_PAGE_API_KEY` set to a standard key. Only a service key, or a `poli login` session, can publish. If you are already logged in, the key wins over your session while it is set (the message then says so): unset `POLI_PAGE_API_KEY` to publish with the session. Exit code `5`.
|
|
695
790
|
|
|
696
791
|
### `This service key publishes to "<a>" only, not "<b>"...`
|
|
697
792
|
|
|
698
|
-
A service key publishes into its own environment only. Pass `--env <a>`, or use a service key for `<b>`. Exit code `2`.
|
|
793
|
+
A service key publishes into its own environment only. Pass `--env <a>`, or use a service key for `<b>`. If you are logged in, the key wins over your session while it is set (the message then says so): unset `POLI_PAGE_API_KEY` to publish with the session. Exit code `2`.
|
|
794
|
+
|
|
795
|
+
### `This API key belongs to organization "<name>" (<slug>, <id>), but this folder is linked to organization "<slug>" (<id>)...`
|
|
796
|
+
|
|
797
|
+
`poli publish` with `POLI_PAGE_API_KEY` set to a key of another organization than the manifest's `cloud.orgId`. Since a key publishes to `cloud.projectSlug` in its own organization, the CLI refuses before any upload rather than publish to a same-slug project there. Use a service key of the linked organization, or, if the folder belongs to the key's organization, run `poli unlink`, then `poli link`. If you are logged in to the linked organization, the key wins over your session while it is set (the message then says so): unset `POLI_PAGE_API_KEY` to publish with the session. Exit code `2`.
|
|
798
|
+
|
|
799
|
+
### `Not authenticated: your session has expired or no API key was sent. Run \`poli login\`, or set POLI_PAGE_API_KEY...`
|
|
800
|
+
|
|
801
|
+
The API answered `MISSING_API_KEY`: it received no valid credential. Either your `poli login` session has expired (run `poli login` again), or no API key was sent (create a key on the dashboard's API keys page and export it as `POLI_PAGE_API_KEY`). Exit code `4`.
|
|
802
|
+
|
|
803
|
+
### `This API key is not valid: it is unknown or was revoked, its environment was deleted, or its service account was disabled or deleted...`
|
|
804
|
+
|
|
805
|
+
The API does not accept the key (`INVALID_API_KEY`): it never existed, it was revoked, its environment was deleted, or its service account was disabled or deleted. Create a new key on the dashboard's API keys page and update `POLI_PAGE_API_KEY`. Exit code `4`.
|
|
806
|
+
|
|
807
|
+
### `Your API key has expired. Create a new one in the dashboard (API keys) and update POLI_PAGE_API_KEY.`
|
|
808
|
+
|
|
809
|
+
The key passed its expiry date (`API_KEY_EXPIRED`). Create a new key on the dashboard's API keys page and update `POLI_PAGE_API_KEY`. Exit code `4`.
|
|
810
|
+
|
|
811
|
+
### `This API key is restricted to other projects. Use a key that includes this project, or create one in the dashboard (API keys).`
|
|
812
|
+
|
|
813
|
+
The key is limited to some projects and this folder's project is not one of them (`PROJECT_OUT_OF_SCOPE`). Use a key that includes the project, or create one on the dashboard's API keys page. Exit code `5`.
|
|
699
814
|
|
|
700
815
|
### `This folder isn't linked to a cloud project. Run \`poli link\` first.`
|
|
701
816
|
|
|
702
817
|
You're in session mode and the local manifest has no `cloud:` block. Either run `poli link`, or switch to api-key mode with `POLI_PAGE_API_KEY=pp_<environment>_…` (which carries the org context implicitly). Exit code `6`.
|
|
703
818
|
|
|
819
|
+
### `This folder is linked to project "<name>" (<slug>) of organization "<name>" (<slug>), a link you have not confirmed on this machine...`
|
|
820
|
+
|
|
821
|
+
`poli dev` or `poli sync` found a `cloud:` block (from a cloned repository, say) that is not in your `~/.polipage/links.json`, and had no terminal to ask in. Run the command once in a terminal and answer yes, or run `poli unlink`, then `poli link`. Exit code `2`. See [confirmed links](#confirmed-links).
|
|
822
|
+
|
|
823
|
+
### `The cloud block of poli-page.json names more than one project: ...`
|
|
824
|
+
|
|
825
|
+
The manifest's `orgSlug`, `orgId`, `projectId` and `projectSlug` do not all name the same project, so sync and publish would write to different ones. The message names the id that disagrees. Run `poli unlink`, then `poli link`. Exit code `6`.
|
|
826
|
+
|
|
704
827
|
### `API keys render a published environment: use \`name@<environment>\``
|
|
705
828
|
|
|
706
|
-
`poli render name` renders the draft, which only a `poli login` session can do. With an API key, render the key's environment: `poli render name@<environment>`. Exit code `2`.
|
|
829
|
+
`poli render name` renders the draft, which only a `poli login` session can do. With an API key, render the key's environment: `poli render name@<environment>`. If you are logged in, the key wins over your session while it is set (the message then says so): unset `POLI_PAGE_API_KEY` to render the draft. Exit code `2`.
|
|
707
830
|
|
|
708
831
|
### `This API key renders the \`<a>\` environment, not \`<b>\``
|
|
709
832
|
|
|
710
|
-
A key renders only the environment in its prefix. Render `name@<a>`, or use a key for `<b>`. Exit code `2`.
|
|
833
|
+
A key renders only the environment in its prefix. Render `name@<a>`, or use a key for `<b>`. If you are logged in, the key wins over your session while it is set (the message then says so): unset `POLI_PAGE_API_KEY` to render `<b>` with the session. Exit code `2`.
|
|
711
834
|
|
|
712
835
|
### `\`invoice@1.2.3\`: templates no longer have versions...`
|
|
713
836
|
|
|
@@ -721,7 +844,7 @@ The API renders the draft for a `poli login` session only. The CLI refuses a dra
|
|
|
721
844
|
|
|
722
845
|
`poli publish --env <env>` to a protected environment (`live` by default) by someone who is not an owner or admin of the organization, or with a service key without the `admin` role. Ask an owner or admin to publish, or use an `admin` service key. Exit code `5`.
|
|
723
846
|
|
|
724
|
-
Without a terminal, `Environment "<env>" is protected. Pass --yes to publish to it without a prompt.` means the confirmation could not be asked: pass `--yes` (`CI=true`
|
|
847
|
+
Without a terminal, `Environment "<env>" is protected. Pass --yes to publish to it without a prompt.` means the confirmation could not be asked: pass `--yes` (`CI=true` does not count as `--yes`). Exit code `2`.
|
|
725
848
|
|
|
726
849
|
### `PUBLISH_IN_PROGRESS`
|
|
727
850
|
|
|
@@ -735,13 +858,17 @@ Thumbnails via `poli documents thumbnails` are a paid-tier feature. Upgrade to S
|
|
|
735
858
|
|
|
736
859
|
Your org has crossed the monthly cap on `live` PDF renders (counted across `poli render` in any environment other than `sandbox` and `poli documents thumbnails` on a document of such an environment). Wait until the next billing period or raise the cap from your dashboard. Exit code `3`.
|
|
737
860
|
|
|
861
|
+
### `N file(s) changed both here and in the cloud draft since the last sync`
|
|
862
|
+
|
|
863
|
+
Someone changed these files in the cloud draft since your last sync, and you changed them too. Nothing was overwritten. Keep yours or take the draft's with the `poli sync` command printed under the message, or run `poli dev` in a terminal to be asked. Exit code `7`. See [conflicts](#conflicts).
|
|
864
|
+
|
|
738
865
|
### `503 ORGANIZATION_MIGRATING`
|
|
739
866
|
|
|
740
|
-
Your org is being migrated to a new tier. `poli
|
|
867
|
+
Your org is being migrated to a new tier. `poli dev` and `poli sync` retry automatically after 5s. Other commands surface the error: retry by hand once the migration completes (typically under a minute).
|
|
741
868
|
|
|
742
|
-
### `poli
|
|
869
|
+
### `poli dev` doesn't sync on save
|
|
743
870
|
|
|
744
|
-
Make sure
|
|
871
|
+
Make sure the file is in the project file set, as [`poli publish`](#poli-publish) defines the bundle (only some file types count under each folder, e.g. `templates/<slug>/logo.svg` does not): no other file triggers a sync, except the `poli dev --data` file. The watcher does not follow symlinks: a file reached through a symlinked directory is not watched. The watcher uses `chokidar` v5; if your editor saves via "atomic write + rename" (some Vim setups), the rename event fires within the debounce window and triggers a sync.
|
|
745
872
|
|
|
746
873
|
---
|
|
747
874
|
|
package/dist/api-client.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ export declare class ApiError extends Error {
|
|
|
3
3
|
readonly code: string;
|
|
4
4
|
readonly httpStatus: number;
|
|
5
5
|
readonly retryAfter?: number | undefined;
|
|
6
|
-
|
|
6
|
+
/** The parsed response body of an error answer, kept as received (never trusted). */
|
|
7
|
+
body: unknown;
|
|
8
|
+
constructor(code: string, httpStatus: number, message: string, retryAfter?: number | undefined, body?: unknown);
|
|
7
9
|
}
|
|
8
10
|
export declare class QuotaExceededError extends ApiError {
|
|
9
11
|
constructor(message: string, retryAfter?: number);
|
|
@@ -50,6 +52,38 @@ export declare class UnsupportedFileTypeError extends ApiError {
|
|
|
50
52
|
export declare class InsufficientRoleError extends ApiError {
|
|
51
53
|
constructor(message: string, retryAfter?: number);
|
|
52
54
|
}
|
|
55
|
+
export declare const API_KEY_MESSAGES: {
|
|
56
|
+
readonly MISSING_API_KEY: "Not authenticated: your session has expired or no API key was sent. Run `poli login`, or set POLI_PAGE_API_KEY to a key created in the dashboard (API keys).";
|
|
57
|
+
readonly INVALID_API_KEY: "This API key is not valid: it is unknown or was revoked, its environment was deleted, or its service account was disabled or deleted. Create a new one in the dashboard (API keys) and update POLI_PAGE_API_KEY.";
|
|
58
|
+
readonly API_KEY_EXPIRED: "Your API key has expired. Create a new one in the dashboard (API keys) and update POLI_PAGE_API_KEY.";
|
|
59
|
+
readonly PROJECT_OUT_OF_SCOPE: "This API key is restricted to other projects. Use a key that includes this project, or create one in the dashboard (API keys).";
|
|
60
|
+
};
|
|
61
|
+
export declare class MissingApiKeyError extends ApiError {
|
|
62
|
+
constructor(_message?: string, retryAfter?: number);
|
|
63
|
+
}
|
|
64
|
+
export declare class InvalidApiKeyError extends ApiError {
|
|
65
|
+
constructor(_message?: string, retryAfter?: number);
|
|
66
|
+
}
|
|
67
|
+
export declare class ApiKeyExpiredError extends ApiError {
|
|
68
|
+
constructor(_message?: string, retryAfter?: number);
|
|
69
|
+
}
|
|
70
|
+
export declare class ProjectOutOfScopeError extends ApiError {
|
|
71
|
+
constructor(_message?: string, retryAfter?: number);
|
|
72
|
+
}
|
|
73
|
+
export interface DraftConflict {
|
|
74
|
+
path: string;
|
|
75
|
+
/** The cloud's current hash of the file, or `null` when it no longer exists there. */
|
|
76
|
+
remoteSha256: string | null;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* `409 DRAFT_CONFLICT`: the sync touched files someone else changed since
|
|
80
|
+
* their base. Nothing was written. Exits 7.
|
|
81
|
+
*/
|
|
82
|
+
export declare class DraftConflictError extends ApiError {
|
|
83
|
+
readonly exitCode = 7;
|
|
84
|
+
readonly conflicts: DraftConflict[];
|
|
85
|
+
constructor(message: string, retryAfter?: number, body?: unknown);
|
|
86
|
+
}
|
|
53
87
|
export interface DeviceRequestResult {
|
|
54
88
|
deviceCode: string;
|
|
55
89
|
userCode: string;
|
|
@@ -87,11 +121,17 @@ export interface ProjectFileEntry {
|
|
|
87
121
|
path: string;
|
|
88
122
|
encoding: 'utf8' | 'base64';
|
|
89
123
|
content: string;
|
|
124
|
+
/** The hash the CLI last saw on the cloud; `null` = the file was absent. Omitted = unconditional. */
|
|
125
|
+
baseSha256?: string | null;
|
|
90
126
|
}
|
|
91
127
|
export interface PatchFilesBody {
|
|
92
128
|
added: ProjectFileEntry[];
|
|
93
129
|
modified: ProjectFileEntry[];
|
|
94
|
-
|
|
130
|
+
/** A path is an unconditional delete; the object form carries the base the CLI last saw. */
|
|
131
|
+
deleted: Array<string | {
|
|
132
|
+
path: string;
|
|
133
|
+
baseSha256: string | null;
|
|
134
|
+
}>;
|
|
95
135
|
}
|
|
96
136
|
/** `POST /v1/projects/:project/publish` body: the whole local project. */
|
|
97
137
|
export interface PublishBody {
|
|
@@ -147,6 +187,20 @@ export interface ProjectEnvironmentState {
|
|
|
147
187
|
}
|
|
148
188
|
export interface PatchFilesResult {
|
|
149
189
|
syncedAt: string;
|
|
190
|
+
/** The cloud's hash of every file this sync wrote. */
|
|
191
|
+
files: Array<{
|
|
192
|
+
path: string;
|
|
193
|
+
sha256: string;
|
|
194
|
+
}>;
|
|
195
|
+
}
|
|
196
|
+
/** One file of the cloud draft, with a short-lived presigned download URL. */
|
|
197
|
+
export interface DraftFile {
|
|
198
|
+
path: string;
|
|
199
|
+
size: number;
|
|
200
|
+
sha256: string;
|
|
201
|
+
/** Presigned: never log or print it. */
|
|
202
|
+
url: string;
|
|
203
|
+
expiresAt: string;
|
|
150
204
|
}
|
|
151
205
|
export interface DocumentDescriptor {
|
|
152
206
|
documentId: string;
|
|
@@ -226,6 +280,8 @@ export interface ApiClient {
|
|
|
226
280
|
}>;
|
|
227
281
|
deviceRequest(): Promise<DeviceRequestResult>;
|
|
228
282
|
devicePoll(deviceCode: string): Promise<DevicePollResult>;
|
|
283
|
+
/** `POST /api/auth/sign-out`: revokes the session server-side. */
|
|
284
|
+
signOut(session: string): Promise<void>;
|
|
229
285
|
getOrganizations(session: string): Promise<Array<{
|
|
230
286
|
id: string;
|
|
231
287
|
name: string;
|
|
@@ -235,11 +291,15 @@ export interface ApiClient {
|
|
|
235
291
|
id: string;
|
|
236
292
|
name: string;
|
|
237
293
|
slug: string;
|
|
294
|
+
access?: string;
|
|
295
|
+
role?: string;
|
|
238
296
|
}>>;
|
|
239
297
|
createProject(session: string, orgId: string, payload: Record<string, unknown>): Promise<{
|
|
240
298
|
id: string;
|
|
241
299
|
}>;
|
|
242
300
|
patchFiles(session: string, orgId: string, projectId: string, body: PatchFilesBody): Promise<PatchFilesResult>;
|
|
301
|
+
/** `GET …/projects/:id/files`: the draft's files with presigned download URLs. */
|
|
302
|
+
listDraftFiles(session: string, orgId: string, projectId: string): Promise<DraftFile[]>;
|
|
243
303
|
listEnvironments(authorization: string, orgId: string): Promise<EnvironmentInfo[]>;
|
|
244
304
|
getProjectEnvironments(session: string, orgId: string, projectId: string): Promise<ProjectEnvironmentState[]>;
|
|
245
305
|
/**
|