@svartz/plugin-submissions
48 exported symbols.
Classes
| c CommitsUnavailable | GitHub can't be asked right now: the shared pause holds, this reader's requests are spent, or GitHub failed. |
Interfaces
| i BrowserOptions | Settings the browser script receives. |
| i BuildData | What the build records for the server: never sent to the browser. |
| i Commit | A commit on the content branch. |
| i CommitReader | Reads one request's worth of commits. Make one per request with `commitReader`. |
| i CommitSource | What reading a vault's commits takes: JSON, for the reader's server data. Holds no secret, only where they are. |
| i DestinationResponse | `GET <endpoint>/destination/?folder=<folder>&title=<title>` answers this for a new page. |
| i EditRequest | `POST <endpoint>/edit/` takes this JSON body. |
| i ErrorResponse | Every failure answers with this JSON body; `message` is written for the reader. |
| i LinksResponse | `GET <endpoint>/links/` answers this: the published notes, never password-protected or hidden ones, and the attachments the site publishes. |
| i LinkTarget | A published note a wikilink can name. The Split preview resolves links to it by `slug`, `path` and `aliases`, as the build does, and links them to `href`. |
| i NewPageRequest | `POST <endpoint>/new/` takes this JSON body. The server derives the file path from `folder` and `title`. |
| i RateLimitOptions | |
| i Restore | One page's content to commit back. |
| i Restorer | Commits for one request. Make one per request with `restorer`. |
| i RouteHolder | The page holding a route: its slug, which permissions are checked on, and its URL below the deployment base, `null` when hidden. |
| i SavedEdits | The edits a vault's site saved among those asked about, each with the id of the account that saved it, or `null`. |
| i SourceResponse | `GET <endpoint>/source/?page=<href>` answers this. |
| i SubmissionsOptions | |
| i TurnstileOptions | The submission guard. Every submission passes a rate limit, keyed by the signed-in identity or else the client's IP, and is refused when it has neither. When sign-in is required, anonymous submissions are refused; otherwise, when Turnstile is configured, they must also carry a token Cloudflare verifies. Runs before any GitHub call. |
| i VaultRecords | Where a vault's sync keeps its records: the D1 binding, the repository, and the vault's folder in it. |
Types
| t Credentials | Exactly one kind of GitHub credentials: a token, or a GitHub App. |
| t Destination | Where a save goes for the reader asking: `commit` straight to the branch, so it goes live with the next deploy, or `pull-request`, for review. `null` when they can't save there as they are now, such as a guest who must sign in. |
| t EditResponse | |
| t FileAt | The content at a commit, or why there is none to show. |
| t Mode | Which saves may commit. `permission` commits for whoever holds `submissions:commits:write` on the page and opens a pull request for the rest; `commit` refuses the rest instead; `pull-request` never commits. |
| t Restored | What `Restorer.restore` did: committed, or why not. `unchanged` when the branch already held the content, `changed` when its file isn't the one the caller read, `protected` when a rule for the branch refuses the commit, `busy` when the branch moved on meanwhile. Only `commit` moved the branch. |
| t RouteClaims | The routes the last build allocated, which a note's frontmatter can claim: JSON, for server data. |
| t ServerOptions | The plugin's server options, as written into the server bundle. |
Functions
| f changedFiles | The vault files each of `commits` (SHAs) changed, as vault paths, for those the mirror of the vault `records` describes holds with their files. In one query; none when the binding is missing. |
| f commitAttribution | The account a commit is authored as, with its linked GitHub account as co-author, and the App's bot that commits it. |
| f commitReader | Reads commits for one vault. The answer makes a `CommitReader` per request; installation tokens and file contents are kept across requests in this worker. Pass `token` to share one `sourceToken` with a writer. |
| f commitSource | What reading the vault's commits takes, or `undefined` when no submissions plugin keeps its mirror. Call it from `emitArtifacts` with `enforce: "post"`: the vault's folder in the repository is what the submissions plugin's own `emitArtifacts` read from git. |
| f isVaultSubmission | Whether pull request `number` is a submission the site saved for the vault `records` describes: what that vault's `POST close/` accepts. `false` when the binding is missing. The moderation plugin asks before it offers Close. |
| f mirrorsCommits | Whether one of a vault's `plugins` is a submissions plugin keeping the GitHub mirror. For a plugin's `forVault`. |
| f mount | Adds Edit to the page actions of every editable note, New page to the site actions of every page, Create your page to the account page of a reader without a user page, and Edit page to a submission in My submissions while it takes follow-up edits. The editor itself loads on first use, or at once when the reader comes back from signing in with a draft for this page. On a submission, it also keeps an unsent reply while its form posts. |
| f renderRevision | `markdown` rendered as the note at `options.path`, ready to put in a page. |
| f restorer | Restores a vault's pages. Only a GitHub App commits as an account, so with a token `commits` is false and every restore throws. `token` shares a `sourceToken` with the vault's commit reader. |
| f routeClaimsOf | The routes the vault's pages hold, hidden and protected ones included, which a page's frontmatter can claim: what `@svartz/plugin-submissions/restore` checks a restored revision against. From `emitArtifacts` with `enforce: "post"`, as `commitSource`; `undefined` without the submissions plugin. |
| f savedEdits | Which of `commits` (SHAs) and `pulls` (numbers) the site saved for the vault `records` describes, and the account behind each: whoever made the commit, or opened the pull request with its first save. `null` for a save by someone without an account. In one query; none are saved when the binding is missing. |
| f sourceToken | The token `source`'s credentials authenticate with: the configured one, or the App's installation token, kept. |
| f submissions | Let readers edit any published Markdown note, or add one in a published folder, as a pull request on `repo`. |
| f wasPublic | Whether the build would have published a note with `markdown`'s frontmatter, unprotected: not a draft, not private, in no password group. A revision it would have hidden stays hidden, though the page is public now. Frontmatter the build couldn't read counts as hidden. |
Variables
| v default | |
| v GITHUB_PAGE_SIZE | Commits per page of GitHub's list, its most. |
| v MAX_FILE_BYTES | File content larger than this isn't read; a note the editor accepts is far smaller. |
| v MAX_GITHUB_READS | GitHub requests one reader may make: what the costliest page, a diff of two revisions the mirror doesn't hold, needs. That is the default branch's name, when neither config nor the mirror knows it, then for each revision the check that the branch holds it, the commit, and the page's file at it. |
| v RECENT_PAGE_SIZE | Commits per page of `CommitReader.recent`. |