@youversion/platform-core 1.8.0 → 1.9.0
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/.turbo/turbo-build.log +4 -4
- package/AGENTS.md +79 -0
- package/CHANGELOG.md +12 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +3 -3
- package/src/__tests__/MockLanguages.ts +6 -6
- package/src/schemas/language.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @youversion/platform-core@1.
|
|
2
|
+
> @youversion/platform-core@1.9.0 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
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
[32mCJS[39m [1mdist/index.cjs [22m[32m43.59 KB[39m
|
|
14
14
|
[32mCJS[39m ⚡️ Build success in 35ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[32m32.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m32.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1915ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m32.91 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m32.91 KB[39m
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @youversion/platform-core
|
|
2
|
+
|
|
3
|
+
## OVERVIEW
|
|
4
|
+
Foundation package providing pure TypeScript API clients for YouVersion services with zero React dependencies.
|
|
5
|
+
|
|
6
|
+
**Related packages:**
|
|
7
|
+
- For React hooks wrapping these clients → see `packages/hooks/AGENTS.md`
|
|
8
|
+
- For pre-built UI components → see `packages/ui/AGENTS.md`
|
|
9
|
+
|
|
10
|
+
## STRUCTURE
|
|
11
|
+
```
|
|
12
|
+
schemas/ # Zod schemas for all data types (schema-first design)
|
|
13
|
+
client.ts # ApiClient - main HTTP client
|
|
14
|
+
bible.ts # BibleClient - Bible data operations
|
|
15
|
+
languages.ts # LanguagesClient - language data
|
|
16
|
+
highlights.ts # HighlightsClient - user highlights
|
|
17
|
+
YouVersionAPI.ts # Base YouVersion API client
|
|
18
|
+
SignInWithYouVersionPKCE.ts # PKCE auth implementation
|
|
19
|
+
StorageStrategy.ts # Storage interface (SessionStorage, MemoryStorage)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## PUBLIC API
|
|
23
|
+
- `ApiClient`: Main HTTP client with auth handling
|
|
24
|
+
- `BibleClient`: Fetch Bibles, chapters, verses, versions
|
|
25
|
+
- `LanguagesClient`: Get available languages
|
|
26
|
+
- `HighlightsClient`: Manage user highlights
|
|
27
|
+
- `SignInWithYouVersionPKCE()`: PKCE auth flow function
|
|
28
|
+
- `SessionStorage`, `MemoryStorage`: Storage strategies
|
|
29
|
+
|
|
30
|
+
## DOs / DON'Ts
|
|
31
|
+
|
|
32
|
+
✅ Do: Keep this package **framework-agnostic** (no React, no DOM, no browser-only APIs)
|
|
33
|
+
✅ Do: Define all input/output types in `schemas/` using Zod; schemas are the single source of truth
|
|
34
|
+
✅ Do: Reuse `YouVersionAPI` base client for new service clients
|
|
35
|
+
✅ Do: Parse API responses with Zod schemas for validation
|
|
36
|
+
|
|
37
|
+
❌ Don't: Import React, `window`, `document`, or browser storage APIs directly
|
|
38
|
+
❌ Don't: Bypass Zod validation for API responses
|
|
39
|
+
❌ Don't: Implement UI, hooks, or React state here
|
|
40
|
+
|
|
41
|
+
## ADDING A NEW ENDPOINT OR CLIENT
|
|
42
|
+
|
|
43
|
+
1. **Define types** in `schemas/` using Zod:
|
|
44
|
+
- Request payload schema
|
|
45
|
+
- Response schema
|
|
46
|
+
2. **Extend or add a client**:
|
|
47
|
+
- Prefer extending existing clients (e.g., `BibleClient`) when the endpoint logically belongs there
|
|
48
|
+
- Otherwise, create `xyz.ts` with a new `XyzClient` that composes `YouVersionAPI`
|
|
49
|
+
3. **Wire validation**:
|
|
50
|
+
- Parse API responses with the corresponding Zod schema
|
|
51
|
+
- Throw or return typed errors on validation failure
|
|
52
|
+
4. **Export from public API**:
|
|
53
|
+
- Expose the new client/types from the main entry file so consumers can import them
|
|
54
|
+
5. **Add tests**:
|
|
55
|
+
- Unit tests with MSW for mock responses
|
|
56
|
+
- Optional integration tests guarded by `INTEGRATION_TESTS=true`
|
|
57
|
+
|
|
58
|
+
## HTTP & CONFIGURATION
|
|
59
|
+
|
|
60
|
+
- HTTP client: Native `fetch` API
|
|
61
|
+
- Base client: `YouVersionAPI` handles base URL, headers, auth tokens
|
|
62
|
+
- All clients extend or compose `YouVersionAPI` for consistent HTTP behavior
|
|
63
|
+
|
|
64
|
+
## CONVENTIONS
|
|
65
|
+
- Schema-first: All types defined in schemas/*.ts using Zod
|
|
66
|
+
- Zero React: Pure TypeScript, no React dependencies
|
|
67
|
+
- Storage: Abstract via StorageStrategy interface
|
|
68
|
+
- Auth: PKCE flow with pluggable storage backends
|
|
69
|
+
- Error handling: Zod validation for all API responses
|
|
70
|
+
|
|
71
|
+
## TESTING
|
|
72
|
+
|
|
73
|
+
- Run tests: `pnpm --filter @youversion/platform-core test`
|
|
74
|
+
- Framework: Vitest with Node environment
|
|
75
|
+
- Mocking: MSW for API endpoints
|
|
76
|
+
- Integration tests:
|
|
77
|
+
- Guarded by `INTEGRATION_TESTS=true`
|
|
78
|
+
- Only run in CI or when explicitly needed; default to mocked tests
|
|
79
|
+
- Coverage: @vitest/coverage-v8
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @youversion/platform-core
|
|
2
2
|
|
|
3
|
+
## 1.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d4b0071: feat(hooks): Add useLanguage hook to retrieve a language from api
|
|
8
|
+
|
|
9
|
+
## 1.8.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 607be3c: Refactor verse HTML transformation to support verse-level highlighting. Extract HTML processing logic to `verse-html-utils.ts` with new `wrapVerseContent()` function that wraps verse content in CSS-targetable `<span class="yv-v">` elements. Simplify footnote extraction using wrapped verse structure. Remove CSS rule preventing text wrapping. Add comprehensive test coverage for verse wrapping behavior.
|
|
14
|
+
|
|
3
15
|
## 1.8.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.d.cts
CHANGED
|
@@ -166,7 +166,7 @@ declare const LanguageSchema: z.ZodObject<{
|
|
|
166
166
|
}>>;
|
|
167
167
|
writing_population: z.ZodOptional<z.ZodNumber>;
|
|
168
168
|
speaking_population: z.ZodOptional<z.ZodNumber>;
|
|
169
|
-
|
|
169
|
+
default_bible_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
170
170
|
}, z.core.$strip>;
|
|
171
171
|
type Language = Readonly<z.infer<typeof LanguageSchema>>;
|
|
172
172
|
|
package/dist/index.d.ts
CHANGED
|
@@ -166,7 +166,7 @@ declare const LanguageSchema: z.ZodObject<{
|
|
|
166
166
|
}>>;
|
|
167
167
|
writing_population: z.ZodOptional<z.ZodNumber>;
|
|
168
168
|
speaking_population: z.ZodOptional<z.ZodNumber>;
|
|
169
|
-
|
|
169
|
+
default_bible_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
170
170
|
}, z.core.$strip>;
|
|
171
171
|
type Language = Readonly<z.infer<typeof LanguageSchema>>;
|
|
172
172
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youversion/platform-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"tsup": "8.5.0",
|
|
31
31
|
"typescript": "5.9.3",
|
|
32
32
|
"vitest": "4.0.4",
|
|
33
|
-
"@internal/
|
|
34
|
-
"@internal/
|
|
33
|
+
"@internal/tsconfig": "0.0.0",
|
|
34
|
+
"@internal/eslint-config": "0.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"zod": "4.1.12"
|
|
@@ -14,7 +14,7 @@ export const mockLanguages: Language[] = [
|
|
|
14
14
|
text_direction: 'ltr',
|
|
15
15
|
writing_population: 1500000000,
|
|
16
16
|
speaking_population: 1500000000,
|
|
17
|
-
|
|
17
|
+
default_bible_id: null,
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
id: 'es',
|
|
@@ -29,7 +29,7 @@ export const mockLanguages: Language[] = [
|
|
|
29
29
|
text_direction: 'ltr',
|
|
30
30
|
writing_population: 500000000,
|
|
31
31
|
speaking_population: 500000000,
|
|
32
|
-
|
|
32
|
+
default_bible_id: null,
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
id: 'fr',
|
|
@@ -44,7 +44,7 @@ export const mockLanguages: Language[] = [
|
|
|
44
44
|
text_direction: 'ltr',
|
|
45
45
|
writing_population: 300000000,
|
|
46
46
|
speaking_population: 300000000,
|
|
47
|
-
|
|
47
|
+
default_bible_id: null,
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
id: 'de',
|
|
@@ -59,7 +59,7 @@ export const mockLanguages: Language[] = [
|
|
|
59
59
|
text_direction: 'ltr',
|
|
60
60
|
writing_population: 100000000,
|
|
61
61
|
speaking_population: 100000000,
|
|
62
|
-
|
|
62
|
+
default_bible_id: null,
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
id: 'sr-Latn',
|
|
@@ -74,7 +74,7 @@ export const mockLanguages: Language[] = [
|
|
|
74
74
|
text_direction: 'ltr',
|
|
75
75
|
writing_population: 8000000,
|
|
76
76
|
speaking_population: 8000000,
|
|
77
|
-
|
|
77
|
+
default_bible_id: null,
|
|
78
78
|
},
|
|
79
79
|
// Add more languages to exceed the maximum page size and exercise pagination
|
|
80
80
|
...Array.from({ length: 120 }, (_, i) => ({
|
|
@@ -90,6 +90,6 @@ export const mockLanguages: Language[] = [
|
|
|
90
90
|
text_direction: 'ltr' as const,
|
|
91
91
|
writing_population: 1000000,
|
|
92
92
|
speaking_population: 1000000,
|
|
93
|
-
|
|
93
|
+
default_bible_id: null,
|
|
94
94
|
})),
|
|
95
95
|
];
|
package/src/schemas/language.ts
CHANGED
|
@@ -32,7 +32,7 @@ export const LanguageSchema = z.object({
|
|
|
32
32
|
/** Speaking population count */
|
|
33
33
|
speaking_population: z.number().int().optional(),
|
|
34
34
|
/** Default Bible version ID for this language */
|
|
35
|
-
|
|
35
|
+
default_bible_id: z.number().int().nullable().optional(),
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
export type Language = Readonly<z.infer<typeof LanguageSchema>>;
|