@youversion/platform-core 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example CHANGED
@@ -1,7 +1,5 @@
1
- YVP_API_BASE_URL=https://api-dev.youversion.com
2
-
3
1
  # Your application ID from YouVersion Platform
4
- YVP_APP_ID=""
2
+ YVP_APP_KEY="ADD_YOUR_APP_KEY_HERE"
5
3
 
6
- # Optional: Authentication token for endpoints that require it
7
- YVP_AUTH_TOKEN=""
4
+ # This should be left untouched unless you're helping test YouVersion's backend APIs.
5
+ YVP_API_HOST=api.youversion.com
@@ -1,5 +1,5 @@
1
1
 
2
- > @youversion/platform-core@0.4.1 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/core
2
+ > @youversion/platform-core@0.4.3 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/core
3
3
  > tsup src/index.ts --format cjs,esm --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,11 +8,11 @@
8
8
  CLI Target: es2022
9
9
  CJS Build start
10
10
  ESM Build start
11
- CJS dist/index.cjs 39.89 KB
12
- CJS ⚡️ Build success in 34ms
13
- ESM dist/index.js 37.89 KB
14
- ESM ⚡️ Build success in 35ms
11
+ ESM dist/index.js 37.68 KB
12
+ ESM ⚡️ Build success in 37ms
13
+ CJS dist/index.cjs 39.67 KB
14
+ CJS ⚡️ Build success in 37ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 2125ms
17
- DTS dist/index.d.cts 34.20 KB
18
- DTS dist/index.d.ts 34.20 KB
16
+ DTS ⚡️ Build success in 2374ms
17
+ DTS dist/index.d.cts 34.08 KB
18
+ DTS dist/index.d.ts 34.08 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @youversion/platform-core
2
2
 
