@churchapps/content-providers 0.1.0 → 0.1.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/README.md +6 -6
- package/dist/index.cjs +40 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +40 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<img align="right" width="150" src="https://raw.githubusercontent.com/ChurchApps/B1Admin/main/public/images/logo.png">
|
|
2
2
|
|
|
3
|
-
# @churchapps/content-
|
|
3
|
+
# @churchapps/content-providers
|
|
4
4
|
|
|
5
5
|
> **ContentProviderHelper** is a TypeScript library for integrating with third-party content providers like Planning Center, Lessons.church, and more. It provides a unified interface for browsing media libraries, handling OAuth authentication, and retrieving content for playback in church presentation software.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @churchapps/content-
|
|
10
|
+
npm install @churchapps/content-providers
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
@@ -15,7 +15,7 @@ npm install @churchapps/content-provider-helper
|
|
|
15
15
|
### Browse Available Providers
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
import { getAllProviders, getAvailableProviders } from '@churchapps/content-
|
|
18
|
+
import { getAllProviders, getAvailableProviders } from '@churchapps/content-providers';
|
|
19
19
|
|
|
20
20
|
// Get all registered providers
|
|
21
21
|
const providers = getAllProviders();
|
|
@@ -28,7 +28,7 @@ console.log(available); // [{ id: 'planningcenter', name: 'Planning Center', ...
|
|
|
28
28
|
### Use a Specific Provider
|
|
29
29
|
|
|
30
30
|
```typescript
|
|
31
|
-
import { getProvider } from '@churchapps/content-
|
|
31
|
+
import { getProvider } from '@churchapps/content-providers';
|
|
32
32
|
|
|
33
33
|
const provider = getProvider('planningcenter');
|
|
34
34
|
|
|
@@ -51,7 +51,7 @@ const plan = await provider.getPresentations(serviceId);
|
|
|
51
51
|
### Create a Custom Provider
|
|
52
52
|
|
|
53
53
|
```typescript
|
|
54
|
-
import { ContentProvider, registerProvider } from '@churchapps/content-
|
|
54
|
+
import { ContentProvider, registerProvider } from '@churchapps/content-providers';
|
|
55
55
|
|
|
56
56
|
class MyProvider extends ContentProvider {
|
|
57
57
|
// Implement required methods
|
|
@@ -63,7 +63,7 @@ registerProvider(new MyProvider());
|
|
|
63
63
|
### Utilities
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
|
-
import { detectMediaType } from '@churchapps/content-
|
|
66
|
+
import { detectMediaType } from '@churchapps/content-providers';
|
|
67
67
|
|
|
68
68
|
detectMediaType('https://example.com/video.mp4'); // 'video'
|
|
69
69
|
detectMediaType('https://example.com/image.png'); // 'image'
|
package/dist/index.cjs
CHANGED
|
@@ -1112,6 +1112,12 @@ var LessonsChurchProvider = class {
|
|
|
1112
1112
|
this.capabilities = { browse: true, presentations: true, playlist: true, instructions: true, mediaLicensing: false };
|
|
1113
1113
|
}
|
|
1114
1114
|
async getPlaylist(path, _auth, resolution) {
|
|
1115
|
+
const { segments } = parsePath(path);
|
|
1116
|
+
if (segments[0] === "addons" && segments.length >= 3) {
|
|
1117
|
+
const addOnId = segments[2];
|
|
1118
|
+
const file = await convertAddOnToFile({ id: addOnId });
|
|
1119
|
+
return file ? [file] : null;
|
|
1120
|
+
}
|
|
1115
1121
|
const venueId = getSegment(path, 4);
|
|
1116
1122
|
if (!venueId) return null;
|
|
1117
1123
|
let apiPath = `/venues/playlist/${venueId}`;
|
|
@@ -1213,12 +1219,17 @@ var LessonsChurchProvider = class {
|
|
|
1213
1219
|
const files = await this.getPlaylist(`/lessons/_/_/_/${venueId}`, null);
|
|
1214
1220
|
return files || [];
|
|
1215
1221
|
}
|
|
1216
|
-
async browseAddOns(
|
|
1222
|
+
async browseAddOns(currentPath, segments) {
|
|
1217
1223
|
const depth = segments.length;
|
|
1218
1224
|
if (depth === 1) return this.getAddOnCategories();
|
|
1219
|
-
if (depth === 2) return this.getAddOnsByCategory(segments[1]);
|
|
1225
|
+
if (depth === 2) return this.getAddOnsByCategory(segments[1], currentPath);
|
|
1226
|
+
if (depth === 3) return this.getAddOnFiles(segments[2]);
|
|
1220
1227
|
return [];
|
|
1221
1228
|
}
|
|
1229
|
+
async getAddOnFiles(addOnId) {
|
|
1230
|
+
const file = await convertAddOnToFile({ id: addOnId });
|
|
1231
|
+
return file ? [file] : [];
|
|
1232
|
+
}
|
|
1222
1233
|
async getAddOnCategories() {
|
|
1223
1234
|
const response = await apiRequest(this.config.endpoints.addOns);
|
|
1224
1235
|
if (!response) return [];
|
|
@@ -1228,22 +1239,23 @@ var LessonsChurchProvider = class {
|
|
|
1228
1239
|
type: "folder",
|
|
1229
1240
|
id: `category-${category}`,
|
|
1230
1241
|
title: category,
|
|
1231
|
-
isLeaf: true,
|
|
1232
1242
|
path: `/addons/${encodeURIComponent(category)}`
|
|
1233
1243
|
}));
|
|
1234
1244
|
}
|
|
1235
|
-
async getAddOnsByCategory(category) {
|
|
1245
|
+
async getAddOnsByCategory(category, currentPath) {
|
|
1236
1246
|
const decodedCategory = decodeURIComponent(category);
|
|
1237
1247
|
const response = await apiRequest(this.config.endpoints.addOns);
|
|
1238
1248
|
if (!response) return [];
|
|
1239
1249
|
const allAddOns = Array.isArray(response) ? response : [];
|
|
1240
1250
|
const filtered = allAddOns.filter((a) => a.category === decodedCategory);
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1251
|
+
return filtered.map((addOn) => ({
|
|
1252
|
+
type: "folder",
|
|
1253
|
+
id: addOn.id,
|
|
1254
|
+
title: addOn.name,
|
|
1255
|
+
thumbnail: addOn.image,
|
|
1256
|
+
isLeaf: true,
|
|
1257
|
+
path: `${currentPath}/${addOn.id}`
|
|
1258
|
+
}));
|
|
1247
1259
|
}
|
|
1248
1260
|
// async getPresentations(path: string, _auth?: ContentProviderAuthData | null): Promise<Plan | null> {
|
|
1249
1261
|
// const venueId = getSegment(path, 4);
|
|
@@ -1272,6 +1284,22 @@ var LessonsChurchProvider = class {
|
|
|
1272
1284
|
return { name: planItemsResponse.venueName, items: (planItemsResponse.items || []).map((item) => processInstructionItem(item, sectionActionsMap, lessonImage)) };
|
|
1273
1285
|
}
|
|
1274
1286
|
const { segments } = parsePath(path);
|
|
1287
|
+
if (segments[0] === "addons" && segments.length === 3) {
|
|
1288
|
+
const addOnId = segments[2];
|
|
1289
|
+
const file = await convertAddOnToFile({ id: addOnId });
|
|
1290
|
+
if (!file) return null;
|
|
1291
|
+
return {
|
|
1292
|
+
name: file.title,
|
|
1293
|
+
items: [{
|
|
1294
|
+
id: addOnId,
|
|
1295
|
+
itemType: "action",
|
|
1296
|
+
relatedId: addOnId,
|
|
1297
|
+
label: file.title,
|
|
1298
|
+
seconds: file.seconds,
|
|
1299
|
+
children: [{ id: addOnId + "-file", itemType: "file", label: file.title, seconds: file.seconds, downloadUrl: file.url, thumbnail: file.thumbnail }]
|
|
1300
|
+
}]
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1275
1303
|
if (segments[0] === "addons" && segments.length === 2) {
|
|
1276
1304
|
return convertAddOnCategoryToInstructions(segments[1]);
|
|
1277
1305
|
}
|
|
@@ -2052,8 +2080,8 @@ var DropboxProvider = class {
|
|
|
2052
2080
|
this.id = "dropbox";
|
|
2053
2081
|
this.name = "Dropbox";
|
|
2054
2082
|
this.logos = {
|
|
2055
|
-
light: "https://
|
|
2056
|
-
dark: "https://
|
|
2083
|
+
light: "https://cdn.prod.website-files.com/66c503d081b2f012369fc5d2/674000d6c0a42d41f8c331be_dropbox-2-logo-png-transparent.png",
|
|
2084
|
+
dark: "https://cdn.prod.website-files.com/66c503d081b2f012369fc5d2/674000d6c0a42d41f8c331be_dropbox-2-logo-png-transparent.png"
|
|
2057
2085
|
};
|
|
2058
2086
|
this.config = {
|
|
2059
2087
|
id: "dropbox",
|