@churchapps/content-providers 0.1.12 → 0.1.13
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 +16 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/package.json +56 -56
package/dist/index.cjs
CHANGED
|
@@ -73,7 +73,8 @@ function slugify(text) {
|
|
|
73
73
|
return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
74
74
|
}
|
|
75
75
|
function detectMediaType(url, explicitType) {
|
|
76
|
-
if (explicitType === "video") return "video";
|
|
76
|
+
if (explicitType === "video" || explicitType?.startsWith("video/")) return "video";
|
|
77
|
+
if (explicitType === "image" || explicitType?.startsWith("image/")) return "image";
|
|
77
78
|
const videoPatterns = [".mp4", ".webm", ".m3u8", ".mov", "stream.mux.com"];
|
|
78
79
|
return videoPatterns.some((p) => url.includes(p)) ? "video" : "image";
|
|
79
80
|
}
|
|
@@ -999,6 +1000,7 @@ function buildSectionActionsMap(actionsResponse, lessonImage, feedResponse) {
|
|
|
999
1000
|
const actionThumbnailMap = /* @__PURE__ */ new Map();
|
|
1000
1001
|
const actionUrlMap = /* @__PURE__ */ new Map();
|
|
1001
1002
|
const actionContentMap = /* @__PURE__ */ new Map();
|
|
1003
|
+
const actionMediaTypeMap = /* @__PURE__ */ new Map();
|
|
1002
1004
|
if (feedResponse?.sections) {
|
|
1003
1005
|
for (const section of feedResponse.sections) {
|
|
1004
1006
|
for (const action of section.actions || []) {
|
|
@@ -1007,7 +1009,10 @@ function buildSectionActionsMap(actionsResponse, lessonImage, feedResponse) {
|
|
|
1007
1009
|
if (action.files?.length) {
|
|
1008
1010
|
const firstFile = action.files[0];
|
|
1009
1011
|
if (firstFile?.thumbnail) actionThumbnailMap.set(action.id, firstFile.thumbnail);
|
|
1010
|
-
if (firstFile?.url)
|
|
1012
|
+
if (firstFile?.url) {
|
|
1013
|
+
actionUrlMap.set(action.id, firstFile.url);
|
|
1014
|
+
actionMediaTypeMap.set(action.id, detectMediaType(firstFile.url, firstFile.fileType));
|
|
1015
|
+
}
|
|
1011
1016
|
}
|
|
1012
1017
|
}
|
|
1013
1018
|
}
|
|
@@ -1022,11 +1027,12 @@ function buildSectionActionsMap(actionsResponse, lessonImage, feedResponse) {
|
|
|
1022
1027
|
const hasFiles = rawActionType === "play" || rawActionType === "add-on";
|
|
1023
1028
|
const thumbnail = action.id && actionThumbnailMap.get(action.id) || lessonImage;
|
|
1024
1029
|
const downloadUrl = action.id ? actionUrlMap.get(action.id) : void 0;
|
|
1030
|
+
const mediaType = action.id ? actionMediaTypeMap.get(action.id) : void 0;
|
|
1025
1031
|
const fullContent = action.id ? actionContentMap.get(action.id) : void 0;
|
|
1026
1032
|
const label = fullContent ? truncateForLabel(fullContent) : action.name;
|
|
1027
1033
|
const needsFullContent = fullContent && (fullContent.length > 100 || fullContent.includes("\n"));
|
|
1028
1034
|
const content = needsFullContent ? fullContent : void 0;
|
|
1029
|
-
return { id: action.id, itemType: "action", relatedId: action.id, label, actionType: rawActionType || void 0, content, seconds, downloadUrl, thumbnail, children: hasFiles ? [{ id: action.id + "-file", itemType: "file", label: action.name, seconds, downloadUrl, thumbnail }] : void 0 };
|
|
1035
|
+
return { id: action.id, itemType: "action", relatedId: action.id, label, actionType: rawActionType || void 0, content, seconds, downloadUrl, mediaType, thumbnail, children: hasFiles ? [{ id: action.id + "-file", itemType: "file", label: action.name, seconds, downloadUrl, mediaType, thumbnail }] : void 0 };
|
|
1030
1036
|
}));
|
|
1031
1037
|
}
|
|
1032
1038
|
}
|
|
@@ -1046,7 +1052,9 @@ function processInstructionItem(item, sectionActionsMap, thumbnail) {
|
|
|
1046
1052
|
const childItemType = normalizeItemType(rawChildItemType);
|
|
1047
1053
|
if (childRelatedId && sectionActionsMap.has(childRelatedId)) {
|
|
1048
1054
|
const sectionActions = sectionActionsMap.get(childRelatedId);
|
|
1049
|
-
const
|
|
1055
|
+
const firstAction = sectionActions?.[0];
|
|
1056
|
+
const firstActionUrl = firstAction?.downloadUrl;
|
|
1057
|
+
const firstActionMediaType = firstAction?.mediaType;
|
|
1050
1058
|
return {
|
|
1051
1059
|
id: child.id,
|
|
1052
1060
|
itemType: childItemType,
|
|
@@ -1057,6 +1065,7 @@ function processInstructionItem(item, sectionActionsMap, thumbnail) {
|
|
|
1057
1065
|
seconds: child.seconds,
|
|
1058
1066
|
children: sectionActions,
|
|
1059
1067
|
downloadUrl: firstActionUrl,
|
|
1068
|
+
mediaType: firstActionMediaType,
|
|
1060
1069
|
thumbnail
|
|
1061
1070
|
};
|
|
1062
1071
|
}
|
|
@@ -1094,13 +1103,15 @@ async function convertAddOnCategoryToInstructions(category) {
|
|
|
1094
1103
|
const file = await convertAddOnToFile(addOn);
|
|
1095
1104
|
const seconds = file?.seconds || addOn.seconds || 10;
|
|
1096
1105
|
const downloadUrl = file?.url;
|
|
1106
|
+
const mediaType = file?.mediaType;
|
|
1097
1107
|
children.push({
|
|
1098
1108
|
id,
|
|
1099
1109
|
itemType: "action",
|
|
1100
1110
|
relatedId: id,
|
|
1101
1111
|
label,
|
|
1102
1112
|
seconds,
|
|
1103
|
-
|
|
1113
|
+
mediaType,
|
|
1114
|
+
children: [{ id: id + "-file", itemType: "file", label, seconds, downloadUrl, mediaType, thumbnail: addOnImage }]
|
|
1104
1115
|
});
|
|
1105
1116
|
}
|
|
1106
1117
|
if (children.length === 0) return null;
|