@youversion/platform-core 0.4.2 → 0.4.4

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/dist/index.cjs CHANGED
@@ -50,18 +50,21 @@ var ApiClient = class {
50
50
  /**
51
51
  * Creates an instance of ApiClient.
52
52
  *
53
- * @param config - The API configuration object containing baseUrl, timeout, and appId.
53
+ * @param config - The API configuration object containing baseUrl, timeout, and appKey.
54
54
  */
55
55
  constructor(config) {
56
56
  this.config = {
57
- version: config.version || "v1",
58
57
  ...config
59
58
  };
60
- this.baseURL = config.baseUrl || "https://api-dev.youversion.com";
59
+ const apiHost = config.apiHost || "api.youversion.com";
60
+ if (!apiHost) {
61
+ throw new Error("ApiClient requires a host name. Provide an apiHost in the config.");
62
+ }
63
+ this.baseURL = "https://" + apiHost;
61
64
  this.timeout = config.timeout || 1e4;
62
65
  this.defaultHeaders = {
63
66
  "Content-Type": "application/json",
64
- "X-YVP-App-Key": this.config.appId,
67
+ "X-YVP-App-Key": this.config.appKey,
65
68
  "X-YVP-Installation-Id": this.config.installationId || "web-sdk-default"
66
69
  };
67
70
  }
@@ -203,9 +206,6 @@ var BibleClient = class {
203
206
  constructor(client) {
204
207
  this.client = client;
205
208
  }
206
- get rootPath() {
207
- return `/${this.client.config.version}`;
208
- }
209
209
  /**
210
210
  * Fetches a collection of Bible versions filtered by language ranges.
211
211
  *
@@ -221,7 +221,7 @@ var BibleClient = class {
221
221
  if (license_id !== void 0) {
222
222
  params.license_id = license_id;
223
223
  }
224
- return this.client.get(`${this.rootPath}/bibles`, params);
224
+ return this.client.get(`/v1/bibles`, params);
225
225
  }
226
226
  /**
227
227
  * Fetches a Bible version by its ID.
@@ -230,7 +230,7 @@ var BibleClient = class {
230
230
  */
231
231
  async getVersion(id) {
232
232
  this.versionIdSchema.parse(id);
233
- return this.client.get(`${this.rootPath}/bibles/${id}`);
233
+ return this.client.get(`/v1/bibles/${id}`);
234
234
  }
235
235
  /**
236
236
  * Fetches all books for a given Bible version.
@@ -240,7 +240,7 @@ var BibleClient = class {
240
240
  */
241
241
  async getBooks(versionId, canon) {
242
242
  this.versionIdSchema.parse(versionId);
243
- return this.client.get(`${this.rootPath}/bibles/${versionId}/books`, {
243
+ return this.client.get(`/v1/bibles/${versionId}/books`, {
244
244
  ...canon && { canon }
245
245
  });
246
246
  }
@@ -253,7 +253,7 @@ var BibleClient = class {
253
253
  async getBook(versionId, book) {
254
254
  this.versionIdSchema.parse(versionId);
255
255
  this.bookSchema.parse(book);
256
- return this.client.get(`${this.rootPath}/bibles/${versionId}/books/${book}`);
256
+ return this.client.get(`/v1/bibles/${versionId}/books/${book}`);
257
257
  }
258
258
  /**
259
259
  * Fetches all chapters for a specific book in a version.
@@ -265,7 +265,7 @@ var BibleClient = class {
265
265
  this.versionIdSchema.parse(versionId);
266
266
  this.bookSchema.parse(book);
267
267
  return this.client.get(
268
- `${this.rootPath}/bibles/${versionId}/books/${book}/chapters`
268
+ `/v1/bibles/${versionId}/books/${book}/chapters`
269
269
  );
270
270
  }
271
271
  /**
@@ -280,7 +280,7 @@ var BibleClient = class {
280
280
  this.bookSchema.parse(book);
281
281
  this.chapterSchema.parse(chapter);
282
282
  return this.client.get(
283
- `${this.rootPath}/bibles/${versionId}/books/${book}/chapters/${chapter}`
283
+ `/v1/bibles/${versionId}/books/${book}/chapters/${chapter}`
284
284
  );
285
285
  }
286
286
  /**
@@ -295,7 +295,7 @@ var BibleClient = class {
295
295
  this.bookSchema.parse(book);
296
296
  this.chapterSchema.parse(chapter);
297
297
  return this.client.get(
298
- `${this.rootPath}/bibles/${versionId}/books/${book}/chapters/${chapter}/verses`
298
+ `/v1/bibles/${versionId}/books/${book}/chapters/${chapter}/verses`
299
299
  );
300
300
  }
301
301
  /**
@@ -312,7 +312,7 @@ var BibleClient = class {
312
312
  this.chapterSchema.parse(chapter);
313
313
  this.verseSchema.parse(verse);
314
314
  return this.client.get(
315
- `${this.rootPath}/bibles/${versionId}/books/${book}/chapters/${chapter}/verses/${verse}`
315
+ `/v1/bibles/${versionId}/books/${book}/chapters/${chapter}/verses/${verse}`
316
316
  );
317
317
  }
318
318
  /**
@@ -353,10 +353,7 @@ var BibleClient = class {
353
353
  if (include_notes !== void 0) {
354
354
  params.include_notes = include_notes;
355
355
  }
356
- return this.client.get(
357
- `${this.rootPath}/bibles/${versionId}/passages/${usfm}`,
358
- params
359
- );
356
+ return this.client.get(`/v1/bibles/${versionId}/passages/${usfm}`, params);
360
357
  }
361
358
  /**
362
359
  * Fetches the indexing structure for a Bible version.
@@ -365,14 +362,14 @@ var BibleClient = class {
365
362
  */
366
363
  async getIndex(versionId) {
367
364
  this.versionIdSchema.parse(versionId);
368
- return this.client.get(`${this.rootPath}/bibles/${versionId}/index`);
365
+ return this.client.get(`/v1/bibles/${versionId}/index`);
369
366
  }
370
367
  /**
371
368
  * Fetches the verse of the day calendar for an entire year.
372
369
  * @returns A collection of VOTD objects for all days of the year.
373
370
  */
374
371
  async getAllVOTDs() {
375
- return this.client.get(`${this.rootPath}/verse_of_the_days`);
372
+ return this.client.get(`/v1/verse_of_the_days`);
376
373
  }
377
374
  /**
378
375
  * Fetches the passage_id for the Verse Of The Day.
@@ -390,7 +387,7 @@ var BibleClient = class {
390
387
  async getVOTD(day) {
391
388
  const daySchema = import_zod.z.number().int().min(1).max(366);
392
389
  daySchema.parse(day);
393
- return this.client.get(`${this.rootPath}/verse_of_the_days/${day}`);
390
+ return this.client.get(`/v1/verse_of_the_days/${day}`);
394
391
  }
395
392
  };
396
393
 
@@ -410,9 +407,6 @@ var LanguagesClient = class {
410
407
  constructor(client) {
411
408
  this.client = client;
412
409
  }
413
- get rootPath() {
414
- return `/${this.client.config.version}`;
415
- }
416
410
  /**
417
411
  * Fetches a collection of languages supported in the Platform.
418
412
  * @param options Query parameters for pagination and filtering (country is required).
@@ -430,7 +424,7 @@ var LanguagesClient = class {
430
424
  if (options.page_token !== void 0) {
431
425
  params.page_token = options.page_token;
432
426
  }
433
- return this.client.get(`${this.rootPath}/languages`, params);
427
+ return this.client.get(`/v1/languages`, params);
434
428
  }
435
429
  /**
436
430
  * Fetches details about a specific language in the Platform.
@@ -439,7 +433,7 @@ var LanguagesClient = class {
439
433
  */
440
434
  async getLanguage(languageId) {
441
435
  this.languageIdSchema.parse(languageId);
442
- return this.client.get(`${this.rootPath}/languages/${languageId}`);
436
+ return this.client.get(`/v1/languages/${languageId}`);
443
437
  }
444
438
  };
445
439
 
@@ -448,10 +442,10 @@ var import_zod3 = require("zod");
448
442
 
449
443
  // src/YouVersionPlatformConfiguration.ts
450
444
  var YouVersionPlatformConfiguration = class {
451
- static _appId = null;
445
+ static _appKey = null;
452
446
  static _installationId = null;
453
447
  static _accessToken = null;
454
- static _apiHost = "api-dev.youversion.com";
448
+ static _apiHost = "api.youversion.com";
455
449
  static _isPreviewMode = false;
456
450
  static _previewUserInfo = null;
457
451
  static getOrSetInstallationId() {
@@ -466,11 +460,11 @@ var YouVersionPlatformConfiguration = class {
466
460
  localStorage.setItem("x-yvp-installation-id", newId);
467
461
  return newId;
468
462
  }
469
- static get appId() {
470
- return this._appId;
463
+ static get appKey() {
464
+ return this._appKey;
471
465
  }
472
- static set appId(value) {
473
- this._appId = value;
466
+ static set appKey(value) {
467
+ this._appKey = value;
474
468
  }
475
469
  static get installationId() {
476
470
  if (!this._installationId) {
@@ -523,9 +517,6 @@ var HighlightsClient = class {
523
517
  constructor(client) {
524
518
  this.client = client;
525
519
  }
526
- get rootPath() {
527
- return `/${this.client.config.version}`;
528
- }
529
520
  /**
530
521
  * Gets the authentication token, either from the provided parameter or from the platform configuration.
531
522
  * @param lat Optional explicit long access token. If not provided, retrieves from YouVersionPlatformConfiguration.
@@ -595,7 +586,7 @@ var HighlightsClient = class {
595
586
  this.validatePassageId(options.passage_id);
596
587
  params.passage_id = options.passage_id;
597
588
  }
598
- return this.client.get(`${this.rootPath}/highlights`, params);
589
+ return this.client.get(`/v1/highlights`, params);
599
590
  }
600
591
  /**
601
592
  * Creates or updates a highlight on a passage.
@@ -610,7 +601,7 @@ var HighlightsClient = class {
610
601
  this.validatePassageId(data.passage_id);
611
602
  this.validateColor(data.color);
612
603
  const token = this.getAuthToken(lat);
613
- return this.client.post(`${this.rootPath}/highlights`, data, { lat: token });
604
+ return this.client.post(`/v1/highlights`, data, { lat: token });
614
605
  }
615
606
  /**
616
607
  * Clears highlights for a passage.
@@ -630,7 +621,7 @@ var HighlightsClient = class {
630
621
  this.validateVersionId(options.version_id);
631
622
  params.version_id = options.version_id;
632
623
  }
633
- await this.client.delete(`${this.rootPath}/highlights/${passageId}`, params);
624
+ await this.client.delete(`/v1/highlights/${passageId}`, params);
634
625
  }
635
626
  };
636
627
 
@@ -928,13 +919,13 @@ var YouVersionAPI = class {
928
919
  Accept: "application/json",
929
920
  "Content-Type": "application/json"
930
921
  };
931
- const appId = YouVersionPlatformConfiguration.appId;
932
- if (appId) {
933
- headers["X-App-Id"] = appId;
922
+ const appKey = YouVersionPlatformConfiguration.appKey;
923
+ if (appKey) {
924
+ headers["X-YVP-App-Key"] = appKey;
934
925
  }
935
926
  const installationId = YouVersionPlatformConfiguration.installationId;
936
927
  if (installationId) {
937
- headers["x-yvp-installation-id"] = installationId;
928
+ headers["X-YVP-Installation-ID"] = installationId;
938
929
  }
939
930
  const request = new Request(url.toString(), {
940
931
  headers
@@ -948,15 +939,15 @@ var URLBuilder = class {
948
939
  static get baseURL() {
949
940
  return new URL(`https://${YouVersionPlatformConfiguration.apiHost}`);
950
941
  }
951
- static authURL(appId, requiredPermissions = /* @__PURE__ */ new Set(), optionalPermissions = /* @__PURE__ */ new Set()) {
952
- if (typeof appId !== "string" || appId.trim().length === 0) {
953
- throw new Error("appId must be a non-empty string");
942
+ static authURL(appKey, requiredPermissions = /* @__PURE__ */ new Set(), optionalPermissions = /* @__PURE__ */ new Set()) {
943
+ if (typeof appKey !== "string" || appKey.trim().length === 0) {
944
+ throw new Error("appKey must be a non-empty string");
954
945
  }
955
946
  try {
956
947
  const url = new URL(this.baseURL);
957
948
  url.pathname = "/auth/login";
958
949
  const searchParams = new URLSearchParams();
959
- searchParams.append("app_id", appId);
950
+ searchParams.append("APP_KEY", appKey);
960
951
  searchParams.append("language", "en");
961
952
  if (requiredPermissions.size > 0) {
962
953
  const requiredList = Array.from(requiredPermissions).map((p) => p.toString());
@@ -1020,11 +1011,11 @@ var YouVersionAPIUsers = class {
1020
1011
  if (!optionalPermissions || !(optionalPermissions instanceof Set)) {
1021
1012
  throw new Error("Invalid optionalPermissions: must be a Set");
1022
1013
  }
1023
- const appId = YouVersionPlatformConfiguration.appId;
1024
- if (!appId) {
1025
- throw new Error("YouVersionPlatformConfiguration.appId must be set before calling signIn");
1014
+ const appKey = YouVersionPlatformConfiguration.appKey;
1015
+ if (!appKey) {
1016
+ throw new Error("YouVersionPlatformConfiguration.appKey must be set before calling signIn");
1026
1017
  }
1027
- const url = URLBuilder.authURL(appId, requiredPermissions, optionalPermissions);
1018
+ const url = URLBuilder.authURL(appKey, requiredPermissions, optionalPermissions);
1028
1019
  const strategy = AuthenticationStrategyRegistry.get();
1029
1020
  const callbackUrl = await strategy.authenticate(url);
1030
1021
  const result = new SignInWithYouVersionResult(callbackUrl);
package/dist/index.d.cts CHANGED
@@ -179,11 +179,9 @@ type Collection<T> = {
179
179
  };
180
180
 
181
181
  interface ApiConfig {
182
- baseUrl?: string;
183
- appId: string;
182
+ apiHost?: string;
183
+ appKey: string;
184
184
  timeout?: number;
185
- hostEnv?: string;
186
- version?: string;
187
185
  installationId?: string;
188
186
  redirectUri?: string;
189
187
  }
@@ -237,7 +235,7 @@ declare class ApiClient {
237
235
  /**
238
236
  * Creates an instance of ApiClient.
239
237
  *
240
- * @param config - The API configuration object containing baseUrl, timeout, and appId.
238
+ * @param config - The API configuration object containing baseUrl, timeout, and appKey.
241
239
  */
242
240
  constructor(config: ApiConfig);
243
241
  /**
@@ -294,7 +292,6 @@ declare class BibleClient {
294
292
  * @param client The API client to use for requests.
295
293
  */
296
294
  constructor(client: ApiClient);
297
- private get rootPath();
298
295
  /**
299
296
  * Fetches a collection of Bible versions filtered by language ranges.
300
297
  *
@@ -424,7 +421,6 @@ declare class LanguagesClient {
424
421
  * @param client The API client to use for requests.
425
422
  */
426
423
  constructor(client: ApiClient);
427
- private get rootPath();
428
424
  /**
429
425
  * Fetches a collection of languages supported in the Platform.
430
426
  * @param options Query parameters for pagination and filtering (country is required).
@@ -466,7 +462,6 @@ declare class HighlightsClient {
466
462
  * @param client The API client to use for requests.
467
463
  */
468
464
  constructor(client: ApiClient);
469
- private get rootPath();
470
465
  /**
471
466
  * Gets the authentication token, either from the provided parameter or from the platform configuration.
472
467
  * @param lat Optional explicit long access token. If not provided, retrieves from YouVersionPlatformConfiguration.
@@ -701,20 +696,20 @@ declare class YouVersionAPI {
701
696
 
702
697
  declare class URLBuilder {
703
698
  private static get baseURL();
704
- static authURL(appId: string, requiredPermissions?: Set<SignInWithYouVersionPermissionValues>, optionalPermissions?: Set<SignInWithYouVersionPermissionValues>): URL;
699
+ static authURL(appKey: string, requiredPermissions?: Set<SignInWithYouVersionPermissionValues>, optionalPermissions?: Set<SignInWithYouVersionPermissionValues>): URL;
705
700
  static userURL(accessToken: string): URL;
706
701
  }
707
702
 
708
703
  declare class YouVersionPlatformConfiguration {
709
- private static _appId;
704
+ private static _appKey;
710
705
  private static _installationId;
711
706
  private static _accessToken;
712
707
  private static _apiHost;
713
708
  private static _isPreviewMode;
714
709
  private static _previewUserInfo;
715
710
  private static getOrSetInstallationId;
716
- static get appId(): string | null;
717
- static set appId(value: string | null);
711
+ static get appKey(): string | null;
712
+ static set appKey(value: string | null);
718
713
  static get installationId(): string;
719
714
  static set installationId(value: string | null);
720
715
  static setAccessToken(token: string | null): void;
package/dist/index.d.ts CHANGED
@@ -179,11 +179,9 @@ type Collection<T> = {
179
179
  };
180
180
 
181
181
  interface ApiConfig {
182
- baseUrl?: string;
183
- appId: string;
182
+ apiHost?: string;
183
+ appKey: string;
184
184
  timeout?: number;
185
- hostEnv?: string;
186
- version?: string;
187
185
  installationId?: string;
188
186
  redirectUri?: string;
189
187
  }
@@ -237,7 +235,7 @@ declare class ApiClient {
237
235
  /**
238
236
  * Creates an instance of ApiClient.
239
237
  *
240
- * @param config - The API configuration object containing baseUrl, timeout, and appId.
238
+ * @param config - The API configuration object containing baseUrl, timeout, and appKey.
241
239
  */
242
240
  constructor(config: ApiConfig);
243
241
  /**
@@ -294,7 +292,6 @@ declare class BibleClient {
294
292
  * @param client The API client to use for requests.
295
293
  */
296
294
  constructor(client: ApiClient);
297
- private get rootPath();
298
295
  /**
299
296
  * Fetches a collection of Bible versions filtered by language ranges.
300
297
  *
@@ -424,7 +421,6 @@ declare class LanguagesClient {
424
421
  * @param client The API client to use for requests.
425
422
  */
426
423
  constructor(client: ApiClient);
427
- private get rootPath();
428
424
  /**
429
425
  * Fetches a collection of languages supported in the Platform.
430
426
  * @param options Query parameters for pagination and filtering (country is required).
@@ -466,7 +462,6 @@ declare class HighlightsClient {
466
462
  * @param client The API client to use for requests.
467
463
  */
468
464
  constructor(client: ApiClient);
469
- private get rootPath();
470
465
  /**
471
466
  * Gets the authentication token, either from the provided parameter or from the platform configuration.
472
467
  * @param lat Optional explicit long access token. If not provided, retrieves from YouVersionPlatformConfiguration.
@@ -701,20 +696,20 @@ declare class YouVersionAPI {
701
696
 
702
697
  declare class URLBuilder {
703
698
  private static get baseURL();
704
- static authURL(appId: string, requiredPermissions?: Set<SignInWithYouVersionPermissionValues>, optionalPermissions?: Set<SignInWithYouVersionPermissionValues>): URL;
699
+ static authURL(appKey: string, requiredPermissions?: Set<SignInWithYouVersionPermissionValues>, optionalPermissions?: Set<SignInWithYouVersionPermissionValues>): URL;
705
700
  static userURL(accessToken: string): URL;
706
701
  }
707
702
 
708
703
  declare class YouVersionPlatformConfiguration {
709
- private static _appId;
704
+ private static _appKey;
710
705
  private static _installationId;
711
706
  private static _accessToken;
712
707
  private static _apiHost;
713
708
  private static _isPreviewMode;
714
709
  private static _previewUserInfo;
715
710
  private static getOrSetInstallationId;
716
- static get appId(): string | null;
717
- static set appId(value: string | null);
711
+ static get appKey(): string | null;
712
+ static set appKey(value: string | null);
718
713
  static get installationId(): string;
719
714
  static set installationId(value: string | null);
720
715
  static setAccessToken(token: string | null): void;