@churchapps/helpers 1.2.5 → 1.2.7

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.
Files changed (39) hide show
  1. package/dist/PlanHelper.d.ts +13 -0
  2. package/dist/PlanHelper.d.ts.map +1 -0
  3. package/dist/PlanHelper.js +89 -0
  4. package/dist/PlanHelper.js.map +1 -0
  5. package/dist/contentProviders/ContentProvider.d.ts +7 -0
  6. package/dist/contentProviders/ContentProvider.d.ts.map +1 -0
  7. package/dist/contentProviders/ContentProvider.js +3 -0
  8. package/dist/contentProviders/ContentProvider.js.map +1 -0
  9. package/dist/contentProviders/LessonsContentProvider.d.ts +17 -0
  10. package/dist/contentProviders/LessonsContentProvider.d.ts.map +1 -0
  11. package/dist/contentProviders/LessonsContentProvider.js +101 -0
  12. package/dist/contentProviders/LessonsContentProvider.js.map +1 -0
  13. package/dist/contentProviders/index.d.ts +3 -0
  14. package/dist/contentProviders/index.d.ts.map +1 -0
  15. package/dist/contentProviders/index.js +6 -0
  16. package/dist/contentProviders/index.js.map +1 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +4 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/interfaces/Doing.d.ts +37 -0
  22. package/dist/interfaces/Doing.d.ts.map +1 -1
  23. package/dist/interfaces/Lessons.d.ts +47 -0
  24. package/dist/interfaces/Lessons.d.ts.map +1 -0
  25. package/dist/interfaces/Lessons.js +4 -0
  26. package/dist/interfaces/Lessons.js.map +1 -0
  27. package/dist/interfaces/index.d.ts +1 -0
  28. package/dist/interfaces/index.d.ts.map +1 -1
  29. package/dist/interfaces/index.js +1 -0
  30. package/dist/interfaces/index.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/PlanHelper.ts +109 -0
  33. package/src/contentProviders/ContentProvider.ts +15 -0
  34. package/src/contentProviders/LessonsContentProvider.ts +129 -0
  35. package/src/contentProviders/index.ts +2 -0
  36. package/src/index.ts +2 -0
  37. package/src/interfaces/Doing.ts +41 -0
  38. package/src/interfaces/Lessons.ts +61 -0
  39. package/src/interfaces/index.ts +1 -0
