@swell/cli
Version:
Swell's command line interface/utility
40 lines (39 loc) • 1.69 kB
TypeScript
import { GroupInfo } from './table.js';
export interface ParsedContentId {
middle: string;
name: string;
prefix: 'app' | 'custom';
}
/**
* Parse a content view identifier of the form `app.<appPart>.<name>` or
* `custom.<source>.<name>`. Returns null for anything that doesn't match.
*/
export declare function parseContentId(id: string): ParsedContentId | null;
/**
* Produce the column-1 paste-back key for a content view. Rewrites
* `app.<hex>.<name>` to `app.<slug>.<name>` when the slug is known; passes
* `custom.*` and unresolvable app ids through unchanged (both remain valid
* paste-back forms against the detail endpoint).
*/
export declare function resolveContentKey(id: string, appSlugById: Record<string, string>): string;
/**
* Group a content view record for the vertical split. Records with no
* `app_id` belong to the platform's `custom.*` source and land in a
* single `<custom>` section at the top of the output.
*/
export declare function groupContentRecord(record: {
app_id?: string;
}, appSlugById: Record<string, string>): GroupInfo;
/**
* Translate a user-supplied content identifier into the unresolved API
* form. Accepts:
* - `custom.<source>.<name>` → unchanged
* - `app.<hex>.<name>` → unchanged (already unresolved form)
* - `app.<slug>.<name>` → slug resolved to hex
* - bare `<name>` → combined with scope.appId to `app.<hex>.<name>`
*
* `resolveAppId` is injected so this function is testable without a live API.
*/
export declare function reverseResolveContentId(identifier: string, scope: {
appId?: string;
}, resolveAppId: (slug: string) => Promise<string>): Promise<string>;