/** * A world folder written in memory (OnlyWorlds Folder Format v0.3.24): `world.json` and one file * per element under `elements//`, named `--.json` (§3.2, the collision rule * included), each the canonical bytes of §5 (`JSON.stringify(value, null, 2)` and a newline, UTF-8, * keys in the order given). The same bytes as the Python package's `write_folder`: the filenames * are its `slugify`, `id_tail` and `resolve_filenames`, the text its `_jsonfmt.encode`. * * Module-internal: not in the package's exports. */ /** One file of a folder: its path inside the folder, `/`-separated, and its bytes. */ interface OwFolderFile { path: string; data: Uint8Array; } /** * The shared core of the import doors: what every reader of another tool's export needs on the * OnlyWorlds side, with no tool's keys in it. A reader (one per tool, its rules in code, its tables * and wording as data) builds a `Draft` per element and hands the core what it found; the core * holds the element's body in the schema's order with the hidden mark, the extension keys a value * is kept under (named from the key, `_2` and on when taken), each kept key reported once, exact * copies folded, the schema's field kinds and link targets, the Narrative and Relation fields for * a linked type, the names the door made and their count, `world.json`, and the folder's files. * * Exported from `@onlyworlds/sdk/convert` are its findings' types; the rest is module-internal. */ /** A key, or an attribute, not placed on a field: kept on the element as `keptAs`. */ interface OwConvertUnplaced { /** The element's name. */ element: string; key: string; why: string; keptAs: string; } /** A link or mention whose target is not an element of the folder. */ interface OwConvertUnresolved { element: string; /** Where on the element: `parent`, `mention`, a key of the export. */ where: string; /** The target as the export writes it. */ target: string; why: string; } /** Exact copies on one element folded into one. */ interface OwConvertFolded { element: string; /** What was copied: `post`, `trait`, `relationship`, ... */ what: string; name: string; copies: number; } /** * One kind of name a door makes, for a thing the export never names or leaves unnamed. `type` is * the element type it names, or `*` for any. `pattern` is its human form (the export's words in * angle brackets); `regex` matches a whole name of the kind. */ interface OwConvertMadeName { kind: string; type: string; pattern: string; source: 'joined' | 'ours'; regex: string; } /** A made-name record's `type` for a name given to an element of whatever type it became. */ declare const ANY_TYPE = "*"; /** The folder format's `producer` line: the tool that made the folder and its version. */ interface OwConvertProducer { tool: string; version?: string; } /** * Kanka's reader: a Kanka JSON export (the zip "Export the campaign" gives) as a world folder, * the same folder as the Python package's door (`python -m onlyworlds.kanka`) byte for byte, and * the same report. Its rules are this file; its tables (Kanka's folders to element types, its keys * to fields, the fixed key lists, the names it makes) and every line of its report are * `kanka.json`, the same bytes the Python door reads. The Python module's docstring is the long * account of what becomes what; in short: * * - each entity an element of its module's type (a module with no type a Narrative, supertype * `Article`), its entry and visible posts the description (a Narrative's story), its parent, * places, kin, kind and memberships links, an attribute named like a field that field when the * value fits, every other key kept as `x_kanka_` and reported; * - relationships as Relations (a two-way pair as one), a tag's Narrative linking what carries it; * - what Kanka hides imported carrying `hidden: true`, never dropped and never public: a private * entity whole, a post not visible to all as its own Narrative, a relationship hidden on a side, * and on a visible entity its private details in one hidden Narrative; * - exact duplicates folded into one; ids UUIDv5 of the campaign and Kanka's ids, so the same * export twice gives the same folder. */ /** The names this door makes, one record a kind, each kind counted in the report. */ declare const KANKA_MADE_NAMES: readonly OwConvertMadeName[]; /** One export folder and what its entities became. */ interface OwKankaModule { folder: string; type: string; entities: number; /** `proven` (read on a real export), `believed`, or `untyped` (Narratives, supertype `Article`). */ status: 'proven' | 'believed' | 'untyped'; } /** An entity's picture, named on its element as `x_kanka_image` but not imported. */ interface OwKankaPicture { element: string; uuid: string; /** The upload's file in the export (`gallery/.`); null when `gallery/` has no such upload. */ path: string | null; /** The upload's own file name; null when there is none. */ original: string | null; /** The upload is not visible to all and the element is: the uuid is kept alone. */ private: boolean; } /** An element that carries a tag the tag's Narrative does not link. */ interface OwKankaUntagged { tag: string; element: string; why: string; } /** What the source hides, imported carrying `hidden: true`: never dropped, never public. */ interface OwKankaHidden { /** Entities marked private: elements carrying the mark. */ entities: number; /** Posts not visible to all on a visible entity: each its own hidden Narrative. */ posts: number; /** Relationships hidden on a side, or touching a hidden entity: hidden Relations. */ relationships: number; /** On a visible entity, held in its hidden-details Narrative. */ traits: number; personality: number; attributes: number; links: number; /** Hidden-details Narratives made. */ details: number; } /** The report of one conversion: the Python door's report, field for field, and its text. */ interface OwKankaReport { /** The export as the report names it (the `source` option). */ source: string; /** The world's name, as `world.json` has it. */ worldName: string; /** Elements written, by type, in code point order of the type. */ counts: Record; total: number; modules: OwKankaModule[]; /** Relation elements made, by the relation's text, in the order of the text. */ relations: { text: string; count: number; }[]; folded: OwConvertFolded[]; unplaced: OwConvertUnplaced[]; unresolved: OwConvertUnresolved[]; hidden: OwKankaHidden; /** Names of the entities made within seconds of the campaign, Kanka's starter content perhaps (imported all the same). */ possiblyStarter: string[]; /** Uploads read in `gallery/`, and how many an entity names. */ uploads: number; uploadsNamed: number; pictures: OwKankaPicture[]; untagged: OwKankaUntagged[]; /** Names made here, not taken whole from the export: a kind of `KANKA_MADE_NAMES` -> its elements, in declared order. */ madeNames: Record; notes: string[]; /** The report's lines, as the Python door prints them, but its last (`kankaReportText` adds it). */ lines: string[]; } /** A conversion: the world folder's files, in code point order of their paths, and the report. */ interface OwKankaConversion { files: OwFolderFile[]; report: OwKankaReport; } interface OwConvertKankaOptions { /** How the report names the export (the Python door prints the path it was given). Default `export.zip`. */ source?: string; /** The tool `world.json`'s `producer` line names, and its version. Default this package and its version, `{ tool: '@onlyworlds/sdk', version: '' }`. */ producer?: OwConvertProducer; } /** Why an export was refused, nothing returned: `not_a_zip`, or `not_an_export` (no `campaign.json` with an id). */ type OwConvertErrorReason = 'not_a_zip' | 'not_an_export'; /** An export was refused; the message is the Python door's. */ declare class OwConvertError extends Error { readonly reason: OwConvertErrorReason; constructor(reason: OwConvertErrorReason, message: string); } /** The report's whole text, as the Python door prints it: its lines, then where it was written (`out`), or that it was a plan (null). */ declare function kankaReportText(report: OwKankaReport, out: string | null): string; /** * Read a Kanka JSON export (the zip's bytes) into a world folder, in memory: its files and the * report. Nothing is written; the caller writes `files` under a new folder. The same folder as the * Python package's door byte for byte, given the same `producer` (one input differs: a file * holding an integer past 2^53 is skipped here with a note, where Python reads it exactly). A file * that is no JSON, or JSON too deep or with a number too large to hold, is skipped with a note. What Kanka hides comes in * carrying `hidden: true`, counted in the report. Throws `OwConvertError` for bytes that are not a * zip or an export with no `campaign.json`, and a `TypeError` for an unknown option, before anything * is read. */ declare function convertKanka(bytes: Uint8Array, opts?: OwConvertKankaOptions): OwKankaConversion; export { ANY_TYPE, KANKA_MADE_NAMES, OwConvertError, convertKanka, kankaReportText }; export type { OwConvertErrorReason, OwConvertFolded, OwConvertKankaOptions, OwConvertMadeName, OwConvertProducer, OwConvertUnplaced, OwConvertUnresolved, OwFolderFile, OwKankaConversion, OwKankaHidden, OwKankaModule, OwKankaPicture, OwKankaReport, OwKankaUntagged };