@churchapps/content-providers 0.7.2 → 0.8.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/dist/index.cjs CHANGED
@@ -202,7 +202,8 @@ var DeviceFlowHelper = class {
202
202
  const response = await fetch(`${config.oauthBase}/token`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ grant_type: "urn:ietf:params:oauth:grant-type:device_code", device_code: deviceCode, client_id: config.clientId }) });
203
203
  if (response.ok) {
204
204
  const data = await response.json();
205
- return toAuthData(data, { scope: config.scopes.join(" ") });
205
+ const auth = toAuthData(data, { scope: config.scopes.join(" ") });
206
+ return data.plan_type_id ? { ...auth, planTypeId: data.plan_type_id } : auth;
206
207
  }
207
208
  const errorData = await response.json();
208
209
  switch (errorData.error) {
@@ -710,7 +711,7 @@ async function convertAddOnToFile(addOn) {
710
711
  } else {
711
712
  return null;
712
713
  }
713
- return { type: "file", id: addOn.id, title: addOn.name, mediaType, thumbnail: addOn.image, url, downloadUrl: url, seconds, loopVideo: video?.loopVideo || false };
714
+ return { type: "file", id: addOn.id, title: addOn.name ?? detail.name, mediaType, thumbnail: addOn.image ?? detail.image, url, downloadUrl: url, seconds, loopVideo: video?.loopVideo || false };
714
715
  }
715
716
  function buildSectionActionsMap(actionsResponse, lessonImage, feedResponse) {
716
717
  const sectionActionsMap = /* @__PURE__ */ new Map();
@@ -1235,7 +1236,7 @@ var SECTION_TYPES = /* @__PURE__ */ new Set(["item", "section", "lessonSection",
1235
1236
  var ACTION_TYPES = /* @__PURE__ */ new Set(["action", "lessonAction", "providerPresentation", "lessonAddOn", "addon", "providerFile", "file"]);
1236
1237
  function collectFilesFromNode(node) {
1237
1238
  const files = [];
1238
- if (node.downloadUrl) {
1239
+ if (node.downloadUrl && (node.itemType === "file" || !node.children?.length)) {
1239
1240
  files.push({
1240
1241
  id: node.id,
1241
1242
  name: node.label || "",
@@ -1394,8 +1395,8 @@ var B1ChurchProvider = class extends BaseProvider {
1394
1395
  const allPlans = await fetchPlans(planTypeId, authData);
1395
1396
  const yesterday = /* @__PURE__ */ new Date();
1396
1397
  yesterday.setDate(yesterday.getDate() - 1);
1397
- yesterday.setHours(0, 0, 0, 0);
1398
- const plans = allPlans.filter((p) => new Date(p.serviceDate).getTime() >= yesterday.getTime());
1398
+ const cutoff = `${yesterday.getFullYear()}-${String(yesterday.getMonth() + 1).padStart(2, "0")}-${String(yesterday.getDate()).padStart(2, "0")}`;
1399
+ const plans = allPlans.filter((p) => String(p.serviceDate).slice(0, 10) >= cutoff);
1399
1400
  plans.sort((a, b) => new Date(a.serviceDate).getTime() - new Date(b.serviceDate).getTime());
1400
1401
  const imageMap = await this.fetchPlanImages(plans, ministryId, authData);
1401
1402
  return plans.map((p) => {
@@ -17838,7 +17839,7 @@ function getAvailableProviders(ids) {
17838
17839
  }
17839
17840
 
17840
17841
  // src/index.ts
17841
- var VERSION = true ? "0.7.2" : "dev";
17842
+ var VERSION = true ? "0.8.0" : "dev";
17842
17843
  // Annotate the CommonJS export names for ESM import in node:
17843
17844
  0 && (module.exports = {
17844
17845
  APlayProvider,