@unito/integration-sdk
Version:
Integration SDK
18 lines (14 loc) • 767 B
text/typescript
import { readdirSync, readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import type { RichTextRoot } from '@unito/integration-api';
// Loaded at module init from the `asts/` directory shipped alongside this
// file. tsc doesn't copy non-TS assets into `dist/`, so the `compile`
// script copies `src/richTextFixtures/asts/` over after `tsc --build`.
const ASTS_DIR = join(dirname(fileURLToPath(import.meta.url)), 'asts');
export const canonicalFixtures: Record<string, RichTextRoot> = Object.fromEntries(
readdirSync(ASTS_DIR)
.filter(f => f.endsWith('.json'))
.sort()
.map(f => [f.slice(0, -'.json'.length), JSON.parse(readFileSync(join(ASTS_DIR, f), 'utf-8')) as RichTextRoot]),
);