3
+ ## 0.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 7b652f7: chore(docs): update documentation and readmes, and env var usage
8
+
9
+ ## 0.4.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 6764bfe: chore: permit range of React versions
14
+
3
15
  ## 0.4.1
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -1,369 +1,109 @@
1
- # @youversion/platform-core
1
+ ![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue)
2
+ ![Node.js >= 20.0.0](https://img.shields.io/badge/Node.js-%3E%3D%2020.0.0-339933?logo=node.js&logoColor=white)
3
+ ![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)
2
4
 
3
- A powerful, type-safe TypeScript library for interacting with Bible data. This package provides a comprehensive API client for fetching Bible versions, books, chapters, verses, and user authentication from the YouVersion Bible API.
5
+ # @youversion/platform-core
4
6
 
5
- ## 🚀 Features
7
+ A type-safe TypeScript SDK for accessing the YouVersion Platform APIs. Get Bible content and build Bible-based applications.
6
8
 
7
- - **🔒 Type-safe API** - Full TypeScript support with comprehensive type definitions
8
- - **🌐 Multi-language support** - Access Bible versions in multiple languages
9
- - **📚 Complete Bible data** - Versions, books, chapters, verses, and metadata
10
- - **🔐 User authentication** - Secure user authentication with Long Access Tokens (LAT)
11
- - **⚡ Lightweight** - Minimal dependencies with tree-shaking support
12
- - **🎯 Easy to use** - Simple, intuitive API design
13
- - **📦 Modern packaging** - CommonJS and ES Module support
9
+ ## Overview
14
10
 
15
- ## 📦 Installation
11
+ `@youversion/platform-core` provides comprehensive API clients for the YouVersion Bible Platform. Access Bible versions, books, chapters, verses, language information, and Verse of the Day. Built with TypeScript for type safety and works in Node.js and browser environments.
16
12
 
17
- ```bash
18
- # npm
19
- npm install @youversion/platform-core
13
+ > **📚 Full Documentation:** [developers.youversion.com/sdks/react](https://developers.youversion.com/sdks/react)
20
14
 
21
- # yarn
22
- yarn add @youversion/platform-core
15
+ ## Installation
23
16
 
24
- # pnpm
17
+ ```bash
25
18
  pnpm add @youversion/platform-core
26
19
  ```
27
20
 
28
- ## 🔑 Getting Started
21
+ ### Prerequisites
29
22
 
30
- Before using the library, you'll need to obtain an App ID from the [YouVersion Developer Portal](https://developers.youversion.com/). This is required for API authentication.
23
+ - Node.js >= 20.0.0
24
+ - YouVersion Platform App Key ([Get from platform.youversion.com](https://platform.youversion.com/))
31
25
 
32
- ## 🏃 Quick Start
26
+ ## When to Use This Package
33
27
 
34
- ```ts
35
- import { ApiClient, BibleClient } from '@youversion/platform-core'
28
+ Use `@youversion/platform-core` when you need:
29
+ - Direct access to YouVersion Platform APIs
30
+ - ✅ Server-side/Node.js Bible data fetching
31
+ - ✅ Full control over API calls and data handling
32
+ - ✅ Minimal dependencies (works anywhere JavaScript runs)
36
33
 
37
- // Initialize the API client
38
- const apiClient = new ApiClient({
39
- appId: 'YOUR_APP_ID', // Required: Get your App ID from https://developers.youversion.com/
40
- })
41
-
42
- // Create a Bible client
43
- const bibleClient = new BibleClient(apiClient)
34
+ **Use other packages instead if:**
35
+ - Building React components → Use [@youversion/platform-react-hooks](../hooks/README.md) for hooks with state management
36
+ - Need ready-made UI Use [@youversion/platform-react-ui](../ui/README.md) for production-ready components
44
37
 
45
- // Fetch Bible versions
46
- const versions = await bibleClient.getVersions('en*')
38
+ ## Related Packages
47
39
 
48
- // Get a specific version
49
- const version = await bibleClient.getVersion(206) // ESV
40
+ - **[@youversion/platform-react-hooks](../hooks/README.md)** - React hooks wrapping this core SDK
41
+ - **[@youversion/platform-react-ui](../ui/README.md)** - Pre-built React components
50
42
 
51
- // Fetch books for a version
52
- const books = await bibleClient.getBooks(206)
53
-
54
- // Get a specific chapter
55
- const chapter = await bibleClient.getChapter(206, 'GEN', 1)
56
- const chapterContent = await bibleClient.getPassage(206, chapter.passage_id)
57
- ```
58
-
59
- ## 🔧 Configuration
60
-
61
- ### API Configuration
43
+ ## Quick Start
62
44
 
63
45
  ```ts
64
- import { ApiClient } from '@youversion/platform-core'
46
+ import { ApiClient, BibleClient } from '@youversion/platform-core'
65
47
 
48
+ // Initialize API client
66
49
  const apiClient = new ApiClient({
67
- appId: 'YOUR_APP_ID', // Required: Get your App ID from https://developers.youversion.com/
68
- baseUrl: 'https://api.youversion.com', // Optional: API base URL
69
- timeout: 10000, // Optional: Request timeout in ms (default: 10000)
70
- version: 'v1', // Optional: API version (default: "v1")
50
+ appKey: import.meta.env.YVP_APP_KEY,
71
51
  })
72
- ```
73
-
74
- ### Configuration Options
75
-
76
- | Option | Type | Default | Description |
77
- | ---------------- | -------- | ---------------------------------- | ----------------------------------------------------------------------------------------- |
78
- | `appId` | `string` | **Required** | Your application ID for API authentication. Get one at https://developers.youversion.com/ |
79
- | `baseUrl` | `string` | `"https://api-dev.youversion.com"` | Base URL for the API |
80
- | `timeout` | `number` | `10000` | Request timeout in milliseconds |
81
- | `version` | `string` | `"v1"` | API version to use |
82
-
83
- ## 📖 API Reference
84
-
85
- ### BibleClient
86
-
87
- The main client for interacting with Bible data.
88
-
89
- #### Methods
90
-
91
- ##### `getVersions(language_ranges: string): Promise<Collection<Version>>`
92
52
 
93
- Fetch available Bible versions filtered by language. The `language_ranges` parameter is required.
94
-
95
- ```ts
96
- // Get all English versions
97
- const englishVersions = await bibleClient.getVersions('en*')
98
-
99
- // Get specific language versions
100
- const spanishVersions = await bibleClient.getVersions('es*')
101
-
102
- // Get multiple language versions
103
- const multiLangVersions = await bibleClient.getVersions('en*,es*,fr*')
104
- ```
105
-
106
- ##### `getVersion(id: number): Promise<Version>`
107
-
108
- Fetch a specific Bible version by ID.
109
-
110
- ```ts
111
- const esv = await bibleClient.getVersion(111)
112
- console.log(esv.title) // "English Standard Version"
113
- ```
114
-
115
- ##### `getBooks(versionId: number): Promise<Collection<Book>>`
116
-
117
- Fetch all books for a specific Bible version.
118
-
119
- ```ts
120
- const books = await bibleClient.getBooks(206)
121
- ```
122
-
123
- ##### `getBook(versionId: number, book: string): Promise<BibleBook>`
124
-
125
- Fetch a specific book by its USFM identifier.
126
-
127
- ```ts
128
- const genesis = await bibleClient.getBook(111, 'GEN')
129
- console.log(genesis.title) // "Genesis"
130
- ```
131
-
132
- ##### `getChapters(versionId: number, book: string): Promise<Collection<BibleChapter>>`
53
+ const bibleClient = new BibleClient(apiClient)
133
54
 
134
- Fetch all chapters for a specific book.
55
+ // Get English Bible versions
56
+ const versions = await bibleClient.getVersions('en*')
57
+ console.log(versions.data[0].title)
135
58
 
136
- ```ts
137
- const chapters = await bibleClient.getChapters(206, 'GEN')
59
+ // Get a specific passage
60
+ const passage = await bibleClient.getPassage(111, 'JHN.3.16')
61
+ console.log(passage.content) // "For God so loved the world..."
138
62
  ```
139
63
 
140
- ##### `getChapter(versionId: number, book: string, chapter: number): Promise<BibleChapter>`
141
-
142
- Fetch a specific chapter.
64
+ ## Features
143
65
 
144
- ```ts
145
- const genesis1 = await bibleClient.getChapter(206, 'GEN', 1)
146
- const content = await bibleClient.getPassage(206, genesis1.passage_id)
147
- ```
66
+ - Retrieve Bible versions, books, chapters, verses, and passages
67
+ - Get formatted passages with optional headings and notes
68
+ - Access the complete Bible index structure
69
+ - Query available languages by country
70
+ - Get Verse of the Day
148
71
 
149
- ##### `getVerses(versionId: number, book: string, chapter: number): Promise<Collection<BibleVerse>>`
150
-
151
- Fetch all verses for a specific chapter.
72
+ ## Configuration
152
73
 
153
74
  ```ts
154
- const verses = await bibleClient.getVerses(111, 'GEN', 1)
155
- verses.data.forEach((verse) => {
156
- const passage = await bibleClient.getPassage(206, verse.passage_id)
75
+ const apiClient = new ApiClient({
76
+ appKey: import.meta.env.YVP_APP_KEY, // Required
77
+ timeout: 10000, // Optional (default: 10000ms)
157
78
  })
158
79
  ```
159
80
 
160
- ##### `getVerse(versionId: number, book: string, chapter: number, verse: number): Promise<BibleVerse>`
161
-
162
- Fetch a specific verse.
163
-
164
- ```ts
165
- const verse = await bibleClient.getVerse(111, 'GEN', 1, 1)
166
- console.log('Verse reference:', verse.reference)
167
- const passage = await bibleClient.getPassage(111, verse.passage_id)
168
- console.log('Content:', passage.content) // "In the beginning, God created the heavens and the earth."
169
- ```
170
-
171
- ### AuthClient
172
-
173
- Client for user authentication and user data.
174
-
175
- #### Methods
176
-
177
- ##### `getUser(lat: string): Promise<User>`
178
-
179
- Retrieve the current authenticated user using a Long Access Token.
180
-
181
- ```ts
182
- import { AuthClient } from '@youversion/platform-core'
183
-
184
- const authClient = new AuthClient(apiClient)
185
- const user = await authClient.getUser('YOUR_LONG_ACCESS_TOKEN')
186
- ```
187
-
188
- ## 🔍 TypeScript Types
189
-
190
- The library provides comprehensive TypeScript types for all API responses:
191
-
192
- ### Core Types
193
-
194
- ```ts
195
- type BibleVersion = {
196
- id: number
197
- abbreviation: string
198
- copyright_long: string
199
- copyright_short: string
200
- info: string
201
- publisher_url: string
202
- language_tag: string
203
- local_abbreviation: string
204
- local_title: string
205
- title: string
206
- books: Array<string>
207
- }
208
-
209
- interface BibleBook {
210
- id: string
211
- title: string
212
- abbreviation: string
213
- canon: string
214
- chapters: Array<string>
215
- }
216
-
217
- interface BibleChapter {
218
- id: string
219
- book_id: string
220
- passage_id: string
221
- title: string
222
- // ... additional fields
223
- }
224
-
225
- interface BibleVerse {
226
- id: string
227
- book_id: string
228
- chapter_id: string
229
- passage_id: string
230
- reference: string
231
- // ... additional fields
232
- }
233
-
234
- interface Collection<T> {
235
- data: T[]
236
- // ... pagination and metadata
237
- }
238
- ```
239
-
240
- ## 🎯 Common Use Cases
241
-
242
- ### 1. Building a Bible Reading App
243
-
244
- ```ts
245
- import { ApiClient, BibleClient } from '@youversion/platform-core'
246
-
247
- class BibleApp {
248
- private bibleClient: BibleClient
249
-
250
- constructor(appId: string) {
251
- const apiClient = new ApiClient({ appId })
252
- this.bibleClient = new BibleClient(apiClient)
253
- }
254
-
255
- async loadChapter(versionId: number, bookUsfm: string, chapterNum: number) {
256
- const chapter = await this.bibleClient.getChapter(versionId, bookUsfm, chapterNum)
257
- const verses = await this.bibleClient.getVerses(versionId, bookUsfm, chapterNum)
258
-
259
- return {
260
- chapter,
261
- verses: verses.data,
262
- }
263
- }
264
-
265
- async searchVersions(languageCode: string) {
266
- const versions = await this.bibleClient.getVersions(`${languageCode}*`)
267
- return versions.data
268
- }
269
- }
270
- ```
271
-
272
- ### 2. Creating a Verse Reference Tool
81
+ ## Troubleshooting
273
82
 
274
- ```ts
275
- async function getVerseReference(reference: string, versionId: number) {
276
- // Parse reference like "GEN 1:1"
277
- const [book, chapterVerse] = reference.split(' ')
278
- const [chapter, verse] = chapterVerse.split(':')
279
-
280
- const verseData = await bibleClient.getVerse(versionId, book, parseInt(chapter), parseInt(verse))
281
- const passage = await bibleClient.getPassage(versionId, verseData.passage_id)
282
-
283
- return {
284
- reference,
285
- content: passage.content,
286
- version: await bibleClient.getVersion(versionId),
287
- }
288
- }
289
- ```
290
-
291
- ### 3. Multi-language Bible Comparison
83
+ ### "Invalid appKey" Error
292
84
 
293
- ```ts
294
- async function compareVerses(book: string, chapter: number, verse: number, versionIds: number[]) {
295
- const comparisons = await Promise.all(
296
- versionIds.map(async (versionId) => {
297
- const [version, verseData] = await Promise.all([
298
- bibleClient.getVersion(versionId),
299
- bibleClient.getVerse(versionId, book, chapter, verse),
300
- ])
301
-
302
- const passage = await bibleClient.getPassage(versionId, verseData.passage_id)
303
- return {
304
- version: version.title,
305
- language: version.language_tag,
306
- content: passage.content,
307
- }
308
- })
309
- )
310
-
311
- return comparisons
312
- }
313
- ```
85
+ **Solution:** Verify your App Key from [platform.youversion.com](https://platform.youversion.com/). Check for typos or extra whitespace.
314
86
 
315
- ## 🚦 Error Handling
87
+ ### "Version not found" Error (404)
316
88
 
317
- The library uses standard HTTP status codes and provides meaningful error messages:
89
+ **Solution:** Verify the version ID exists:
318
90
 
319
91
  ```ts
320
- import { ApiClient, BibleClient } from '@youversion/platform-core'
321
-
322
- try {
323
- const bibleClient = new BibleClient(new ApiClient({ appId: 'YOUR_APP_ID' })) // Get App ID from https://developers.youversion.com/
324
- const version = await bibleClient.getVersion(999999) // Non-existent version
325
- } catch (error) {
326
- if (error.response?.status === 404) {
327
- console.error('Version not found')
328
- } else if (error.response?.status === 401) {
329
- console.error('Authentication failed - check your App ID')
330
- } else {
331
- console.error('An error occurred:', error.message)
332
- }
333
- }
334
- ```
335
-
336
- ## 🔧 Development
337
-
338
- ### Prerequisites
339
-
340
- - Node.js 18+
341
- - TypeScript 4.8+
342
-
343
- ### Building
344
-
345
- ```bash
346
- # Install dependencies
347
- npm install
348
-
349
- # Build the library
350
- npm run build
351
-
352
- # Run tests (from monorepo root for consistency)
353
- pnpm test
354
-
355
- # Run linting
356
- npm run lint
92
+ const versions = await bibleClient.getVersions('en*')
93
+ const validIds = versions.data.map(v => v.id)
94
+ console.log('Valid version IDs:', validIds)
357
95
  ```
358
96
 
359
- ## 📄 License
97
+ ## Development
360
98
 
361
- This package is part of the YouVersion Bible SDK and is subject to YouVersion's terms of service.
99
+ See [CONTRIBUTING.md](../../CONTRIBUTING.md) for development instructions.
362
100
 
363
- ## 🤝 Contributing
101
+ ## License
364
102
 
365
- This is an internal YouVersion package. For issues or feature requests, please contact the YouVersion development team.
103
+ See [LICENSE](../../LICENSE)
366
104
 
367
- ## 📚 Related Packages
105
+ ## Support
368
106
 
369
- - `@youversion/platform-react-ui` - React UI components for Bible applications
107
+ - GitHub Issues: [Create an issue](https://github.com/youversion/platform-sdk-react/issues)
108
+ - Platform Docs: [platform.youversion.com](https://platform.youversion.com/)
109
+ - Monorepo: [YouVersion Platform SDK](../../README.md)