@churchapps/content-providers 0.7.1 → 0.7.3
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 +24 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1394,8 +1394,8 @@ var B1ChurchProvider = class extends BaseProvider {
|
|
|
1394
1394
|
const allPlans = await fetchPlans(planTypeId, authData);
|
|
1395
1395
|
const yesterday = /* @__PURE__ */ new Date();
|
|
1396
1396
|
yesterday.setDate(yesterday.getDate() - 1);
|
|
1397
|
-
yesterday.
|
|
1398
|
-
const plans = allPlans.filter((p) =>
|
|
1397
|
+
const cutoff = `${yesterday.getFullYear()}-${String(yesterday.getMonth() + 1).padStart(2, "0")}-${String(yesterday.getDate()).padStart(2, "0")}`;
|
|
1398
|
+
const plans = allPlans.filter((p) => String(p.serviceDate).slice(0, 10) >= cutoff);
|
|
1399
1399
|
plans.sort((a, b) => new Date(a.serviceDate).getTime() - new Date(b.serviceDate).getTime());
|
|
1400
1400
|
const imageMap = await this.fetchPlanImages(plans, ministryId, authData);
|
|
1401
1401
|
return plans.map((p) => {
|
|
@@ -1710,6 +1710,9 @@ function filterMediaEntries(entries) {
|
|
|
1710
1710
|
if (entry[".tag"] === "folder") folders.push(entry);
|
|
1711
1711
|
else if (entry[".tag"] === "file" && isMediaFile(entry.name)) mediaFiles.push(entry);
|
|
1712
1712
|
}
|
|
1713
|
+
const byName = (a, b) => a.name.localeCompare(b.name, void 0, { numeric: true, sensitivity: "base" });
|
|
1714
|
+
folders.sort(byName);
|
|
1715
|
+
mediaFiles.sort(byName);
|
|
1713
1716
|
return { folders, mediaFiles };
|
|
1714
1717
|
}
|
|
1715
1718
|
|
|
@@ -17647,6 +17650,8 @@ var data_default4 = {
|
|
|
17647
17650
|
};
|
|
17648
17651
|
|
|
17649
17652
|
// src/providers/goCurriculum/GoCurriculumProvider.ts
|
|
17653
|
+
var CATALOG_URL = "https://dl.dropboxusercontent.com/scl/fi/kb3qlgspv92x8m3mk5s8d/data.json?rlkey=z13qq7aghyszv2w1yud2obtqm";
|
|
17654
|
+
var CATALOG_TTL_MS = 60 * 60 * 1e3;
|
|
17650
17655
|
var GoCurriculumProvider = class extends BaseProvider {
|
|
17651
17656
|
constructor() {
|
|
17652
17657
|
super(...arguments);
|
|
@@ -17671,10 +17676,21 @@ var GoCurriculumProvider = class extends BaseProvider {
|
|
|
17671
17676
|
scopes: ["basic"]
|
|
17672
17677
|
};
|
|
17673
17678
|
this.data = data_default4;
|
|
17679
|
+
this.dataFetchedAt = 0;
|
|
17674
17680
|
this.requiresAuth = true;
|
|
17675
17681
|
this.authTypes = ["oauth_pkce"];
|
|
17676
17682
|
this.capabilities = { browse: true, playlist: true, instructions: true, mediaLicensing: false };
|
|
17677
17683
|
}
|
|
17684
|
+
async getData() {
|
|
17685
|
+
if (Date.now() - this.dataFetchedAt < CATALOG_TTL_MS) return this.data;
|
|
17686
|
+
try {
|
|
17687
|
+
const response = await fetch(CATALOG_URL);
|
|
17688
|
+
if (response.ok) this.data = await response.json();
|
|
17689
|
+
} catch {
|
|
17690
|
+
}
|
|
17691
|
+
this.dataFetchedAt = Date.now();
|
|
17692
|
+
return this.data;
|
|
17693
|
+
}
|
|
17678
17694
|
// ponytail: any valid login unlocks everything for the pilot — per-tier (MemberPress) filtering waits on Go's membership endpoint
|
|
17679
17695
|
async verifyAuth(auth) {
|
|
17680
17696
|
const token = auth?.access_token;
|
|
@@ -17692,8 +17708,9 @@ var GoCurriculumProvider = class extends BaseProvider {
|
|
|
17692
17708
|
async browse(path, auth) {
|
|
17693
17709
|
if (!await this.verifyAuth(auth)) return [];
|
|
17694
17710
|
const { segments, depth } = parsePath(path);
|
|
17695
|
-
|
|
17696
|
-
|
|
17711
|
+
const data = await this.getData();
|
|
17712
|
+
if (depth === 0) return data.catalog.map((c) => createFolder(c.id, c.name, `/${c.id}`, c.thumbnail));
|
|
17713
|
+
const collection = data.catalog.find((c) => c.id === segments[0]);
|
|
17697
17714
|
if (!collection) return [];
|
|
17698
17715
|
if (depth === 1) return collection.lessons.map((l) => createFolder(l.id, l.name, `/${collection.id}/${l.id}`, l.thumbnail || collection.thumbnail, true));
|
|
17699
17716
|
if (depth === 2) return this.getLessonFiles(collection, segments[1]);
|
|
@@ -17708,7 +17725,7 @@ var GoCurriculumProvider = class extends BaseProvider {
|
|
|
17708
17725
|
if (!await this.verifyAuth(auth)) return null;
|
|
17709
17726
|
const { segments, depth } = parsePath(path);
|
|
17710
17727
|
if (depth !== 2) return null;
|
|
17711
|
-
const collection = this.
|
|
17728
|
+
const collection = (await this.getData()).catalog.find((c) => c.id === segments[0]);
|
|
17712
17729
|
if (!collection) return null;
|
|
17713
17730
|
const files = this.getLessonFiles(collection, segments[1]);
|
|
17714
17731
|
return files.length > 0 ? files : null;
|
|
@@ -17718,7 +17735,7 @@ var GoCurriculumProvider = class extends BaseProvider {
|
|
|
17718
17735
|
if (depth !== 2) return null;
|
|
17719
17736
|
const files = await this.getPlaylist(path, auth);
|
|
17720
17737
|
if (!files) return null;
|
|
17721
|
-
const collection = this.
|
|
17738
|
+
const collection = (await this.getData()).catalog.find((c) => c.id === segments[0]);
|
|
17722
17739
|
const lesson = collection?.lessons.find((l) => l.id === segments[1]);
|
|
17723
17740
|
return filesToInstructions(lesson?.name || "Lesson", files);
|
|
17724
17741
|
}
|
|
@@ -17821,7 +17838,7 @@ function getAvailableProviders(ids) {
|
|
|
17821
17838
|
}
|
|
17822
17839
|
|
|
17823
17840
|
// src/index.ts
|
|
17824
|
-
var VERSION = true ? "0.7.
|
|
17841
|
+
var VERSION = true ? "0.7.3" : "dev";
|
|
17825
17842
|
// Annotate the CommonJS export names for ESM import in node:
|
|
17826
17843
|
0 && (module.exports = {
|
|
17827
17844
|
APlayProvider,
|