@swell/cli
Version:
Swell's command line interface/utility
62 lines (61 loc) • 2.54 kB
TypeScript
import { GroupInfo } from './table.js';
export interface SettingRecord {
api?: string;
app_id?: string | null;
deprecated?: boolean | null;
fields?: Record<string, unknown>;
id?: string;
label?: string;
name?: string;
}
/**
* Settings identifier grammar (calibrated against `/data/:settings`).
*
* `app.<slug-or-hex>` → kind 'app' — slug must be translated to hex before
* a path GET; hex passes through.
* anything else valid → kind 'path' — direct path GET. The endpoint resolves
* bare system names (`taxes`), bare app
* hexes, and full dotted ids
* (`com.taxes`) on the path. No `name`
* query needed.
* anything else → kind 'invalid'
*
* The 3-segment `app.<slug>.<name>` form is rejected: settings collapse to one
* record per app at push time, so there is no sub-section identity the API can
* resolve back. Users wanting a single section run `--json | jq`.
*/
export type ParsedSettingsKey = {
kind: 'app';
ref: string;
} | {
kind: 'path';
segment: string;
} | {
input: string;
kind: 'invalid';
};
export declare function parseSettingsKey(input: string): ParsedSettingsKey;
/**
* Produce the column-1 paste-back key for a settings record.
*
* System (no app_id): `record.name` (e.g. `taxes`).
* App with slug: `app.<slug>`.
* App without slug: `app.<hex>` (still pasteable — `app.<hex>` resolves).
*
* App records carry `name === app_id` (the hex), which is meaningless to a
* human; we never surface it. Ultimate fallback is `record.id` for degenerate
* records that have neither `app_id` nor `name`.
*/
export declare function formatSettingsKey(record: SettingRecord, appSlugById: Record<string, string>): string;
/**
* Group a settings record. System rows (`app_id` null/undefined) belong to the
* platform and render under a `system` divider at the top, mirroring the
* notifications shape.
*/
export declare function groupSettingsRecord(record: SettingRecord, appSlugById: Record<string, string>): GroupInfo;
/**
* `general` and `admin` are flagged `deprecated: true` in the base schema and
* still come back from the default list (no server-side filter equivalent —
* `deprecated[$ne]=true` doesn't take). Filter them out client-side.
*/
export declare function isDeprecatedRecord(record: SettingRecord): boolean;