@@ -0,0 +1,13 @@
1
+ import type { PlanInterface, PlanItemInterface } from "./interfaces";
2
+ import type { ContentProviderInterface } from "./contentProviders/ContentProvider";
3
+ import { LessonsContentProvider } from "./contentProviders/LessonsContentProvider";
4
+ export declare class PlanHelper {
5
+ private static providers;
6
+ static registerProvider(provider: ContentProviderInterface): void;
7
+ static replaceProvider(provider: ContentProviderInterface): void;
8
+ static populate(plan: PlanInterface, planItems: PlanItemInterface[]): Promise<PlanItemInterface[]>;
9
+ private static flattenItems;
10
+ private static attachContent;
11
+ static getLessonsProvider(): LessonsContentProvider;
12
+ }
13
+ //# sourceMappingURL=PlanHelper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlanHelper.d.ts","sourceRoot":"","sources":["../src/PlanHelper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAA4B,MAAM,cAAc,CAAC;AAC/F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAEnF,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAC,SAAS,CAEtB;IAGF,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,IAAI;IAQjE,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,wBAAwB,GAAG,IAAI;WAUnD,QAAQ,CACnB,IAAI,EAAE,aAAa,EACnB,SAAS,EAAE,iBAAiB,EAAE,GAC7B,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAyC/B,OAAO,CAAC,MAAM,CAAC,YAAY;IAiB3B,OAAO,CAAC,MAAM,CAAC,aAAa;IAgB5B,MAAM,CAAC,kBAAkB,IAAI,sBAAsB;CAGpD"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlanHelper = void 0;
4
+ const LessonsContentProvider_1 = require("./contentProviders/LessonsContentProvider");
5
+ class PlanHelper {
6
+ static providers = [
7
+ new LessonsContentProvider_1.LessonsContentProvider()
8
+ ];
9
+ // Register additional content providers
10
+ static registerProvider(provider) {
11
+ // Avoid duplicates
12
+ if (!this.providers.find(p => p.providerId === provider.providerId)) {
13
+ this.providers.push(provider);
14
+ }
15
+ }
16
+ // Replace a provider (useful for configuring with different URLs)
17
+ static replaceProvider(provider) {
18
+ const index = this.providers.findIndex(p => p.providerId === provider.providerId);
19
+ if (index >= 0) {
20
+ this.providers[index] = provider;
21
+ }
22
+ else {
23
+ this.providers.push(provider);
24
+ }
25
+ }
26
+ // Main method: populate planItems with their content
27
+ static async populate(plan, planItems) {
28
+ // Flatten hierarchy to get all items
29
+ const allItems = this.flattenItems(planItems);
30
+ // Group items by provider
31
+ const itemsByProvider = new Map();
32
+ for (const item of allItems) {
33
+ for (const provider of this.providers) {
34
+ if (provider.canHandle(plan, item)) {
35
+ const existing = itemsByProvider.get(provider) || [];
36
+ existing.push(item);
37
+ itemsByProvider.set(provider, existing);
38
+ break; // First matching provider wins
39
+ }
40
+ }
41
+ }
42
+ // Fetch content from each provider in parallel
43
+ const fetchPromises = [];
44
+ const contentMap = new Map();
45
+ for (const [provider, items] of itemsByProvider) {
46
+ fetchPromises.push(provider.fetchContent(plan, items).then(providerContent => {
47
+ for (const [itemId, content] of providerContent) {
48
+ contentMap.set(itemId, content);
49
+ }
50
+ }));
51
+ }
52
+ await Promise.all(fetchPromises);
53
+ // Attach content to items (mutates in place for efficiency)
54
+ this.attachContent(planItems, contentMap);
55
+ return planItems;
56
+ }
57
+ // Flatten nested planItems for processing
58
+ static flattenItems(items) {
59
+ const result = [];
60
+ const collect = (itemList) => {
61
+ for (const item of itemList) {
62
+ result.push(item);
63
+ if (item.children?.length) {
64
+ collect(item.children);
65
+ }
66
+ }
67
+ };
68
+ collect(items);
69
+ return result;
70
+ }
71
+ // Attach content to items recursively
72
+ static attachContent(items, contentMap) {
73
+ for (const item of items) {
74
+ const content = contentMap.get(item.id);
75
+ if (content) {
76
+ item.content = content;
77
+ }
78
+ if (item.children?.length) {
79
+ this.attachContent(item.children, contentMap);
80
+ }
81
+ }
82
+ }
83
+ // Convenience: Get the lessons provider for direct lesson operations
84
+ static getLessonsProvider() {
85
+ return this.providers.find(p => p.providerId === "lessons");
86
+ }
87
+ }
88
+ exports.PlanHelper = PlanHelper;
89
+ //# sourceMappingURL=PlanHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlanHelper.js","sourceRoot":"","sources":["../src/PlanHelper.ts"],"names":[],"mappings":";;;AAEA,sFAAmF;AAEnF,MAAa,UAAU;IACb,MAAM,CAAC,SAAS,GAA+B;QACrD,IAAI,+CAAsB,EAAE;KAC7B,CAAC;IAEF,wCAAwC;IACxC,MAAM,CAAC,gBAAgB,CAAC,QAAkC;QACxD,mBAAmB;QACnB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACpE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,kEAAkE;IAClE,MAAM,CAAC,eAAe,CAAC,QAAkC;QACvD,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,QAAQ,CAAC,UAAU,CAAC,CAAC;QAClF,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,C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PlanInterface, PlanItemInterface, PlanItemContentInterface } from "../interfaces";
2
+ export interface ContentProviderInterface {
3
+ readonly providerId: string;
4
+ canHandle(plan: PlanInterface, planItem: PlanItemInterface): boolean;
5
+ fetchContent(plan: PlanInterface, planItems: PlanItemInterface[]): Promise<Map<string, PlanItemContentInterface>>;
6
+ }
7
+ //# sourceMappingURL=ContentProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentProvider.d.ts","sourceRoot":"","sources":["../../src/contentProviders/ContentProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEhG,MAAM,WAAW,wBAAwB;IAEvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAG5B,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAGrE,YAAY,CACV,IAAI,EAAE,aAAa,EACnB,SAAS,EAAE,iBAAiB,EAAE,GAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC,CAAC;CACnD"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ContentProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentProvider.js","sourceRoot":"","sources":["../../src/contentProviders/ContentProvider.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import type { PlanInterface, PlanItemInterface, PlanItemContentInterface, ExternalVenueRefInterface } from "../interfaces";
2
+ import type { VenuePlanItemsResponseInterface, VenueActionResponseInterface } from "../interfaces/Lessons";
3
+ import type { ContentProviderInterface } from "./ContentProvider";
4
+ export declare class LessonsContentProvider implements ContentProviderInterface {
5
+ readonly providerId = "lessons";
6
+ private lessonsUrl;
7
+ constructor(lessonsUrl?: string);
8
+ canHandle(plan: PlanInterface, planItem: PlanItemInterface): boolean;
9
+ fetchContent(plan: PlanInterface, planItems: PlanItemInterface[]): Promise<Map<string, PlanItemContentInterface>>;
10
+ fetchVenuePlanItems(plan: PlanInterface): Promise<VenuePlanItemsResponseInterface>;
11
+ fetchVenueActions(plan: PlanInterface): Promise<VenueActionResponseInterface>;
12
+ hasAssociatedLesson(plan: PlanInterface): boolean;
13
+ isExternalVenue(plan: PlanInterface): boolean;
14
+ getExternalRef(plan: PlanInterface): ExternalVenueRefInterface | null;
15
+ getVenueId(plan: PlanInterface): string | null;
16
+ }
17
+ //# sourceMappingURL=LessonsContentProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LessonsContentProvider.d.ts","sourceRoot":"","sources":["../../src/contentProviders/LessonsContentProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,+BAA+B,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAC3G,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,qBAAa,sBAAuB,YAAW,wBAAwB;IACrE,QAAQ,CAAC,UAAU,aAAa;IAEhC,OAAO,CAAC,UAAU,CAAS;gBAEf,UAAU,GAAE,MAAiC;IAIzD,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO;IAW9D,YAAY,CAChB,IAAI,EAAE,aAAa,EACnB,SAAS,EAAE,iBAAiB,EAAE,GAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IA4C3C,mBAAmB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,+BAA+B,CAAC;IAclF,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAanF,mBAAmB,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAIjD,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAI7C,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,yBAAyB,GAAG,IAAI;IASrE,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI;CAO/C"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LessonsContentProvider = void 0;
4
+ const ApiHelper_1 = require("../ApiHelper");
5
+ class LessonsContentProvider {
6
+ providerId = "lessons";
7
+ lessonsUrl;
8
+ constructor(lessonsUrl = "https://lessons.church") {
9
+ this.lessonsUrl = lessonsUrl;
10
+ }
11
+ canHandle(plan, planItem) {
12
+ // Handles: action, addOn, lessonSection, and items with relatedId when plan has lesson
13
+ const lessonTypes = ["action", "addOn", "lessonSection"];
14
+ const hasLessonPlan = plan?.contentType === "venue" || plan?.contentType === "externalVenue";
15
+ if (lessonTypes.includes(planItem.itemType) && planItem.relatedId)
16
+ return true;
17
+ if (planItem.itemType === "item" && planItem.relatedId && hasLessonPlan)
18
+ return true;
19
+ return false;
20
+ }
21
+ async fetchContent(plan, planItems) {
22
+ const result = new Map();
23
+ // Group by type for efficient batching
24
+ const actions = planItems.filter(p => p.itemType === "action" && p.relatedId);
25
+ const addOns = planItems.filter(p => p.itemType === "addOn" && p.relatedId);
26
+ const sections = planItems.filter(p => (p.itemType === "lessonSection" || p.itemType === "item") && p.relatedId);
27
+ const externalRef = this.getExternalRef(plan);
28
+ // Build embed URLs for each item
29
+ for (const item of actions) {
30
+ result.set(item.id, {
31
+ provider: this.providerId,
32
+ embedUrl: externalRef
33
+ ? `${this.lessonsUrl}/embed/external/${externalRef.externalProviderId}/action/${item.relatedId}`
34
+ : `${this.lessonsUrl}/embed/action/${item.relatedId}`
35
+ });
36
+ }
37
+ for (const item of addOns) {
38
+ result.set(item.id, {
39
+ provider: this.providerId,
40
+ embedUrl: externalRef
41
+ ? `${this.lessonsUrl}/embed/external/${externalRef.externalProviderId}/addon/${item.relatedId}`
42
+ : `${this.lessonsUrl}/embed/addon/${item.relatedId}`
43
+ });
44
+ }
45
+ for (const item of sections) {
46
+ result.set(item.id, {
47
+ provider: this.providerId,
48
+ embedUrl: externalRef
49
+ ? `${this.lessonsUrl}/embed/external/${externalRef.externalProviderId}/section/${item.relatedId}`
50
+ : `${this.lessonsUrl}/embed/section/${item.relatedId}`
51
+ });
52
+ }
53
+ return result;
54
+ }
55
+ // Fetch venue plan items (for preview mode)
56
+ async fetchVenuePlanItems(plan) {
57
+ if (!this.hasAssociatedLesson(plan))
58
+ return { items: [] };
59
+ const externalRef = this.getExternalRef(plan);
60
+ if (externalRef) {
61
+ return await ApiHelper_1.ApiHelper.getAnonymous(`/externalProviders/${externalRef.externalProviderId}/venue/${externalRef.venueId}/planItems`, "LessonsApi");
62
+ }
63
+ return await ApiHelper_1.ApiHelper.getAnonymous(`/venues/public/planItems/${plan.contentId}`, "LessonsApi");
64
+ }
65
+ // Fetch venue actions (for expanding sections)
66
+ async fetchVenueActions(plan) {
67
+ if (!this.hasAssociatedLesson(plan))
68
+ return { sections: [] };
69
+ const externalRef = this.getExternalRef(plan);
70
+ if (externalRef) {
71
+ return await ApiHelper_1.ApiHelper.getAnonymous(`/externalProviders/${externalRef.externalProviderId}/venue/${externalRef.venueId}/actions`, "LessonsApi");
72
+ }
73
+ return await ApiHelper_1.ApiHelper.getAnonymous(`/venues/public/actions/${plan.contentId}`, "LessonsApi");
74
+ }
75
+ hasAssociatedLesson(plan) {
76
+ return (plan?.contentType === "venue" || plan?.contentType === "externalVenue") && !!plan?.contentId;
77
+ }
78
+ isExternalVenue(plan) {
79
+ return plan?.contentType === "externalVenue";
80
+ }
81
+ getExternalRef(plan) {
82
+ if (!this.isExternalVenue(plan) || !plan?.contentId)
83
+ return null;
84
+ try {
85
+ return JSON.parse(plan.contentId);
86
+ }
87
+ catch {
88
+ return null;
89
+ }
90
+ }
91
+ getVenueId(plan) {
92
+ if (!this.hasAssociatedLesson(plan))
93
+ return null;
94
+ if (this.isExternalVenue(plan)) {
95
+ return this.getExternalRef(plan)?.venueId || null;
96
+ }
97
+ return plan.contentId || null;
98
+ }
99
+ }
100
+ exports.LessonsContentProvider = LessonsContentProvider;
101
+ //# sourceMappingURL=LessonsContentProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LessonsContentProvider.js","sourceRoot":"","sources":["../../src/contentProviders/LessonsContentProvider.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AAUzC,MAAa,sBAAsB;IACxB,UAAU,GAAG,SAAS,CAAC;IAExB,UAAU,CAAS;IAE3B,YAAY,aAAqB,wBAAwB;QACvD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,IAAmB,EAAE,QAA2B;QACxD,uFAAuF;QACvF,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;QACzD,MAAM,aAAa,GAAG,IAAI,EAAE,WAAW,KAAK,OAAO,IAAI,IAAI,EAAE,WAAW,KAAK,eAAe,CAAC;QAE7F,IAAI,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QAC/E,IAAI,QAAQ,CAAC,QAAQ,KAAK,MAAM,IAAI,QAAQ,CAAC,SAAS,IAAI,aAAa;YAAE,OAAO,IAAI,CAAC;QAErF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,IAAmB,EACnB,SAA8B;QAE9B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoC,CAAC;QAE3D,uCAAuC;QACvC,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC;QAC9E,MAAM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AC;QACD,OAAO,MAAM,qBAAS,CAAC,YAAY,CAAC,0BAA0B,IAAI,CAAC,SAAS,EAAE,EAAE,YAAY,CAAC,CAAC;IAChG,CAAC;IAED,mBAAmB,CAAC,IAAmB;QACrC,OAAO,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,IAAI,IAAI,EAAE,WAAW,KAAK,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC;IACvG,CAAC;IAED,eAAe,CAAC,IAAmB;QACjC,OAAO,IAAI,EAAE,WAAW,KAAK,eAAe,CAAC;IAC/C,CAAC;IAED,cAAc,CAAC,IAAmB;QAChC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS;YAAE,OAAO,IAAI,CAAC;QACjE,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,UAAU,CAAC,IAAmB;QAC5B,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QACjD,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,OAAO,IAAI,IAAI,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC;IAChC,CAAC;CACF;AAtHD,wDAsHC"}
@@ -0,0 +1,3 @@
1
+ export type { ContentProviderInterface } from "./ContentProvider";
2
+ export { LessonsContentProvider } from "./LessonsContentProvider";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contentProviders/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LessonsContentProvider = void 0;
4
+ var LessonsContentProvider_1 = require("./LessonsContentProvider");
5
+ Object.defineProperty(exports, "LessonsContentProvider", { enumerable: true, get: function () { return LessonsContentProvider_1.LessonsContentProvider; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contentProviders/index.ts"],"names":[],"mappings":";;;AACA,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA"}
package/dist/index.d.ts CHANGED
@@ -12,4 +12,6 @@ export { FileHelper } from "./FileHelper";
12
12
  export { PersonHelper } from "./PersonHelper";
13
13
  export { UserHelper } from "./UserHelper";
14
14
  export { UniqueIdHelper } from "./UniqueIdHelper";
15
+ export { PlanHelper } from "./PlanHelper";
16
+ export * from "./contentProviders";
15
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,cAAc,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.UniqueIdHelper = exports.UserHelper = exports.PersonHelper = exports.FileHelper = exports.EventHelper = exports.ErrorHelper = exports.DonationHelper = exports.DateHelper = exports.CurrencyHelper = exports.CommonEnvironmentHelper = exports.ArrayHelper = exports.AppearanceHelper = exports.ApiHelper = void 0;
17
+ exports.PlanHelper = exports.UniqueIdHelper = exports.UserHelper = exports.PersonHelper = exports.FileHelper = exports.EventHelper = exports.ErrorHelper = exports.DonationHelper = exports.DateHelper = exports.CurrencyHelper = exports.CommonEnvironmentHelper = exports.ArrayHelper = exports.AppearanceHelper = exports.ApiHelper = void 0;
18
18
  __exportStar(require("./interfaces"), exports);
19
19
  var ApiHelper_1 = require("./ApiHelper");
20
20
  Object.defineProperty(exports, "ApiHelper", { enumerable: true, get: function () { return ApiHelper_1.ApiHelper; } });
@@ -42,4 +42,7 @@ var UserHelper_1 = require("./UserHelper");
42
42
  Object.defineProperty(exports, "UserHelper", { enumerable: true, get: function () { return UserHelper_1.UserHelper; } });
43
43
  var UniqueIdHelper_1 = require("./UniqueIdHelper");
44
44
  Object.defineProperty(exports, "UniqueIdHelper", { enumerable: true, get: function () { return UniqueIdHelper_1.UniqueIdHelper; } });
45
+ var PlanHelper_1 = require("./PlanHelper");
46
+ Object.defineProperty(exports, "PlanHelper", { enumerable: true, get: function () { return PlanHelper_1.PlanHelper; } });
47
+ __exportStar(require("./contentProviders"), exports);
45
48
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAChC,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAChC,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,qDAAmC"}
@@ -55,6 +55,8 @@ export interface PlanInterface {
55
55
  ministryId?: string;
56
56
  serviceDate?: Date;
57
57
  notes?: string;
58
+ contentType?: string;
59
+ contentId?: string;
58
60
  }
59
61
  export interface PositionInterface {
60
62
  id?: string;
@@ -90,4 +92,39 @@ export interface BlockoutDateInterface {
90
92
  startDate?: Date;
91
93
  endDate?: Date;
92
94
  }
95
+ export interface ExternalVenueRefInterface {
96
+ externalProviderId: string;
97
+ programId: string;
98
+ studyId: string;
99
+ lessonId: string;
100
+ venueId: string;
101
+ }
102
+ export interface ContentFileInterface {
103
+ id?: string;
104
+ name?: string;
105
+ url?: string;
106
+ fileType?: string;
107
+ seconds?: number;
108
+ }
109
+ export interface PlanItemContentInterface {
110
+ provider: string;
111
+ embedUrl?: string;
112
+ html?: string;
113
+ files?: ContentFileInterface[];
114
+ metadata?: Record<string, any>;
115
+ }
116
+ export interface PlanItemInterface {
117
+ id?: string;
118
+ planId?: string;
119
+ parentId?: string;
120
+ sort?: number;
121
+ itemType?: string;
122
+ relatedId?: string;
123
+ label?: string;
124
+ description?: string;
125
+ seconds?: number;
126
+ link?: string;
127
+ children?: PlanItemInterface[];
128
+ content?: PlanItemContentInterface;
129
+ }
93
130
  //# sourceMappingURL=Doing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Doing.d.ts","sourceRoot":"","sources":["../../src/interfaces/Doing.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AACD,MAAM,WAAW,mBAAmB;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB;AACD,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAA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,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC"}
@@ -0,0 +1,47 @@
1
+ export interface LessonActionInterface {
2
+ id: string;
3
+ name: string;
4
+ actionType: string;
5
+ roleName?: string;
6
+ seconds?: number;
7
+ }
8
+ export interface LessonSectionInterface {
9
+ id: string;
10
+ name: string;
11
+ actions?: LessonActionInterface[];
12
+ }
13
+ export interface LessonVenueInterface {
14
+ id: string;
15
+ name: string;
16
+ sections?: LessonSectionInterface[];
17
+ }
18
+ export interface LessonInfoInterface {
19
+ id: string;
20
+ name: string;
21
+ venues?: LessonVenueInterface[];
22
+ }
23
+ export interface LessonStudyInterface {
24
+ id: string;
25
+ name: string;
26
+ lessons?: LessonInfoInterface[];
27
+ }
28
+ export interface LessonProgramInterface {
29
+ id: string;
30
+ name: string;
31
+ studies?: LessonStudyInterface[];
32
+ }
33
+ export interface LessonTreeInterface {
34
+ programs?: LessonProgramInterface[];
35
+ }
36
+ export interface LessonActionTreeInterface {
37
+ programs?: LessonProgramInterface[];
38
+ }
39
+ export interface VenueActionResponseInterface {
40
+ venueName?: string;
41
+ sections?: LessonSectionInterface[];
42
+ }
43
+ export interface VenuePlanItemsResponseInterface {
44
+ venueName?: string;
45
+ items?: import("./Doing").PlanItemInterface[];
46
+ }
47
+ //# sourceMappingURL=Lessons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Lessons.d.ts","sourceRoot":"","sources":["../../src/interfaces/Lessons.ts"],"names":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OAAO,SAAS,EAAE,iBAAiB,EAAE,CAAC;CAC/C"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Interfaces for Lessons API responses (tree structures)
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=Lessons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Lessons.js","sourceRoot":"","sources":["../../src/interfaces/Lessons.ts"],"names":[],"mappings":";AAAA,yDAAyD"}
@@ -6,6 +6,7 @@ export * from "./Attendance";
6
6
  export * from "./Content";
7
7
  export * from "./Doing";
8
8
  export * from "./Donation";
9
+ export * from "./Lessons";
9
10
  export * from "./Membership";
10
11
  export * from "./Messaging";
11
12
  export * from "./Reporting";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAG9B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAG9B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -23,6 +23,7 @@ __exportStar(require("./Attendance"), exports);
23
23
  __exportStar(require("./Content"), exports);
24
24
  __exportStar(require("./Doing"), exports);
25
25
  __exportStar(require("./Donation"), exports);
26
+ __exportStar(require("./Lessons"), exports);
26
27
  __exportStar(require("./Membership"), exports);
27
28
  __exportStar(require("./Messaging"), exports);
28
29
  __exportStar(require("./Reporting"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,yDAAuC;AACvC,gDAA8B;AAE9B,iBAAiB;AACjB,2CAAyB;AACzB,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB;AACxB,6CAA2B;AAC3B,+CAA6B;AAC7B,8CAA4B;AAC5B,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,yDAAuC;AACvC,gDAA8B;AAE9B,iBAAiB;AACjB,2CAAyB;AACzB,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB;AACxB,6CAA2B;AAC3B,4CAA0B;AAC1B,+CAA6B;AAC7B,8CAA4B;AAC5B,8CAA4B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@churchapps/helpers",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "Library of helper functions not specific to any one ChurchApps project or framework.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,109 @@
1
+ import type { PlanInterface, PlanItemInterface, PlanItemContentInterface } from "./interfaces";
2
+ import type { ContentProviderInterface } from "./contentProviders/ContentProvider";
3
+ import { LessonsContentProvider } from "./contentProviders/LessonsContentProvider";
4
+
5
+ export class PlanHelper {
6
+ private static providers: ContentProviderInterface[] = [
7
+ new LessonsContentProvider()
8
+ ];
9
+
10
+ // Register additional content providers
11
+ static registerProvider(provider: ContentProviderInterface): void {
12
+ // Avoid duplicates
13
+ if (!this.providers.find(p => p.providerId === provider.providerId)) {
14
+ this.providers.push(provider);
15
+ }
16
+ }
17
+
18
+ // Replace a provider (useful for configuring with different URLs)
19
+ static replaceProvider(provider: ContentProviderInterface): void {
20
+ const index = this.providers.findIndex(p => p.providerId === provider.providerId);
21
+ if (index >= 0) {
22
+ this.providers[index] = provider;
23
+ } else {
24
+ this.providers.push(provider);
25
+ }
26
+ }
27
+
28
+ // Main method: populate planItems with their content
29
+ static async populate(
30
+ plan: PlanInterface,
31
+ planItems: PlanItemInterface[]
32
+ ): Promise<PlanItemInterface[]> {
33
+ // Flatten hierarchy to get all items
34
+ const allItems = this.flattenItems(planItems);
35
+
36
+ // Group items by provider
37
+ const itemsByProvider = new Map<ContentProviderInterface, PlanItemInterface[]>();
38
+
39
+ for (const item of allItems) {
40
+ for (const provider of this.providers) {
41
+ if (provider.canHandle(plan, item)) {
42
+ const existing = itemsByProvider.get(provider) || [];
43
+ existing.push(item);
44
+ itemsByProvider.set(provider, existing);
45
+ break; // First matching provider wins
46
+ }
47
+ }
48
+ }
49
+
50
+ // Fetch content from each provider in parallel
51
+ const fetchPromises: Promise<void>[] = [];
52
+ const contentMap = new Map<string, PlanItemContentInterface>();
53
+
54
+ for (const [provider, items] of itemsByProvider) {
55
+ fetchPromises.push(
56
+ provider.fetchContent(plan, items).then(providerContent => {
57
+ for (const [itemId, content] of providerContent) {
58
+ contentMap.set(itemId, content);
59
+ }
60
+ })
61
+ );
62
+ }
63
+
64
+ await Promise.all(fetchPromises);
65
+
66
+ // Attach content to items (mutates in place for efficiency)
67
+ this.attachContent(planItems, contentMap);
68
+
69
+ return planItems;
70
+ }
71
+
72
+ // Flatten nested planItems for processing
73
+ private static flattenItems(items: PlanItemInterface[]): PlanItemInterface[] {
74
+ const result: PlanItemInterface[] = [];
75
+
76
+ const collect = (itemList: PlanItemInterface[]) => {
77
+ for (const item of itemList) {
78
+ result.push(item);
79
+ if (item.children?.length) {
80
+ collect(item.children);
81
+ }
82
+ }
83
+ };
84
+
85
+ collect(items);
86
+ return result;
87
+ }
88
+
89
+ // Attach content to items recursively
90
+ private static attachContent(
91
+ items: PlanItemInterface[],
92
+ contentMap: Map<string, PlanItemContentInterface>
93
+ ): void {
94
+ for (const item of items) {
95
+ const content = contentMap.get(item.id);
96
+ if (content) {
97
+ item.content = content;
98
+ }
99
+ if (item.children?.length) {
100
+ this.attachContent(item.children, contentMap);
101
+ }
102
+ }
103
+ }
104
+
105
+ // Convenience: Get the lessons provider for direct lesson operations
106
+ static getLessonsProvider(): LessonsContentProvider {
107
+ return this.providers.find(p => p.providerId === "lessons") as LessonsContentProvider;
108
+ }
109
+ }
@@ -0,0 +1,15 @@
1
+ import type { PlanInterface, PlanItemInterface, PlanItemContentInterface } from "../interfaces";
2
+
3
+ export interface ContentProviderInterface {
4
+ // Unique identifier for this provider
5
+ readonly providerId: string;
6
+
7
+ // Check if this provider handles the given plan/planItem
8
+ canHandle(plan: PlanInterface, planItem: PlanItemInterface): boolean;
9
+
10
+ // Fetch content for multiple planItems (batch for efficiency)
11
+ fetchContent(
12
+ plan: PlanInterface,
13
+ planItems: PlanItemInterface[]
14
+ ): Promise<Map<string, PlanItemContentInterface>>;
15
+ }
@@ -0,0 +1,129 @@
1
+ import { ApiHelper } from "../ApiHelper";
2
+ import type {
3
+ PlanInterface,
4
+ PlanItemInterface,
5
+ PlanItemContentInterface,
6
+ ExternalVenueRefInterface
7
+ } from "../interfaces";
8
+ import type { VenuePlanItemsResponseInterface, VenueActionResponseInterface } from "../interfaces/Lessons";
9
+ import type { ContentProviderInterface } from "./ContentProvider";
10
+
11
+ export class LessonsContentProvider implements ContentProviderInterface {
12
+ readonly providerId = "lessons";
13
+
14
+ private lessonsUrl: string;
15
+
16
+ constructor(lessonsUrl: string = "https://lessons.church") {
17
+ this.lessonsUrl = lessonsUrl;
18
+ }
19
+
20
+ canHandle(plan: PlanInterface, planItem: PlanItemInterface): boolean {
21
+ // Handles: action, addOn, lessonSection, and items with relatedId when plan has lesson
22
+ const lessonTypes = ["action", "addOn", "lessonSection"];
23
+ const hasLessonPlan = plan?.contentType === "venue" || plan?.contentType === "externalVenue";
24
+
25
+ if (lessonTypes.includes(planItem.itemType) && planItem.relatedId) return true;
26
+ if (planItem.itemType === "item" && planItem.relatedId && hasLessonPlan) return true;
27
+
28
+ return false;
29
+ }
30
+
31
+ async fetchContent(
32
+ plan: PlanInterface,
33
+ planItems: PlanItemInterface[]
34
+ ): Promise<Map<string, PlanItemContentInterface>> {
35
+ const result = new Map<string, PlanItemContentInterface>();
36
+
37
+ // Group by type for efficient batching
38
+ const actions = planItems.filter(p => p.itemType === "action" && p.relatedId);
39
+ const addOns = planItems.filter(p => p.itemType === "addOn" && p.relatedId);
40
+ const sections = planItems.filter(p =>
41
+ (p.itemType === "lessonSection" || p.itemType === "item") && p.relatedId
42
+ );
43
+
44
+ const externalRef = this.getExternalRef(plan);
45
+
46
+ // Build embed URLs for each item
47
+ for (const item of actions) {
48
+ result.set(item.id, {
49
+ provider: this.providerId,
50
+ embedUrl: externalRef
51
+ ? `${this.lessonsUrl}/embed/external/${externalRef.externalProviderId}/action/${item.relatedId}`
52
+ : `${this.lessonsUrl}/embed/action/${item.relatedId}`
53
+ });
54
+ }
55
+
56
+ for (const item of addOns) {
57
+ result.set(item.id, {
58
+ provider: this.providerId,
59
+ embedUrl: externalRef
60
+ ? `${this.lessonsUrl}/embed/external/${externalRef.externalProviderId}/addon/${item.relatedId}`
61
+ : `${this.lessonsUrl}/embed/addon/${item.relatedId}`
62
+ });
63
+ }
64
+
65
+ for (const item of sections) {
66
+ result.set(item.id, {
67
+ provider: this.providerId,
68
+ embedUrl: externalRef
69
+ ? `${this.lessonsUrl}/embed/external/${externalRef.externalProviderId}/section/${item.relatedId}`
70
+ : `${this.lessonsUrl}/embed/section/${item.relatedId}`
71
+ });
72
+ }
73
+
74
+ return result;
75
+ }
76
+
77
+ // Fetch venue plan items (for preview mode)
78
+ async fetchVenuePlanItems(plan: PlanInterface): Promise<VenuePlanItemsResponseInterface> {
79
+ if (!this.hasAssociatedLesson(plan)) return { items: [] };
80
+
81
+ const externalRef = this.getExternalRef(plan);
82
+ if (externalRef) {
83
+ return await ApiHelper.getAnonymous(
84
+ `/externalProviders/${externalRef.externalProviderId}/venue/${externalRef.venueId}/planItems`,
85
+ "LessonsApi"
86
+ );
87
+ }
88
+ return await ApiHelper.getAnonymous(`/venues/public/planItems/${plan.contentId}`, "LessonsApi");
89
+ }
90
+
91
+ // Fetch venue actions (for expanding sections)
92
+ async fetchVenueActions(plan: PlanInterface): Promise<VenueActionResponseInterface> {
93
+ if (!this.hasAssociatedLesson(plan)) return { sections: [] };
94
+
95
+ const externalRef = this.getExternalRef(plan);
96
+ if (externalRef) {
97
+ return await ApiHelper.getAnonymous(
98
+ `/externalProviders/${externalRef.externalProviderId}/venue/${externalRef.venueId}/actions`,
99
+ "LessonsApi"
100
+ );
101
+ }
102
+ return await ApiHelper.getAnonymous(`/venues/public/actions/${plan.contentId}`, "LessonsApi");
103
+ }
104
+
105
+ hasAssociatedLesson(plan: PlanInterface): boolean {
106
+ return (plan?.contentType === "venue" || plan?.contentType === "externalVenue") && !!plan?.contentId;
107
+ }
108
+
109
+ isExternalVenue(plan: PlanInterface): boolean {
110
+ return plan?.contentType === "externalVenue";
111
+ }
112
+
113
+ getExternalRef(plan: PlanInterface): ExternalVenueRefInterface | null {
114
+ if (!this.isExternalVenue(plan) || !plan?.contentId) return null;
115
+ try {
116
+ return JSON.parse(plan.contentId);
117
+ } catch {
118
+ return null;
119
+ }
120
+ }
121
+
122
+ getVenueId(plan: PlanInterface): string | null {
123
+ if (!this.hasAssociatedLesson(plan)) return null;
124
+ if (this.isExternalVenue(plan)) {
125
+ return this.getExternalRef(plan)?.venueId || null;
126
+ }
127
+ return plan.contentId || null;
128
+ }
129
+ }
@@ -0,0 +1,2 @@
1
+ export type { ContentProviderInterface } from "./ContentProvider";
2
+ export { LessonsContentProvider } from "./LessonsContentProvider";
package/src/index.ts CHANGED
@@ -12,4 +12,6 @@ export { FileHelper } from "./FileHelper";
12
12
  export { PersonHelper } from "./PersonHelper";
13
13
  export { UserHelper } from "./UserHelper";
14
14
  export { UniqueIdHelper } from "./UniqueIdHelper";
15
+ export { PlanHelper } from "./PlanHelper";
16
+ export * from "./contentProviders";
15
17
 
@@ -56,6 +56,8 @@ export interface PlanInterface {
56
56
  ministryId?: string;
57
57
  serviceDate?: Date;
58
58
  notes?: string;
59
+ contentType?: string;
60
+ contentId?: string;
59
61
  }
60
62
  export interface PositionInterface {
61
63
  id?: string;
@@ -91,3 +93,42 @@ export interface BlockoutDateInterface {
91
93
  startDate?: Date;
92
94
  endDate?: Date;
93
95
  }
96
+
97
+ export interface ExternalVenueRefInterface {
98
+ externalProviderId: string;
99
+ programId: string;
100
+ studyId: string;
101
+ lessonId: string;
102
+ venueId: string;
103
+ }
104
+
105
+ export interface ContentFileInterface {
106
+ id?: string;
107
+ name?: string;
108
+ url?: string;
109
+ fileType?: string; // "image", "video", "audio", "document"
110
+ seconds?: number;
111
+ }
112
+
113
+ export interface PlanItemContentInterface {
114
+ provider: string; // "lessons", "songs", "media", "church"
115
+ embedUrl?: string; // URL for iframe embed
116
+ html?: string; // Raw HTML content
117
+ files?: ContentFileInterface[];
118
+ metadata?: Record<string, any>; // Provider-specific data
119
+ }
120
+
121
+ export interface PlanItemInterface {
122
+ id?: string;
123
+ planId?: string;
124
+ parentId?: string;
125
+ sort?: number;
126
+ itemType?: string; // "header", "song", "action", "addOn", "lessonSection", "item"
127
+ relatedId?: string;
128
+ label?: string;
129
+ description?: string;
130
+ seconds?: number;
131
+ link?: string;
132
+ children?: PlanItemInterface[];
133
+ content?: PlanItemContentInterface; // Populated by PlanHelper
134
+ }
@@ -0,0 +1,61 @@
1
+ // Interfaces for Lessons API responses (tree structures)
2
+
3
+ export interface LessonActionInterface {
4
+ id: string;
5
+ name: string;
6
+ actionType: string;
7
+ roleName?: string;
8
+ seconds?: number;
9
+ }
10
+
11
+ export interface LessonSectionInterface {
12
+ id: string;
13
+ name: string;
14
+ actions?: LessonActionInterface[];
15
+ }
16
+
17
+ export interface LessonVenueInterface {
18
+ id: string;
19
+ name: string;
20
+ sections?: LessonSectionInterface[];
21
+ }
22
+
23
+ export interface LessonInfoInterface {
24
+ id: string;
25
+ name: string;
26
+ venues?: LessonVenueInterface[];
27
+ }
28
+
29
+ export interface LessonStudyInterface {
30
+ id: string;
31
+ name: string;
32
+ lessons?: LessonInfoInterface[];
33
+ }
34
+
35
+ export interface LessonProgramInterface {
36
+ id: string;
37
+ name: string;
38
+ studies?: LessonStudyInterface[];
39
+ }
40
+
41
+ // Response from /lessons/public/tree
42
+ export interface LessonTreeInterface {
43
+ programs?: LessonProgramInterface[];
44
+ }
45
+
46
+ // Response from /lessons/public/actionTree (same structure as LessonTreeInterface)
47
+ export interface LessonActionTreeInterface {
48
+ programs?: LessonProgramInterface[];
49
+ }
50
+
51
+ // Response from /venues/public/actions/{id}
52
+ export interface VenueActionResponseInterface {
53
+ venueName?: string;
54
+ sections?: LessonSectionInterface[];
55
+ }
56
+
57
+ // Response from /venues/public/planItems/{id}
58
+ export interface VenuePlanItemsResponseInterface {
59
+ venueName?: string;
60
+ items?: import("./Doing").PlanItemInterface[];
61
+ }
@@ -8,6 +8,7 @@ export * from "./Attendance";
8
8
  export * from "./Content";
9
9
  export * from "./Doing";
10
10
  export * from "./Donation";
11
+ export * from "./Lessons";
11
12
  export * from "./Membership";
12
13
  export * from "./Messaging";
13
14
  export * from "./Reporting";