Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions packages/fetcher/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ export function titleXmlUrl(congress: string, law: string, title: string): strin
return `${OLRC_RELEASE_POINTS_URL}us/pl/${congress}/${law}/xml_usc${paddedTitle}@${congress}-${law}.zip`;
}

/**
* Build a URL for the all-titles XML ZIP download for a release point.
* Pattern: https://uscode.house.gov/download/releasepoints/us/pl/{congress}/{law}/xml_uscAll@{congress}-{law}.zip
*/
export function allTitlesXmlUrl(congress: string, law: string): string {
return `${OLRC_RELEASE_POINTS_URL}us/pl/${congress}/${law}/xml_uscAll@${congress}-${law}.zip`;
}

/**
* Maximum number of bytes to accept from a single download.
*
Expand Down
1 change: 0 additions & 1 deletion packages/fetcher/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export {
OLRC_PRIOR_RELEASE_POINTS_PAGE,
OLRC_RELEASE_POINTS_URL,
titleXmlUrl,
allTitlesXmlUrl,
HASH_STORE_DIR,
HASH_STORE_FILE,
} from './constants.js';
Expand Down
27 changes: 0 additions & 27 deletions packages/transformer/src/__tests__/transformer.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { describe, it, expect } from 'vitest';
import {
parseUslmXml,
extractText,
generateFrontmatter,
buildSectionPath,
formatListItem,
Expand Down Expand Up @@ -144,32 +143,6 @@ describe('parseUslmXml', () => {
});
});

describe('extractText', () => {
it('returns string values directly', () => {
expect(extractText('hello')).toBe('hello');
});

it('extracts #text from objects', () => {
expect(extractText({ '#text': 'nested' })).toBe('nested');
});

it('returns empty string for null/undefined/unrecognized', () => {
expect(extractText(null)).toBe('');
expect(extractText(undefined)).toBe('');
expect(extractText({ foo: 'bar' })).toBe('');
});

it('handles numeric values', () => {
expect(extractText(42)).toBe('42');
expect(extractText({ '#text': 101 })).toBe('101');
});

it('handles preserveOrder arrays', () => {
const nodes = [{ '#text': 'hello' }, { '#text': 'world' }];
expect(extractText(nodes)).toBe('hello world');
});
});

describe('generateFrontmatter', () => {
it('produces valid YAML frontmatter', () => {
const fm = generateFrontmatter({
Expand Down
24 changes: 0 additions & 24 deletions packages/transformer/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
/** USLM XML element names and transformer configuration */

/**
* USLM namespace URI.
* Note: OLRC publishes USLM 1.0 (http://xml.house.gov/schemas/uslm/1.0)
* which uses `<uscDoc>` as root, while the USLM 2.0 spec uses `<lawDoc>`.
* The namespace URI is the same; only the schema version and root element differ.
*/
export const USLM_NAMESPACE = 'https://xml.house.gov/schemas/uslm/1.0';

/** Structural USLM element names (hierarchy order) */
export const USLM_ELEMENTS = {
/** Top-level document wrapper (USLM 2.0) */
Expand Down Expand Up @@ -58,24 +50,8 @@ export const USLM_ELEMENTS = {
table: 'table',
} as const;

/**
* Legal list markers by nesting depth.
* (a) → (1) → (A) → (i) → (I) → (aa)
*/
export const LEGAL_LIST_MARKERS = [
{ prefix: '(', style: 'lower-alpha' }, // (a), (b), (c)
{ prefix: '(', style: 'decimal' }, // (1), (2), (3)
{ prefix: '(', style: 'upper-alpha' }, // (A), (B), (C)
{ prefix: '(', style: 'lower-roman' }, // (i), (ii), (iii)
{ prefix: '(', style: 'upper-roman' }, // (I), (II), (III)
{ prefix: '(', style: 'double-lower' }, // (aa), (bb), (cc)
] as const;

/** Indentation per nesting level (in spaces) */
export const INDENT_PER_LEVEL = 2;

/** Maximum nesting depth for safety (prevent runaway recursion) */
export const MAX_NESTING_DEPTH = 20;

/** Output directory structure pattern */
export const OUTPUT_PATH_PATTERN = 'statutes/title-{title}/chapter-{chapter}/section-{section}.md';
4 changes: 2 additions & 2 deletions packages/transformer/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { XmlToMarkdownAdapter } from './transformer.js';
export { parseUslmXml, extractText } from './parser.js';
export { parseUslmXml } from './parser.js';
export type { ParsedDocument } from './parser.js';
export {
generateFrontmatter,
Expand All @@ -14,6 +14,6 @@ export {
detectSectionStatus,
} from './markdown-generator.js';
export type { Frontmatter, MarkdownFile, SectionStatus } from './markdown-generator.js';
export { USLM_ELEMENTS, USLM_NAMESPACE, INDENT_PER_LEVEL, MAX_NESTING_DEPTH } from './constants.js';
export { USLM_ELEMENTS, INDENT_PER_LEVEL, MAX_NESTING_DEPTH } from './constants.js';
export { createLogger } from '@civic-source/shared';
export { extractTextFromNodes, findElements, getAttributes, getElementName } from './xml-utils.js';
20 changes: 0 additions & 20 deletions packages/transformer/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,6 @@ function createUslmParser(): XMLParser {
return parser;
}

/**
* Extract text from a preserveOrder node array or a plain value.
* For backward compatibility with markdown-generator and transformer.
*/
export function extractText(node: unknown): string {
if (typeof node === 'string') return node;
if (typeof node === 'number') return String(node);
if (Array.isArray(node)) return extractTextFromNodes(node);
if (node !== null && typeof node === 'object') {
const obj = node as Record<string, unknown>;
if ('#text' in obj && typeof obj['#text'] === 'string') return obj['#text'];
if ('#text' in obj && typeof obj['#text'] === 'number') return String(obj['#text']);
}
return '';
}

/**
* Find the title number from a parsed USLM document (preserveOrder format).
* Looks for the identifier attribute on the title element.
*/
/** Find the document root element — either lawDoc (USLM 2.0) or uscDoc (USLM 1.0) */
function findDocRoot(root: unknown[]): { children: unknown[]; attrs: Record<string, string> } | undefined {
return findElements(root, USLM_ELEMENTS.lawDoc)[0]
Expand Down
13 changes: 0 additions & 13 deletions packages/transformer/src/xml-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@
* Attributes live in a ":@" sibling key on the same object.
*/

/** A text node in preserveOrder output */
export interface PreserveOrderTextNode {
'#text': string;
}

/** An element node in preserveOrder output */
export interface PreserveOrderElementNode {
[tag: string]: unknown[];
}

/** A single node in the preserveOrder output */
export type PreserveOrderNode = PreserveOrderTextNode | PreserveOrderElementNode;

/**
* Recursively walk nodes and concatenate all #text values in document order.
* Joins segments with a single space and collapses whitespace.
Expand Down
6 changes: 0 additions & 6 deletions scripts/lib/delta-detector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ export function hashContent(content: string): string {
return createHash('sha256').update(content, 'utf-8').digest('hex');
}

/** A file with its path and content hash */
export interface HashedFile {
path: string;
hash: string;
}

/** Result of comparing two sets of files */
export interface DeltaResult {
/** Files that are new or have changed content */
Expand Down