Skip to content

Rewrite Visual Editor API JSDoc from the implementation#37

Open
EllaCloudCannon wants to merge 8 commits into
mainfrom
docs/jsdocs-review
Open

Rewrite Visual Editor API JSDoc from the implementation#37
EllaCloudCannon wants to merge 8 commits into
mainfrom
docs/jsdocs-review

Conversation

@EllaCloudCannon

@EllaCloudCannon EllaCloudCannon commented Jun 16, 2026

Copy link
Copy Markdown

PLEASE DELETE HANDOFF DOC BEFORE MERGE

Summary

Replaces the Visual Editor API's JSDoc (src/index.d.ts) with a full rewrite grounded in the actual app implementation, plus a HANDOFF.md documenting type-level follow-ups the comment pass can't make. The previous JSDoc was AI-generated and unreliable (e.g. @throws {FileNotFoundError} / {CollectionNotFoundError} that are never thrown). Since platform-documentation generates the developer reference directly from this file, these comments are the published reference.

What changed

src/index.d.ts — JSDoc rewrite (comments + one type change):

  • Removed hallucinated @throws; only the real Error cases documented, with actual failure modes described instead (resolve-undefined, the items() falsy-key hang).
  • @example on every method and property; consistent present-tense voice; CloudCannon terminology capitalized ("Configuration File", "Team Member", "Data Panel"); no em dashes.
  • Object descriptions follow a consistent shape — Represents… / Returned by / Accessed through… / Additionally, you can…; property descriptions are blunt and verb-first (Holds… / Provides…).
  • Event listeners documented on all interfaces, each with a named-handler example; the event.detail payload (isNew, sourcePath) documented once in the reference's Events section rather than repeated.
  • Collection.items() / Dataset.items() document their (verified, asymmetric) bad-key behavior: a non-matching Collection key resolves to [], while a Dataset hangs.
  • File.data/content reframed as entry points (no longer duplicate the child get() examples); FileData/FileContent lead with "Accessed through a File's data/content property".
  • data.upload documents its save semantics and uses a self-contained example; edit reworded; EditOptions.slug generalized to cover both edit and upload; void mutators say "Has no effect if the file does not exist".
  • Removed a false datasets() reference from Dataset; added files() to the File "Returned by" list.
  • One type change (the only signature edit): narrowed File.get(), claimLock(), releaseLock() to … | undefined, matching the verified handler behavior (the message handler returns undefined for any unresolved sourcePath).

HANDOFF.md (new): maintainer follow-ups that require type/code changes, tiered by priority:

  • Tier 1 (verified correctness): FileContent.get() throws on a missing file instead of resolving undefined (client bug); data.upload surfaces style/position it ignores; FileMetadata.last_modified is typed string | Date but the client only ever receives a string (JSON boundary); FileData/FileContent addEventListener never fire (no :data:/:content: events are dispatched).
  • Tier 2 (confirm against implementation): AddArrayItemOptions.value optionality; whether a datasets() method should exist.
  • Tier 3 (optional polish): typing event.detail; naming inline option literals (GetDataOptions, PanelPosition); a V0 listener-union cleanup.

Each Tier 1 item cites the specific app code it was verified against.

@EllaCloudCannon EllaCloudCannon marked this pull request as ready for review June 19, 2026 04:04
@EllaCloudCannon EllaCloudCannon changed the title Rewrite the Visual Editor API JSDoc from the implementation Rewrite Visual Editor API JSDoc from the implementation Jun 19, 2026
Comment thread src/index.d.ts
Comment on lines +17 to +22
/**
* A stable identifier for the panel, returned as the `panelId` and passed to
* `destroyCustomDataPanel` to close it. When omitted, CloudCannon generates a
* seven-character base-36 id (digits `0`-`9` and lowercase `a`-`z`, e.g.
* `k4j92xq`). Treat it as an opaque token.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description makes me think there is something in the code called panelId, but I don't think that's the case? I also don't really know what "opaque token" means, but that might just be me?

Comment thread src/index.d.ts
Comment on lines +17 to +22
/**
* A stable identifier for the panel, returned as the `panelId` and passed to
* `destroyCustomDataPanel` to close it. When omitted, CloudCannon generates a
* seven-character base-36 id (digits `0`-`9` and lowercase `a`-`z`, e.g.
* `k4j92xq`). Treat it as an opaque token.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* A stable identifier for the panel, returned as the `panelId` and passed to
* `destroyCustomDataPanel` to close it. When omitted, CloudCannon generates a
* seven-character base-36 id (digits `0`-`9` and lowercase `a`-`z`, e.g.
* `k4j92xq`). Treat it as an opaque token.
*/
/**
* A stable identifier for the new panel. This can be passed to `destroyCustomDataPanel`
* to close it. When omitted, CloudCannon generates a seven-character base-36 id
* (digits `0`-`9` and lowercase `a`-`z`, e.g.`k4j92xq`).
*/

Comment thread src/index.d.ts
/** The slug of the target field. */
slug: string;
/** Optional style information */
/** Optional style hint for the editing surface. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** Optional style hint for the editing surface. */
/** Set to "sidebar" to open in the Data Editor sidebar instead of a Data Panel. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is right???

Comment thread src/index.d.ts
* In this example, we read when the file was created.
* ```javascript
* const { created_at } = await api.currentFile().metadata();
* console.log(created_at);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* console.log(created_at);
* console.log(`Created at ${new Date(created_at).toLocaleString()}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly more dynamic example to show it's a date string? All good either way, just an idea

Comment thread src/index.d.ts
file(path: string): CloudCannonVisualEditorAPIV1File;
/**
* Returns the Collection with the given key, as configured under
* `collections_config` in your CloudCannon Configuration File.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a nitpick, but "Collection" could mean the items in the collection, or the configuration for the collection. Maybe we could say that here it means an object with methods for listing collection items and listening to changes?

Comment thread src/index.d.ts
Comment on lines +1182 to +1185
* Opens a custom Data Panel in the Visual Editor and resolves with its
* `panelId`. When `options.id` is omitted, CloudCannon generates a
* seven-character base-36 id. Pass the returned `panelId` to
* `destroyCustomDataPanel` to close the panel.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Opens a custom Data Panel in the Visual Editor and resolves with its
* `panelId`. When `options.id` is omitted, CloudCannon generates a
* seven-character base-36 id. Pass the returned `panelId` to
* `destroyCustomDataPanel` to close the panel.
* Opens a custom Data Panel in the Visual Editor and resolves with an
* ID corresponding to that panel. Pass the returned `panelId` to
* `destroyCustomDataPanel` to close the panel.

Comment thread src/index.d.ts
*/
createCustomDataPanel(options: CreateCustomDataPanelOptions): Promise<string>;
/**
* Closes the custom Data Panel with the given `panelId`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is actually fine, but the camelcase and backticks on "panelId" make me think it's supposed to be an actual variable name, and I think it's just a concept?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants