@youversion/platform-core 1.2.0 → 1.2.1
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 +8 -8
- package/CHANGELOG.md +8 -0
- package/dist/index.cjs +6 -4
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -4
- package/package.json +1 -1
- package/src/__tests__/{MockLangauges.ts → MockLanguages.ts} +3 -3
- package/src/__tests__/handlers.ts +1 -1
- package/src/__tests__/languages.test.ts +9 -8
- package/src/languages.ts +7 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @youversion/platform-core@1.2.
|
|
2
|
+
> @youversion/platform-core@1.2.1 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
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es2022
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mESM[39m [1mdist/index.js [22m[32m41.09 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 34ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m42.90 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 34ms
|
|
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 2020ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m32.78 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m32.78 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @youversion/platform-core
|
|
2
2
|
|
|
3
|
+
## 1.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e845974: fix: make country parameter optional for getLanguages
|
|
8
|
+
|
|
9
|
+
The country parameter is now optional when fetching languages, allowing developers to retrieve all available languages without filtering by country. This improves developer experience by providing a more flexible API while maintaining backward compatibility for existing code that provides a country filter.
|
|
10
|
+
|
|
3
11
|
## 1.2.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -409,13 +409,15 @@ var LanguagesClient = class {
|
|
|
409
409
|
}
|
|
410
410
|
/**
|
|
411
411
|
* Fetches a collection of languages supported in the Platform.
|
|
412
|
-
* @param options Query parameters for pagination and filtering
|
|
412
|
+
* @param options Query parameters for pagination and filtering.
|
|
413
413
|
* @returns A collection of Language objects.
|
|
414
414
|
*/
|
|
415
|
-
async getLanguages(options) {
|
|
415
|
+
async getLanguages(options = {}) {
|
|
416
416
|
const params = {};
|
|
417
|
-
|
|
418
|
-
|
|
417
|
+
if (options.country !== void 0) {
|
|
418
|
+
const country = this.countrySchema.parse(options.country);
|
|
419
|
+
params.country = country;
|
|
420
|
+
}
|
|
419
421
|
if (options.page_size !== void 0) {
|
|
420
422
|
const pageSizeSchema = import_zod2.z.number().int().positive();
|
|
421
423
|
pageSizeSchema.parse(options.page_size);
|
package/dist/index.d.cts
CHANGED
|
@@ -449,7 +449,7 @@ declare class BibleClient {
|
|
|
449
449
|
type GetLanguagesOptions = {
|
|
450
450
|
page_size?: number;
|
|
451
451
|
page_token?: string;
|
|
452
|
-
country
|
|
452
|
+
country?: string;
|
|
453
453
|
};
|
|
454
454
|
/**
|
|
455
455
|
* Client for interacting with Languages API endpoints.
|
|
@@ -465,10 +465,10 @@ declare class LanguagesClient {
|
|
|
465
465
|
constructor(client: ApiClient);
|
|
466
466
|
/**
|
|
467
467
|
* Fetches a collection of languages supported in the Platform.
|
|
468
|
-
* @param options Query parameters for pagination and filtering
|
|
468
|
+
* @param options Query parameters for pagination and filtering.
|
|
469
469
|
* @returns A collection of Language objects.
|
|
470
470
|
*/
|
|
471
|
-
getLanguages(options
|
|
471
|
+
getLanguages(options?: GetLanguagesOptions): Promise<Collection<Language>>;
|
|
472
472
|
/**
|
|
473
473
|
* Fetches details about a specific language in the Platform.
|
|
474
474
|
* @param languageId The BCP 47 language code (optionally including script, e.g., "en" or "sr-Latn").
|
package/dist/index.d.ts
CHANGED
|
@@ -449,7 +449,7 @@ declare class BibleClient {
|
|
|
449
449
|
type GetLanguagesOptions = {
|
|
450
450
|
page_size?: number;
|
|
451
451
|
page_token?: string;
|
|
452
|
-
country
|
|
452
|
+
country?: string;
|
|
453
453
|
};
|
|
454
454
|
/**
|
|
455
455
|
* Client for interacting with Languages API endpoints.
|
|
@@ -465,10 +465,10 @@ declare class LanguagesClient {
|
|
|
465
465
|
constructor(client: ApiClient);
|
|
466
466
|
/**
|
|
467
467
|
* Fetches a collection of languages supported in the Platform.
|
|
468
|
-
* @param options Query parameters for pagination and filtering
|
|
468
|
+
* @param options Query parameters for pagination and filtering.
|
|
469
469
|
* @returns A collection of Language objects.
|
|
470
470
|
*/
|
|
471
|
-
getLanguages(options
|
|
471
|
+
getLanguages(options?: GetLanguagesOptions): Promise<Collection<Language>>;
|
|
472
472
|
/**
|
|
473
473
|
* Fetches details about a specific language in the Platform.
|
|
474
474
|
* @param languageId The BCP 47 language code (optionally including script, e.g., "en" or "sr-Latn").
|
package/dist/index.js
CHANGED
|
@@ -370,13 +370,15 @@ var LanguagesClient = class {
|
|
|
370
370
|
}
|
|
371
371
|
/**
|
|
372
372
|
* Fetches a collection of languages supported in the Platform.
|
|
373
|
-
* @param options Query parameters for pagination and filtering
|
|
373
|
+
* @param options Query parameters for pagination and filtering.
|
|
374
374
|
* @returns A collection of Language objects.
|
|
375
375
|
*/
|
|
376
|
-
async getLanguages(options) {
|
|
376
|
+
async getLanguages(options = {}) {
|
|
377
377
|
const params = {};
|
|
378
|
-
|
|
379
|
-
|
|
378
|
+
if (options.country !== void 0) {
|
|
379
|
+
const country = this.countrySchema.parse(options.country);
|
|
380
|
+
params.country = country;
|
|
381
|
+
}
|
|
380
382
|
if (options.page_size !== void 0) {
|
|
381
383
|
const pageSizeSchema = z2.number().int().positive();
|
|
382
384
|
pageSizeSchema.parse(options.page_size);
|
package/package.json
CHANGED
|
@@ -76,8 +76,8 @@ export const mockLanguages: Language[] = [
|
|
|
76
76
|
speaking_population: 8000000,
|
|
77
77
|
default_bible_version_id: null,
|
|
78
78
|
},
|
|
79
|
-
// Add more languages to
|
|
80
|
-
...Array.from({ length:
|
|
79
|
+
// Add more languages to exceed the maximum page size and exercise pagination
|
|
80
|
+
...Array.from({ length: 120 }, (_, i) => ({
|
|
81
81
|
id: `lang${i + 1}`,
|
|
82
82
|
language: `lang${i + 1}`,
|
|
83
83
|
script: 'Latn',
|
|
@@ -86,7 +86,7 @@ export const mockLanguages: Language[] = [
|
|
|
86
86
|
display_names: {},
|
|
87
87
|
scripts: ['Latn'],
|
|
88
88
|
variants: [],
|
|
89
|
-
countries: ['US'],
|
|
89
|
+
countries: i % 2 === 0 ? ['US', 'CA'] : ['BR'],
|
|
90
90
|
text_direction: 'ltr' as const,
|
|
91
91
|
writing_population: 1000000,
|
|
92
92
|
speaking_population: 1000000,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { http, HttpResponse } from 'msw';
|
|
2
2
|
import type { Collection, Highlight, Language } from '../types';
|
|
3
|
-
import { mockLanguages } from './
|
|
3
|
+
import { mockLanguages } from './MockLanguages';
|
|
4
4
|
import { mockVersions, mockVersionKJV } from './MockVersions';
|
|
5
5
|
import { mockBibleGenesis, mockBibleBooks } from './MockBibles';
|
|
6
6
|
import { mockChapterGenesis1, mockGenesisChapters } from './MockChapters';
|
|
@@ -17,22 +17,23 @@ describe('LanguagesClient', () => {
|
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
describe('getLanguages', () => {
|
|
20
|
-
it('should fetch languages
|
|
21
|
-
const languages = await languagesClient.getLanguages({
|
|
20
|
+
it('should fetch languages without country filter', async () => {
|
|
21
|
+
const languages = await languagesClient.getLanguages({ page_size: 99 });
|
|
22
22
|
|
|
23
23
|
const { success } = LanguageSchema.safeParse(languages.data[0]);
|
|
24
24
|
expect(success).toBe(true);
|
|
25
|
-
expect(languages.data).toHaveLength(
|
|
26
|
-
expect(languages.
|
|
25
|
+
expect(languages.data).toHaveLength(99);
|
|
26
|
+
expect(languages.next_page_token).not.toBeNull();
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
it('should fetch languages with
|
|
30
|
-
const languages = await languagesClient.getLanguages({ country: 'US', page_size:
|
|
29
|
+
it('should fetch languages with country filter', async () => {
|
|
30
|
+
const languages = await languagesClient.getLanguages({ country: 'US', page_size: 20 });
|
|
31
31
|
|
|
32
32
|
const { success } = LanguageSchema.safeParse(languages.data[0]);
|
|
33
33
|
expect(success).toBe(true);
|
|
34
|
-
expect(languages.data).toHaveLength(
|
|
35
|
-
expect(languages.
|
|
34
|
+
expect(languages.data).toHaveLength(20);
|
|
35
|
+
expect(languages.data.every((language) => language.countries?.includes('US'))).toBe(true);
|
|
36
|
+
expect(languages.next_page_token).not.toBeNull();
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
it('should throw an error for invalid country code - empty string', async () => {
|
package/src/languages.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { Collection, Language } from './types';
|
|
|
8
8
|
export type GetLanguagesOptions = {
|
|
9
9
|
page_size?: number;
|
|
10
10
|
page_token?: string;
|
|
11
|
-
country
|
|
11
|
+
country?: string; // ISO 3166-1 alpha-2 country code
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -41,15 +41,16 @@ export class LanguagesClient {
|
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Fetches a collection of languages supported in the Platform.
|
|
44
|
-
* @param options Query parameters for pagination and filtering
|
|
44
|
+
* @param options Query parameters for pagination and filtering.
|
|
45
45
|
* @returns A collection of Language objects.
|
|
46
46
|
*/
|
|
47
|
-
async getLanguages(options: GetLanguagesOptions): Promise<Collection<Language>> {
|
|
47
|
+
async getLanguages(options: GetLanguagesOptions = {}): Promise<Collection<Language>> {
|
|
48
48
|
const params: Record<string, string | number> = {};
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
if (options.country !== undefined) {
|
|
51
|
+
const country = this.countrySchema.parse(options.country);
|
|
52
|
+
params.country = country;
|
|
53
|
+
}
|
|
53
54
|
|
|
54
55
|
if (options.page_size !== undefined) {
|
|
55
56
|
const pageSizeSchema = z.number().int().positive();
|