### Initial Project Setup Source: https://github.com/gracious-tech/fetch/blob/master/CLAUDE.md Download project-scoped Node.js and perform a full setup including installing modules and building libraries. This may take several minutes on the first run. ```bash # Download project-scoped Node.js (only needed once, or after version bump) .bin/setup_node # Full setup: install modules, build all libraries, build test collection # Takes 5-10 minutes on first run (downloads Bible translations) .bin/setup ``` -------------------------------- ### Collector CLI Setup Command Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Shows the syntax for a setup command within the Collector CLI. ```bash collector setup ``` -------------------------------- ### Install Fetch Dependencies Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md Installs project dependencies using the setup script. ```bash # Install dependencies .bin/setup ``` -------------------------------- ### Setup Bible Search Index Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-index.md Demonstrates how to initialize FetchClient, fetch a collection, create a BibleIndex, index all books, and perform a search. This is a complete example for setting up a searchable Bible. ```typescript import {FetchClient} from '@gracious.tech/fetch-client' import {BibleIndex} from '@gracious.tech/fetch-search' async function setupSearch() { // Get collection const client = new FetchClient() const collection = await client.fetch_collection() // Create index const index = new BibleIndex(collection, 'web') // Index all books (may take a moment) const allBooks = collection.bibles.get_books('web').map(b => b.id) console.log(`Indexing ${allBooks.length} books...`) await index.index_books(allBooks) // Now search const results = await index.search('love', 20) console.log(`Found ${results.length} matches for "love"`) for (const result of results) { console.log(`${result.ref.toString()}: ${result.contents.substring(0, 50)}...`) } } setupSearch() ``` -------------------------------- ### Fetch Client Configuration Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md Example of configuring the FetchClient with custom endpoints, usage options, and fetch caching. ```typescript const client = new FetchClient({ endpoints: ['https://v1.fetch.bible/'], usage: {commercial: true, attributionless: false}, remember_fetches: true }) ``` -------------------------------- ### Install Project Modules Source: https://github.com/gracious-tech/fetch/blob/master/README.md Installs all necessary modules for the fetch(bible) project. Run this command in the project's root directory. ```bash .bin/setup ``` -------------------------------- ### Start Local HTTP Server Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/collector-cli.md Starts a local HTTP server for testing the collection. You can specify a port or use the default. ```bash fetch-collector serve fetch-collector serve 8080 ``` ```bash # Start on default port fetch-collector serve # Start on specific port fetch-collector serve 3000 # In another terminal, test curl http://localhost:3000/manifest.json ``` -------------------------------- ### FetchClient Usage Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Basic example for Application Developers on building custom Bible apps using FetchClient. ```typescript import { FetchClient } from "@gracious-tech/fetch"; const client = new FetchClient({ // Full control over data access }); // Use client for custom Bible app logic ``` -------------------------------- ### Serve Fetch Collection Locally Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md Starts a local server to serve the collection. ```bash # Serve collection locally .bin/serve_collection & ``` -------------------------------- ### Collector CLI Download Command Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Demonstrates the syntax for a download command in the Collector CLI. ```bash collector download ``` -------------------------------- ### Install fetch-collector Source: https://github.com/gracious-tech/fetch/blob/master/site/src/access/collections/index.md Install the Node CLI for managing collections. This tool is used for both the official fetch(bible) collection and for creating your own. ```bash npm install @gracious.tech/fetch-collector ``` -------------------------------- ### Setup and Use Fetch CLI Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md Commands for setting up, discovering, downloading, processing, and publishing collections using the Fetch CLI. ```bash fetch-collector setup fetch-collector discover ebible fetch-collector download [id] fetch-collector process fetch-collector publish ``` -------------------------------- ### Serve Site Source: https://github.com/gracious-tech/fetch/blob/master/README.md Starts a server to serve the fetch.bible website, including its documentation. Ensure the collection is being served concurrently. ```bash .bin/serve_site ``` -------------------------------- ### Fetch Collector Configuration File Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/collector-cli.md Example of the collection/config.yaml file used to configure most fetch-collector operations, including collection name, directory, and publishing settings. ```yaml name: "Bible Collection" dir: "./collection" bibles: {} glosses: {} notes: {} publish: s3: bucket: "my-bucket" region: "us-east-1" distribution: "E123ABC" ``` -------------------------------- ### Setup Node.js Environment Source: https://github.com/gracious-tech/fetch/blob/master/CLAUDE.md Ensure the project's bundled Node.js version is set up correctly for use by .bin/ scripts. ```bash .bin/setup_node ``` -------------------------------- ### Serve App Source: https://github.com/gracious-tech/fetch/blob/master/README.md Starts a server to serve the generic Bible reading app. Ensure the collection is being served concurrently. ```bash .bin/serve_app ``` -------------------------------- ### Serve Collection Source: https://github.com/gracious-tech/fetch/blob/master/README.md Starts a server to serve the collection, making it accessible for the app and site components. ```bash .bin/serve_collection ``` -------------------------------- ### Collector CLI Publishing Command Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Illustrates the syntax for a publishing command in the Collector CLI. ```bash collector publish ``` -------------------------------- ### Collector CLI Discovery Command Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Illustrates the syntax for a discovery command in the Collector CLI. ```bash collector discover ``` -------------------------------- ### Initialize Fetch Collector CLI Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/ARCHITECTURE.md Set up the Fetch Collector CLI for managing Bible translations. Run 'fetch-collector setup' to initialize. ```bash # Initialize fetch-collector setup ``` -------------------------------- ### Serve collection locally Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/collector-cli.md Start a local server to preview the generated collection files. This is useful for testing before publishing. ```bash fetch-collector serve ``` -------------------------------- ### Setup Bible Multi Converter Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/collector-cli.md Installs the Bible Multi Converter (BMC) tool, which is required for certain processing steps. Alternatively, manually download it to the collector/bmc/ directory. ```bash # Download BMC fetch-collector setup-bmc # Or manually download to collector/bmc/ ``` -------------------------------- ### Initialize BibleEnhancer with Defaults Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-enhancer.md Use this snippet for basic setup with all default configurations. ```typescript import {BibleEnhancer} from '@gracious.tech/fetch-enhancer' // Basic setup with defaults const enhancer = new BibleEnhancer() ``` -------------------------------- ### FetchClientConfig Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Demonstrates the structure of FetchClientConfig, including endpoints, data endpoints, usage, and fetch remembering. ```typescript const config = { endpoints: { // ... }, data_endpoint: "/data", usage: { // ... }, remember_fetches: true }; ``` -------------------------------- ### HTML Conversion Examples Source: https://github.com/gracious-tech/fetch/blob/master/converters/usx-to-json/README.md Provides examples for extracting verses, chapters, and custom ranges from an HTML USX JSON object. Demonstrates combining verse parts to form complete HTML. ```javascript // Convert a USX document for the book of Luke const luke = usx_to_json_html(luke_in_usx) // Get a single verse const chapter1verse5 = luke.contents[1][5].join('') // Get a chapter const chapter2_start = luke.contents[2][1][0] const chapter2_contents = luke.contents[2].map(v => v[1]).join('') const chapter2_end = luke.contents[2].at(-1)[2] const chapter2 = chapter2_start + chapter2_contents + chapter2_end // Get a custom range const ch3_v5to9_start = luke.contents[3][5][0] const ch3_v5to9_contents = luke.contents[3].slice(5, 9+1).map(v => v[1]).join('') const ch3_v5to9_end = luke.contents[3][9][2] const ch3_v5to9 = ch3_v5to9_start + ch3_v5to9_contents + ch3_v5to9_end // Get whole book // NOTE Starting and closing tags not needed since nothing being clipped const all_verses = luke.contents.flat().map(v => v[1]).join('') ``` -------------------------------- ### BibleIndex Usage Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Example for Search Implementers on setting up and using BibleIndex for full-text search. ```typescript import { BibleIndex } from "@gracious-tech/fetch"; const index = new BibleIndex({ // Configuration for search }); // Use index for full-text search queries ``` -------------------------------- ### FetchEnhancer Usage Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Basic example for Web Developers on how to add Bible references to websites using FetchEnhancer. ```typescript import { FetchEnhancer } from "@gracious-tech/fetch"; const enhancer = new FetchEnhancer({ // Minimal configuration }); // Use enhancer to add Bible references ``` -------------------------------- ### Development Servers Source: https://github.com/gracious-tech/fetch/blob/master/CLAUDE.md Start development servers for the test collection, the Bible app, and the documentation site. These should be run in separate terminals. ```bash # Serve the test collection (local HTTP server for collection data) .bin/serve_collection # Serve the Bible app (Vite dev server on port 8431) .bin/serve_app # Serve the documentation site (VitePress dev server) .bin/serve_site ``` -------------------------------- ### BibleEnhancer ConstructorOptions Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Illustrates the options available when constructing a BibleEnhancer instance. ```typescript const options = { // ... 8 keys for configuration }; ``` -------------------------------- ### Collector CLI Setup and Usage Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md Commands for setting up, discovering, downloading, processing, and publishing Bible collections using the fetch-collector CLI. ```bash fetch-collector setup fetch-collector discover ebible fetch-collector download web fetch-collector process fetch-collector publish ``` -------------------------------- ### Collector CLI Reporting Command Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Shows the syntax for a reporting command within the Collector CLI. ```bash collector report ``` -------------------------------- ### Collector CLI Maintenance Command Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Demonstrates the syntax for a maintenance command in the Collector CLI. ```bash collector maintenance ``` -------------------------------- ### Collector CLI Processing Command Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Shows the syntax for a processing command within the Collector CLI. ```bash collector process ``` -------------------------------- ### Future Multi-Language Support Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-index.md Illustrates how multi-language support might be implemented in future versions by importing language presets. ```typescript // In future versions with multi-language support: import SpanishPreset from 'flexsearch/lang/es' import FrenchPreset from 'flexsearch/lang/fr' ``` -------------------------------- ### Filter Resources by License Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md Example of filtering Bible resources by license using the `usage` configuration in FetchClientConfig. ```typescript const client = new FetchClient({ usage: {commercial: true, attributionless: false} }) ``` -------------------------------- ### Setup Test Collection Source: https://github.com/gracious-tech/fetch/blob/master/README.md Generates a test collection with several Bible translations using the collector CLI. This process may take 5-10 minutes. ```bash .bin/test_collector ``` -------------------------------- ### Bible Enhancer Configuration Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md Configuration for the BibleEnhancer, specifying translations, app origin, and history tracking. ```typescript const enhancer = new BibleEnhancer({ translations: ['web'], app_origin: 'https://app.fetch.bible', history: true }) ``` -------------------------------- ### IndividualVerse Interface Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-book.md Demonstrates the structure of the IndividualVerse interface used to represent a single verse with its metadata. ```typescript interface IndividualVerse { id: number // Reproducible numeric ID (chapter * 1000 + verse) chapter: number // Chapter number verse: number // Verse number content: T // Verse content (string or array depending on format) } ``` ```typescript const verse: IndividualVerse = { id: 1001, chapter: 1, verse: 1, content: "In the beginning was the Word..." } ``` -------------------------------- ### Basic HTML Structure for Fetch App Source: https://github.com/gracious-tech/fetch/blob/master/site/src/access/client/example/index.md This is the main HTML file for the example application. It includes basic structure, CSS for styling, and JavaScript for functionality. ```html Fetch Bible Example

