@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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @youversion/platform-core@1.2.0 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/core
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
  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 42.87 KB
12
- CJS ⚡️ Build success in 31ms
13
- ESM dist/index.js 41.06 KB
14
- ESM ⚡️ Build success in 32ms
11
+ ESM dist/index.js 41.09 KB
12
+ ESM ⚡️ Build success in 34ms
13
+ CJS dist/index.cjs 42.90 KB
14
+ CJS ⚡️ Build success in 34ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 1751ms
17
- DTS dist/index.d.cts 32.80 KB
18
- DTS dist/index.d.ts 32.80 KB
16
+ DTS ⚡️ Build success in 2020ms
17
+ DTS dist/index.d.cts 32.78 KB
18
+ DTS dist/index.d.ts 32.78 KB
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 (country is required).
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
- const country = this.countrySchema.parse(options.country);
418
- params.country = country;
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: string;
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 (country is required).
468
+ * @param options Query parameters for pagination and filtering.
469
469
  * @returns A collection of Language objects.
470
470
  */
471
- getLanguages(options: GetLanguagesOptions): Promise<Collection<Language>>;
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: string;
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 (country is required).
468
+ * @param options Query parameters for pagination and filtering.
469
469
  * @returns A collection of Language objects.
470
470
  */
471
- getLanguages(options: GetLanguagesOptions): Promise<Collection<Language>>;
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 (country is required).
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
- const country = this.countrySchema.parse(options.country);
379
- params.country = country;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youversion/platform-core",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -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 reach 25 for default page size when filtering by 'US'
80
- ...Array.from({ length: 24 }, (_, i) => ({
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 './MockLangauges';
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 with required country param', async () => {
21
- const languages = await languagesClient.getLanguages({ country: 'US' });
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(25);
26
- expect(languages.data[0]).toHaveProperty('countries', expect.arrayContaining(['US']));
25
+ expect(languages.data).toHaveLength(99);
26
+ expect(languages.next_page_token).not.toBeNull();
27
27
  });
28
28
 
29
- it('should fetch languages with page_size option', async () => {
30
- const languages = await languagesClient.getLanguages({ country: 'US', page_size: 10 });
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(10);
35
- expect(languages.next_page_token).toBe('eyJzdGFydCI6IDEwfQ==');
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: string; // ISO 3166-1 alpha-2 country code (required per OpenAPI spec)
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 (country is required).
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
- // Country is required per OpenAPI spec
51
- const country = this.countrySchema.parse(options.country);
52
- params.country = country;
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();