Fetch Bible

``` -------------------------------- ### Fetch Bible Content with FetchClient Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md Use FetchClient to initialize the platform and fetch Bible collections and specific books. This example demonstrates fetching the HTML for John 3:16. ```typescript import {FetchClient} from '@gracious.tech/fetch-client' const client = new FetchClient() const collection = await client.fetch_collection() const book = await collection.bibles.fetch_book('web', 'jhn') const html = book.get_html(3, 16) ``` -------------------------------- ### Implement Search with BibleIndex Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md Implement full-text search functionality using BibleIndex. This example shows how to index specific books and perform a search query. ```typescript import {BibleIndex} from '@gracious.tech/fetch-search' const index = new BibleIndex(collection, 'web') await index.index_books(['mat', 'mrk', 'luk', 'jhn']) const results = await index.search('kingdom') ``` -------------------------------- ### Plain Text Conversion Examples Source: https://github.com/gracious-tech/fetch/blob/master/converters/usx-to-json/README.md Demonstrates manual extraction of verses, chapters, and custom ranges from a plain text USX JSON object. Includes filtering out headings and footnotes. ```javascript // Convert a USX document for the book of Luke const luke = usx_to_json_txt(luke_in_usx) // Get a single verse const chapter1verse5 = luke.contents[1][5] // Strip out headings/footnotes so have a single string const no_headings_or_footnotes = chapter1verse5.filter(part => typeof part === 'string').join('') // Get a chapter const chapter2 = luke.contents[2].flat() // Get a custom range const chapter3_v5to9 = luke.contents[3].slice(5, 9+1).flat() // Get whole book const all_verses = luke.contents.flat(2) ``` -------------------------------- ### Collector Management Commands Source: https://github.com/gracious-tech/fetch/blob/master/CLAUDE.md Manage the collection data, including setup, discovery of different data sources, downloading translations, processing, and serving. ```bash # Run collector commands .bin/collector setup .bin/collector discover ebible .bin/collector discover dbl .bin/collector download .bin/collector process .bin/collector glosses .bin/collector notes .bin/collector crossref .bin/collector manifest .bin/collector serve ``` -------------------------------- ### Integrate Bible Index with Collections Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-index.md Shows how to combine FetchCollection and BibleIndex to get a user's preferred translation, index books, search, and then fetch full verse content for display. ```typescript const collection = await client.fetch_collection() const index = new BibleIndex(collection, 'web') // Get user's preferred translation const translations = collection.bibles.get_resources() const web = translations.find(t => t.id === 'web') // Index and search await index.index_books(collection.bibles.get_books('web').map(b => b.id)) const results = await index.search('eternal life', 10) // Fetch full verse content for display for (const result of results) { const book = await collection.bibles.fetch_book('web', result.ref.book) const fullText = book.get_html(result.ref.start_chapter, result.ref.start_verse) console.log(fullText) } ``` -------------------------------- ### Usage Statistics by Topic Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Displays the distribution of documentation content across various topics within the fetch(bible) project, including API references, examples, and tables. ```markdown | Topic | Files | Examples | Tables | |-------|-------|----------|--------| | Client API | 3 | 50+ | 15+ | | References | 2 | 40+ | 8+ | | Collections | 2 | 35+ | 12+ | | Search | 1 | 25+ | 5+ | | Web Integration | 1 | 20+ | 5+ | | CLI Tools | 1 | 15+ | 8+ | | Types/Config | 2 | 10+ | 10+ | | Architecture | 1 | 30+ | 0 | ``` -------------------------------- ### Get All Notes for a Book Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/glosses-notes-crossref.md Retrieves all study notes for an entire book, combined into a single object. Useful for getting a comprehensive overview. ```typescript const allNotes = notes.get_all() const totalLength = allNotes.html.length ``` -------------------------------- ### Default Theme Styles for BibleEnhancer Source: https://github.com/gracious-tech/fetch/blob/master/site/src/access/enhancer/index.md Example CSS demonstrating the default theme styles applied to Bible reference links and multi-range wrappers, including preventing line breaks. ```css .fb-enhancer-theme .fb-enhancer-link { color: inherit; text-decoration: none; background-color: hsla(60, 100%, 45%, 0.15); } /* Prevent references from being broken by line-wrapping, like "Genesis 1:1" compared to "Genesis 1:1" */ .fb-enhancer-theme .fb-enhancer-multi, .fb-enhancer-theme .fb-enhancer-link { white-space: nowrap; } ``` -------------------------------- ### Initialize a new collection Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/collector-cli.md Use this command to set up a new collection with default configuration and data. It creates the configuration file, downloads language data, and the Bible Multi Converter tool. ```bash fetch-collector setup ``` -------------------------------- ### Get All Bible Books in Order Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-references.md Access the `books_ordered` constant to get an array of all 66 Bible book codes in their traditional sequence. This is useful for iterating through books or ensuring correct ordering. ```typescript import {books_ordered} from '@gracious.tech/fetch-client' console.log(books_ordered[0]) // 'gen' console.log(books_ordered[39]) // 'mat' (first NT book) console.log(books_ordered[65]) // 'rev' (last book) ``` -------------------------------- ### Serve Fetch Collector Locally Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/collector-cli.md Starts a local development server for testing. The collector serve command automatically enables CORS. If issues arise, restarting the server or specifying a port (e.g., 8080) can help. ```bash # Collector serve automatically enables CORS # If not working, restart server fetch-collector serve 8080 ``` -------------------------------- ### Show Fetch Collector Help Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/collector-cli.md Displays help information for the fetch-collector CLI. Use '--help' with the main command to see all available commands, or with a specific command (e.g., 'download --help') for detailed command-specific usage. ```bash # Show all commands fetch-collector --help # Show specific command help fetch-collector download --help fetch-collector process --help ``` -------------------------------- ### Get English Bible Resources Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/fetch-collection.md Filters Bible translations to include only those in English. ```typescript const english = collection.bibles.get_resources({language: 'eng'}) ``` -------------------------------- ### Get Gloss Resources Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/fetch-collection.md Fetches gloss resources for a specified language. This follows the same interface as BibleCollection. ```typescript // Get glosses for a language const glossResources = collection.glosses.get_resources({language: 'eng'}) ``` -------------------------------- ### Get Translation Completion Status Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/fetch-collection.md Returns which books are available and which are missing from a translation, separated by testament. ```typescript const completion = collection.bibles.get_completion('web') console.log(completion.ot.available) // e.g., ['gen', 'exo', ...] console.log(completion.nt.missing) // Missing books if any ``` -------------------------------- ### Build Client API Documentation Source: https://github.com/gracious-tech/fetch/blob/master/CLAUDE.md Builds the client API documentation specifically for the project's documentation site. ```bash # Build client API docs for the site .bin/build_client_docs ``` -------------------------------- ### Get New Testament Books Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/fetch-collection.md Filters books within a translation to include only those from the New Testament. ```typescript // New Testament only const nt = collection.bibles.get_books('web', {testament: 'nt'}) ``` -------------------------------- ### Initialize FetchClient and Fetch Collection Source: https://github.com/gracious-tech/fetch/blob/master/site/src/_public/example.html Instantiate the FetchClient and fetch the entire Bible collection. This is a prerequisite for most other operations. ```javascript // Import the fetch(bible) client // Normally you would import from '@gracious.tech/fetch-client' rather than a static file import {FetchClient, get_chapters} from './client.mjs' // Locate UI elements const select_language = self.document.querySelector('.language') const select_translation = self.document.querySelector('.translation') const select_book = self.document.querySelector('.book') const select_chapter = self.document.querySelector('.chapter') const div_content = self.document.querySelector('.content') // Fetch collection const client = new FetchClient() const collection = await client.fetch_collection() ``` -------------------------------- ### Initialize FetchClient Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/fetch-client.md Create a new FetchClient instance. Use the default configuration for the official CDN or provide custom endpoints and usage options. ```typescript import {FetchClient} from '@gracious.tech/fetch-client' // Default client (uses official CDN) const client = new FetchClient() // With custom CDN endpoints const client = new FetchClient({ endpoints: ['https://my-collection.example.com/'], usage: {commercial: true, attributionless: false} }) ``` -------------------------------- ### Project File Structure Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md This tree outlines the generated documentation's file structure, including the main entry point, architecture, configuration, types, CLI reference, and a detailed API reference section. ```bash output/ ├── README.md # Main entry point and navigation guide ├── ARCHITECTURE.md # Platform architecture and integration patterns ├── CONFIGURATION.md # All configuration options ├── TYPES.md # Complete type definitions ├── COLLECTOR-CLI.MD # CLI reference and workflow └── api-reference/ ├── fetch-client.md # FetchClient class (main entry point) ├── fetch-collection.md # FetchCollection and resource collections ├── bible-book.md # Bible content formats (HTML, TXT, USFM, USX) ├── bible-references.md # Reference parsing and detection ├── glosses-notes-crossref.md # Supplementary data (glosses, notes, crossrefs) ├── bible-enhancer.md # Web integration for third-party sites ├── bible-index.md # Full-text search using FlexSearch └── utility-functions.md # Helper functions and constants ``` -------------------------------- ### Fetch Collector CLI Help Source: https://github.com/gracious-tech/fetch/blob/master/site/src/access/collections/index.md View the usage instructions for the fetch-collector command-line interface. This command displays all available options and commands. ```bash npx fetch-collector --help ``` -------------------------------- ### Initialize and Fetch Bible Content Source: https://github.com/gracious-tech/fetch/blob/master/site/src/access/client/index.md Demonstrates initializing the FetchClient, fetching collection metadata, retrieving available translations and books, and then fetching the content of a specific book and chapter. Use this to load and display Bible content programmatically. ```typescript import {FetchClient} from '@gracious.tech/fetch-client' // Init client const client = new FetchClient() // Fetch the collection's meta data const collection = await client.fetch_collection() // Get what translations are available const translations = collection.bibles.get_resources() // Get the id of the first translation available const translation_id = translations[0].id // Load local book names for the translation await collection.bibles.fetch_translation_extras(translation_id) // Get what books are available for the translation // (may be whole Bible or may only be e.g. NT) const books = collection.bibles.get_books(translation_id) // Fetch the contents of the first book const book = await collection.bibles.fetch_book(translation_id, books[0].id) // Output the HTML of the first chapter of the book console.log(book.get_chapter(1)) ``` -------------------------------- ### BookSection Interface Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/types.md Represents a section within a book, specifying start and end chapters/verses and an optional heading. ```typescript interface BookSection { start_chapter: number start_verse: number end_chapter: number end_verse: number heading: string | null } ``` -------------------------------- ### Convert PassageReference to String Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-references.md Use the toString() method on a PassageReference object to get its human-readable string representation. ```typescript const ref = PassageReference.from_string('John 3:16') console.log(ref.toString()) // "John 3:16" ``` -------------------------------- ### Build App Package Source: https://github.com/gracious-tech/fetch/blob/master/CLAUDE.md Build the app package, which depends on the client and search packages. ```bash .bin/build_app ``` -------------------------------- ### Initialize New Collector Collection Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/configuration.md Command to initialize a new collector collection with default configuration settings. ```bash .bin/collector setup ``` -------------------------------- ### Get New Testament Only Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md Fetches only the books belonging to the New Testament from a collection using `get_books()` with a testament filter. ```typescript const nt = collection.bibles.get_books('web', {testament: 'nt'}) ``` -------------------------------- ### Building Individual Workspaces Source: https://github.com/gracious-tech/fetch/blob/master/CLAUDE.md Build individual project workspaces. The order is important as some workspaces depend on others. References must be built first. ```bash # Build individual workspaces (follow dependency order if rebuilding from scratch) .bin/build_references # Must be first — client and converters depend on it .bin/build_client # Needed by app, enhancer, and collector .bin/build_converters # Loops through all converter subdirectories .bin/build_search # Needed by app .bin/build_enhancer .bin/build_collector .bin/build_app # Production build (vite build) ``` -------------------------------- ### Get All Books in a Translation Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/fetch-collection.md Lists all Bible books available in a specified translation. Supports filtering by testament and sorting. ```typescript // All books in a translation const books = collection.bibles.get_books('web') ``` -------------------------------- ### Get All Bible Resources Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/fetch-collection.md Lists all Bible translations in the collection. Supports filtering by language, usage restrictions, and completeness. ```typescript const all = collection.bibles.get_resources() ``` -------------------------------- ### FetchClient - Main Entry Point Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md The FetchClient is the primary interface for interacting with the fetch(bible) platform. It provides methods to fetch various Bible-related resources such as books, glosses, notes, cross-references, and search data. It also handles configuration and error management. ```APIDOC ## FetchClient ### Description The main entry point for accessing Bible collections and resources. It allows fetching books, glosses, notes, cross-references, and search data, along with configuration and error handling. ### Constructor `new FetchClient(config?: FetchClientConfig)` Initializes a new FetchClient instance with optional configuration. ### Methods - **`fetch_collection(): Promise`** Fetches the main collection of Bible resources. - **`fetch_book(language: string, bookId: string): Promise`** Fetches a specific Bible book in a given language. - **`fetch_glosses(language: string): Promise`** Fetches glosses for a specific language. - **`fetch_notes(language: string): Promise`** Fetches study notes for a specific language. - **`fetch_crossrefs(language: string): Promise`** Fetches cross-references for a specific language. - **`search(query: string): Promise`** Performs a full-text search across available resources. ### Error Handling Handles errors related to fetching resources, configuration, and search operations. ``` -------------------------------- ### Build Fetch Packages Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md Builds all packages within the Fetch project, including client, search, enhancer, and references. ```bash # Build all packages .bin/build_client .bin/build_search .bin/build_enhancer .bin/build_references ``` -------------------------------- ### Complete Fetch Client and Bible Enhancer Configuration Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/configuration.md Configure the Fetch Client with multiple endpoints and usage policies, and set up the Bible Enhancer with themes, translations, and custom history push logic. ```typescript import {FetchClient} from '@gracious.tech/fetch-client' import {BibleEnhancer} from '@gracious.tech/fetch-enhancer' const client = new FetchClient({ endpoints: [ 'https://my-bible-cdn.example.com/', 'https://v1.fetch.bible/' ], data_endpoint: 'https://data.example.com/', usage: { commercial: true, attributionless: false, limitless: false, derivatives: 'same-license' }, remember_fetches: true }) const enhancer = new BibleEnhancer({ client: client, default_theme: true, app_origin: 'https://bible.example.com', translations: ['web', 'kjv'], history: true, app_args: { theme: 'dark', language: 'en' }, always_detect_english: true, before_history_push: () => { // Track analytics console.log('Reference viewed') } }) // Use configured client and enhancer const collection = await client.fetch_collection() enhancer.enhance_element(document.body) ``` -------------------------------- ### Get Verses with Metadata Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-book.md Retrieves verses with their metadata, grouped by chapter. Useful for displaying Bible content with chapter structure. ```typescript get_list(start_chapter?: number, start_verse?: number, end_chapter?: number, end_verse?: number): IndividualVerse[][] ``` ```typescript const verses = book.get_list(1, 1, 1, 5) for (const chapter of verses) { for (const verse of chapter) { console.log(`John ${verse.chapter}:${verse.verse} - ${verse.content}`) } } ``` -------------------------------- ### Build Client Module Source: https://github.com/gracious-tech/fetch/blob/master/README.md Builds the client module, which is a dependency for other components of the fetch(bible) project. ```bash .bin/build_client ``` -------------------------------- ### Get Commercial Use Bible Resources Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/fetch-collection.md Filters Bible translations to include only those compatible with commercial use and requiring attribution. ```typescript const commercial = collection.bibles.get_resources({ usage: {commercial: true, attributionless: false} }) ``` -------------------------------- ### Creating and Using Typed Objects Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/types.md Demonstrates how to create typed objects for options and process results using specific item types. Requires importing relevant types. ```typescript // Creating typed objects const options: GetResourcesOptions = { language: 'eng', sort_by_year: true } // Working with results const items: GetResourcesItem[] = collection.bibles.get_resources(options) for (const item of items) { console.log(item.name_bilingual) } ``` -------------------------------- ### Import and Create Passage References Source: https://github.com/gracious-tech/fetch/blob/master/references/README.md Demonstrates how to import necessary components and create PassageReference objects using simple and complex arguments. ```javascript import {PassageReference, detect_references, book_abbrev_english} from '@gracious.tech/bible-references' // Simple args const ref1 = new PassageReference('jhn', 3, 16) // Complex args that can specify a range of verses const ref2 = new PassageReference({ book: 'jhn', start_chapter: 3, start_verse: 16, end_chapter: 3, end_verse: 17, }) ``` -------------------------------- ### Run Linting Source: https://github.com/gracious-tech/fetch/blob/master/CLAUDE.md Execute ESLint for code linting with specific configurations for Node.js, Vue 3, and TypeScript. ```bash .bin/audit_lint ``` -------------------------------- ### Run Fetch Tests Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/README.md Executes the test suite for the Fetch project. ```bash # Run tests .bin/audit_test ``` -------------------------------- ### Get USX Text Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-book.md Retrieves the entire book content as USX-formatted XML. Suitable for validation and structured processing of Bible data. ```typescript get_text(): string ``` ```typescript const usx = book.get_text() // Returns: // // // Genesis // // ... ``` -------------------------------- ### Get Languages Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/fetch-collection.md List all languages available in the collection. Supports filtering by language code, text search, population, and sorting options. ```typescript // Get all languages const all = collection.bibles.get_languages() // Get spoken languages sorted by English name const spoken = collection.bibles.get_languages({ exclude_old: true, sort_by: 'english' }) // Search for a language const spanish = collection.bibles.get_languages({search: 'spanish'}) ``` -------------------------------- ### Filter Bible Resources by Commercial Usage License Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/ARCHITECTURE.md Initialize FetchClient with specific usage options to filter for commercially compatible Bible resources. Set 'commercial' to true. ```typescript // Only commercial-compatible resources const client = new FetchClient({ usage: { commercial: true, attributionless: false, limitless: false, derivatives: false } }) const collection = await client.fetch_collection() // Only resources matching these restrictions const bibles = collection.bibles.get_resources() ``` -------------------------------- ### Get Cross-references by PassageReference Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/glosses-notes-crossref.md Retrieves cross-references for a specific verse using a PassageReference object. This returns an array of related PassageReference objects. ```typescript const ref = PassageReference.from_string('Genesis 1:1') const refs = crossrefs.get_refs(ref) ``` -------------------------------- ### Error Handling Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-book.md Shows how to handle errors that may occur due to invalid chapter or verse number ranges when fetching verses. ```typescript try { const verses = book.get_list(999, 1, 999, 5) // Invalid chapter } catch (error) { console.error(error.message) // Error in validation } ``` -------------------------------- ### Memory-Conscious Indexing Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-index.md An example of a memory-conscious approach to indexing, specifying the format as 'txt' and indexing only a subset of books (the Gospels) to reduce memory usage. ```typescript // Memory-conscious approach const index = new BibleIndex(collection, 'web', 'txt') await index.index_books(['mat', 'mrk', 'luk', 'jhn']) // Just Gospels ``` -------------------------------- ### Including Fetch Client Styles with a Link Element Source: https://github.com/gracious-tech/fetch/blob/master/site/src/access/client/index.md Alternatively, deploy the client's CSS file with your project and include it using a standard HTML `` element. ```html ``` -------------------------------- ### Advanced Search Queries Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-index.md Shows examples of advanced search syntaxes including implicit AND queries, fuzzy matching, and partial word matching. ```typescript // AND queries (implicit) const results = await index.search('love eternal') // Fuzzy matching (default enabled) const results2 = await index.search('blesed') // Matches "blessed" // Partial word matching (forward matching) const results3 = await index.search('bless') // Matches "blessed", "blessing" ``` -------------------------------- ### Complete Verse Study Integration Pattern Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/DOCUMENTATION_SUMMARY.md Example of integrating components to display a complete verse study, including text, glosses, and notes. ```typescript // Example for Complete Verse Study // Fetches verse text, glosses, and notes ``` -------------------------------- ### Fetch Available Glosses and Notes Resources Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/glosses-notes-crossref.md Demonstrates how to check for available gloss and note resources for a given language and fetch them. Use this to dynamically load study materials. ```typescript // Example: Complete verse study const collection = await client.fetch_collection() // Check what glosses are available const glossResources = collection.glosses.get_resources({language: 'eng'}) if (glossResources.length > 0) { const gloss = await collection.glosses.fetch_book(glossResources[0].id, 'jhn') console.log(gloss.get_words(3, 16)) } // Check what notes are available const noteResources = collection.notes.get_resources({language: 'eng'}) if (noteResources.length > 0) { const note = await collection.notes.fetch_book(noteResources[0].id, 'jhn') console.log(note.get_relevant(3, 16)) } ``` -------------------------------- ### Page Statistics Component Setup Source: https://github.com/gracious-tech/fetch/blob/master/site/src/content/stats/index.md Sets up the PageStatistics component within a Vue.js application, including a fallback loading state using suspense. ```vue ``` -------------------------------- ### Initialize BibleIndex Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/configuration.md Instantiate BibleIndex with a FetchCollection, translation ID, and format. This prepares the index for operations like indexing books and searching. ```typescript const index = new BibleIndex( collection, // FetchCollection instance 'web', // Translation ID 'html' // Format: 'html' or 'txt' (default 'html') ) ``` -------------------------------- ### Get Cross-references by Chapter and Verse Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/glosses-notes-crossref.md Retrieves cross-references for a specific verse using chapter and verse numbers directly. This is an alternative to using PassageReference. ```typescript const refs2 = crossrefs.get_refs(1, 1) ``` -------------------------------- ### Inspect Manifest File Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/collector-cli.md Creates a readable, indented copy of the manifest.json file named manifest.json.pretty. This is useful for debugging and reviewing manifest contents. ```bash fetch-collector inspect-manifest ``` -------------------------------- ### Standalone App with Fetch Client Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/ARCHITECTURE.md Outlines the pattern for using FetchClient directly in a standalone application. Suggests building custom UIs with frameworks like Vue or React and using BibleCollection for data fetching. ```typescript // Use FetchClient directly for full control // Create custom UI with Vue, React, etc. // Use BibleCollection to fetch content ``` -------------------------------- ### Get Glosses Words by PassageReference Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/glosses-notes-crossref.md Retrieves glossed words for a specific verse using a PassageReference object. Ensure the PassageReference is correctly formatted. ```typescript const ref = PassageReference.from_string('Matthew 1:1') const words = glosses.get_words(ref) ``` -------------------------------- ### Get Book URL Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/fetch-collection.md Retrieve the CDN URL for a specific Bible book in a given format. Useful for direct downloads or manual caching. ```typescript const url = collection.bibles.get_book_url('web', 'jhn') // Returns: https://v1.fetch.bible/bibles/web/html/jhn.json ``` -------------------------------- ### Generate other resources Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/collector-cli.md Commands to generate additional resources such as glosses, notes, and cross-references. Use the --redownload option to fetch fresh data. ```bash fetch-collector glosses ``` ```bash fetch-collector notes ``` ```bash fetch-collector crossref ``` -------------------------------- ### Download, Process, and Publish Bible Data with CLI Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/ARCHITECTURE.md Manage the lifecycle of Bible data using the Fetch Collector CLI, including downloading, processing, generating glosses, and publishing. ```bash # Download, process, and publish fetch-collector download web fetch-collector process fetch-collector glosses fetch-collector publish ``` -------------------------------- ### BibleBookHtml get_html() Example Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/api-reference/bible-book.md Retrieves a specified passage from a Bible book as HTML-formatted text, including verse styling. Can optionally include copyright attribution. ```typescript const html = book.get_html(1, 1, 1, 5) // Returns:

1In the beginning...

// Include attribution const withAttrib = book.get_html(1, 1, 1, 5, {attribute: true}) ``` -------------------------------- ### Fetch Collector Typical Workflow Source: https://github.com/gracious-tech/fetch/blob/master/_autodocs/collector-cli.md Illustrates a common sequence of commands for setting up, discovering, downloading, processing, and publishing translation data using the fetch-collector CLI. ```bash # 1. Setup fetch-collector setup # 2. Discover translations fetch-collector discover ebible # 3. Download fetch-collector download web fetch-collector download kjv # 4. Process fetch-collector process # 5. Add supplementary resources fetch-collector glosses fetch-collector notes fetch-collector crossref # 6. Test locally fetch-collector serve & # Open http://localhost:8080/manifest.json # 7. Publish fetch-collector publish ```