@churchapps/helpers 1.0.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.
@@ -0,0 +1,108 @@
1
+ import { format as dateFormat } from "date-fns"
2
+
3
+ export class DateHelper {
4
+
5
+ //Fixes timezone issues when you just need the date.
6
+ static toDate(input: any) {
7
+ return new Date(Date.parse(input.toString().replace("Z", "")));
8
+ }
9
+
10
+ static toDateTime(input: any) {
11
+ return new Date(Date.parse(input.toString()));
12
+ }
13
+
14
+ //obsolete. Do not use
15
+ static convertToDate(input: any) {
16
+ return this.toDateTime(input);
17
+ }
18
+
19
+ static addDays(date: Date, days: number) {
20
+ date.setDate(date.getDate() + days);
21
+ return date;
22
+ }
23
+
24
+ static prettyDate(date: Date) {
25
+ if (date === undefined || date === null) return "";
26
+ return this.formatDateTime(date, "MMM d, yyyy");
27
+ }
28
+
29
+ static prettyDateTime(date: Date) {
30
+ if (date === undefined || date === null) return "";
31
+ return this.formatDateTime(date, "MMM d, yyyy h:mm a");
32
+ }
33
+
34
+ static prettyTime(date: Date) {
35
+ if (date === undefined || date === null) return "";
36
+ return this.formatDateTime(date, "h:mm a");
37
+ }
38
+
39
+ static getLastSunday() {
40
+ let result = new Date();
41
+ while (result.getDay() !== 0) result.setDate(result.getDate() - 1);
42
+ return result;
43
+ }
44
+
45
+ static getWeekSunday(year: number, week: number) {
46
+ let result = new Date(year, 0, 1);
47
+ while (result.getDay() !== 0) result.setDate(result.getDate() + 1);
48
+ result.setDate(result.getDate() + ((week - 1) * 7));
49
+ return result;
50
+ }
51
+
52
+ static formatHtml5Date(date: Date): string {
53
+ let result = "";
54
+ if (date !== undefined && date !== null) {
55
+ try {
56
+ result = new Date(date).toISOString().split("T")[0];
57
+ } catch { }
58
+ }
59
+ return result;
60
+ }
61
+
62
+ static formatHtml5Time(time: Date): string {
63
+ let h = time.getHours();
64
+ let m = time.getMinutes();
65
+ let s = time.getSeconds();
66
+ return `${h < 10 ? ("0" + h) : h}:${m < 10 ? ("0" + m) : m}:${s < 10 ? ("0" + s) : s}`;
67
+ }
68
+
69
+ static formatHtml5DateTime(date: Date): string {
70
+ if (date === undefined || date === null) return "";
71
+ else {
72
+ return this.formatDateTime(date, "yyyy-MM-dd") + "T" + this.formatDateTime(date, "HH:mm");
73
+ }
74
+ }
75
+
76
+ static getDisplayDuration(d: Date): string {
77
+ let seconds = Math.round((new Date().getTime() - d.getTime()) / 1000);
78
+ if (seconds > 86400) {
79
+ let days = Math.floor(seconds / 86400);
80
+ return (days === 1) ? "1d" : days.toString() + "d";
81
+ }
82
+ else if (seconds > 3600) {
83
+ let hours = Math.floor(seconds / 3600);
84
+ return (hours === 1) ? "1h" : hours.toString() + "h";
85
+ }
86
+ else if (seconds > 60) {
87
+ let minutes = Math.floor(seconds / 60);
88
+ return (minutes === 1) ? "1m" : minutes.toString() + "m";
89
+ }
90
+ else return (seconds === 1) ? "1s" : Math.floor(seconds).toString() + "s";
91
+ }
92
+
93
+ static getShortDate(d: Date): string {
94
+ return (d.getMonth() + 1).toString() + "/" + (d.getDate()).toString() + "/" + d.getFullYear().toString();
95
+ }
96
+
97
+ static convertDatePickerFormat(d: Date): Date {
98
+ const date = this.formatHtml5Date(d).split("-");
99
+ if (date.length === 3) return new Date(`${date[1]}-${date[2]}-${date[0]}`);
100
+ return new Date();
101
+ }
102
+
103
+ private static formatDateTime(date: Date, format: string) {
104
+ try {
105
+ return dateFormat(date, format);
106
+ } catch { return ""; }
107
+ }
108
+ }
@@ -0,0 +1,26 @@
1
+ export class DonationHelper {
2
+
3
+ static getInterval(intervalName:string) {
4
+ let intervalCount = 1;
5
+ let intervalType = "month";
6
+ let parts = intervalName.split("_");
7
+ if (parts.length === 2) {
8
+ switch (parts[0])
9
+ {
10
+ case "two": intervalCount = 2; break;
11
+ case "three": intervalCount = 3; break;
12
+ }
13
+ intervalType = parts[1];
14
+ }
15
+ let result = { interval_count: intervalCount, interval: intervalType };
16
+ return result;
17
+ }
18
+
19
+ static getIntervalKeyName(intervalCount: number, intervalType: string) {
20
+ let firstPart = "one";
21
+ if (intervalCount === 2) firstPart = "two";
22
+ else if (intervalCount === 3) firstPart = "three";
23
+ return firstPart + "_" + intervalType;
24
+ }
25
+
26
+ }
@@ -0,0 +1,36 @@
1
+ import { ErrorLogInterface, ErrrorAppDataInterface } from "../interfaces/Error";
2
+ import { ApiHelper } from "./ApiHelper";
3
+
4
+
5
+ export class ErrorHelper {
6
+
7
+ static getAppData:() => { churchId: string, userId: string, originUrl: string, application: string};
8
+ static customErrorHandler:(errorLog:ErrorLogInterface) => void;
9
+
10
+ static init = (getAppData:() => ErrrorAppDataInterface, customErrorHandler:(errorLog:ErrorLogInterface) => void) => {
11
+ ErrorHelper.getAppData = getAppData;
12
+ ErrorHelper.customErrorHandler = customErrorHandler;
13
+ }
14
+
15
+ static logError = (errorType:string, message:string, details:string) => {
16
+ if (this.getAppData)
17
+ {
18
+ const data = this.getAppData();
19
+ const log:ErrorLogInterface = {
20
+ application: data.application,
21
+ errorTime: new Date(),
22
+ userId: data.userId,
23
+ churchId: data.churchId,
24
+ originUrl: data.originUrl,
25
+ errorType: errorType,
26
+ message: message,
27
+ details: details
28
+ }
29
+
30
+ if (log.errorType==="401" && log.message.indexOf("/users/login")>-1) return;
31
+ ApiHelper.postAnonymous("/errors", [log], "MembershipApi");
32
+ if (ErrorHelper.customErrorHandler) ErrorHelper.customErrorHandler(log);
33
+ }
34
+ }
35
+
36
+ }
@@ -0,0 +1,49 @@
1
+ import { EventInterface } from "../interfaces";
2
+ import { RRule, datetime } from "rrule";
3
+ import { ParsedOptions } from "rrule/dist/esm/types";
4
+
5
+ export class EventHelper {
6
+
7
+ static getRange = (event:EventInterface, startDate:Date, endDate:Date) => {
8
+ const start = new Date(event.start);
9
+ const rrule = EventHelper.getFullRRule(event);
10
+
11
+ const dates = rrule.between(startDate, endDate);
12
+
13
+ dates.forEach(d => {
14
+ d.setHours(start.getHours());
15
+ d.setMinutes(start.getMinutes());
16
+ d.setSeconds(start.getSeconds());
17
+ })
18
+ return dates;
19
+ }
20
+
21
+ static getFullRRule = (event:EventInterface) => {
22
+ let rrule = RRule.fromString(event.recurrenceRule);
23
+ rrule.options.dtstart = new Date(event.start);
24
+ return rrule;
25
+ }
26
+
27
+ static removeExcludeDates = (events:EventInterface[]) => {
28
+ for (let i=events.length-1; i>=0; i--) {
29
+ if (events[i].exceptionDates?.length>0)
30
+ {
31
+ const parsedDates = events[i].exceptionDates.map(d=>new Date(d).toISOString());
32
+ if (parsedDates.indexOf(events[i].start.toISOString())>-1) events.splice(i,1);
33
+ }
34
+ }
35
+ }
36
+
37
+ static getPartialRRuleString = (options:ParsedOptions) => {
38
+ const parts = new RRule(options).toString().split("RRULE:");
39
+ const result = parts.length===2 ? parts[1] : "";
40
+ return result;
41
+ }
42
+
43
+ static cleanRule = (options:ParsedOptions) => {
44
+ options.byhour = undefined;
45
+ options.byminute = undefined;
46
+ options.bysecond = undefined;
47
+ }
48
+
49
+ }
@@ -0,0 +1,31 @@
1
+ import axios from "axios";
2
+
3
+ export class FileHelper {
4
+
5
+ static postPresignedFile = (presigned: any, uploadedFile: File, progressCallback: (percent: number) => void) => {
6
+ const formData = new FormData();
7
+ formData.append("key", presigned.key);
8
+ formData.append("acl", "public-read");
9
+ formData.append("Content-Type", uploadedFile.type);
10
+ for (const property in presigned.fields) formData.append(property, presigned.fields[property]);
11
+ formData.append("file", uploadedFile);
12
+
13
+ const axiosConfig = {
14
+ headers: { "Content-Type": "multipart/form-data" },
15
+ onUploadProgress: (data: any) => {
16
+ progressCallback(Math.round((100 * data.loaded) / data.total));
17
+ }
18
+ };
19
+
20
+ return axios.post(presigned.url, formData, axiosConfig);
21
+ };
22
+
23
+ static dataURLtoBlob(dataurl: string) {
24
+ let arr = dataurl.split(","), mime = arr[0].match(/:(.*?);/)[1],
25
+ bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
26
+ while (n--) {
27
+ u8arr[n] = bstr.charCodeAt(n);
28
+ }
29
+ return new Blob([u8arr], { type: mime });
30
+ }
31
+ }
@@ -0,0 +1,60 @@
1
+ import { PersonInterface, ContactInfoInterface } from "./interfaces";
2
+ import { CommonEnvironmentHelper } from "./CommonEnvironmentHelper";
3
+
4
+ export class PersonHelper {
5
+
6
+ static getPhotoUrl(person: PersonInterface) {
7
+ if (!person?.photo) return "/images/sample-profile.png"
8
+ else return person?.photo?.startsWith("data:image/png;base64,") ? person.photo : CommonEnvironmentHelper.ContentRoot + person.photo;
9
+ }
10
+
11
+ static getAge(birthdate: Date): string {
12
+ if (birthdate !== undefined && birthdate !== null) {
13
+ let ageDifMs = Date.now() - new Date(birthdate).getTime();
14
+ let ageDate = new Date(ageDifMs);
15
+ let years = Math.abs(ageDate.getUTCFullYear() - 1970);
16
+ return years + " years";
17
+ }
18
+ else return "";
19
+ }
20
+
21
+ static getDisplayName(firstName: string, lastName: string, nickName: string): string {
22
+ if (nickName !== undefined && nickName !== null && nickName.length > 0) return firstName + ' "' + nickName + '" ' + lastName;
23
+ else return firstName + " " + lastName;
24
+ }
25
+
26
+ public static compareAddress(address1: ContactInfoInterface, address2: ContactInfoInterface): boolean {
27
+ const displayAddress1: string = this.addressToString(address1).trim();
28
+ const displayAddress2: string = this.addressToString(address2).trim();
29
+
30
+ if (displayAddress1 !== displayAddress2) {
31
+ return true
32
+ }
33
+ return false
34
+ }
35
+
36
+ public static addressToString(address: ContactInfoInterface): string {
37
+ return `${address.address1 || ""} ${address.address2 || ""} ${address.city || ""}${(address.city && address.state) ? "," : ""} ${address.state || ""} ${address.zip || ""}`
38
+ }
39
+
40
+ public static changeOnlyAddress(contactInfo1: ContactInfoInterface, contactInfo2: ContactInfoInterface): ContactInfoInterface {
41
+ const updatedAddress: ContactInfoInterface = {
42
+ ...contactInfo1,
43
+ address1: contactInfo2.address1,
44
+ address2: contactInfo2.address2,
45
+ city: contactInfo2.city,
46
+ state: contactInfo2.state,
47
+ zip: contactInfo2.zip
48
+ }
49
+
50
+ return updatedAddress
51
+ }
52
+
53
+ public static checkAddressAvailabilty(person: PersonInterface): boolean {
54
+ const addressString: string = this.addressToString(person.contactInfo).trim();
55
+ if (addressString !== "") {
56
+ return true;
57
+ }
58
+ return false;
59
+ }
60
+ }
@@ -0,0 +1,36 @@
1
+ export class UniqueIdHelper {
2
+
3
+ static chars = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
4
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
5
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
6
+ "-", "_"];
7
+
8
+ static alphanumericChars = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
9
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
10
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
11
+
12
+ public static isMissing(obj: any) {
13
+ if (obj === undefined || obj === null) return true;
14
+ else if (obj.toString() === "") return true;
15
+ else return false;
16
+ }
17
+
18
+ public static shortId() {
19
+ return this.generate(UniqueIdHelper.chars, 11);
20
+ }
21
+
22
+ public static generateAlphanumeric() {
23
+ return this.generate(UniqueIdHelper.alphanumericChars, 11);
24
+ }
25
+
26
+ public static generate(charList: string[], length: number) {
27
+ let result = "";
28
+ for (let i = 0; i < length; i++) {
29
+ const idx = Math.floor(Math.random() * charList.length);
30
+ const c = charList[idx];
31
+ result += c;
32
+ }
33
+ return result;
34
+ }
35
+
36
+ }
@@ -0,0 +1,59 @@
1
+ import { ApiHelper } from "./ApiHelper"
2
+ import { UserInterface, UserContextInterface, IPermission, PersonInterface, LoginUserChurchInterface } from "./interfaces";
3
+
4
+ export class UserHelper {
5
+ static currentUserChurch: LoginUserChurchInterface;
6
+ static userChurches: LoginUserChurchInterface[];
7
+ static user: UserInterface;
8
+ static churchChanged: boolean = false;
9
+ static person: PersonInterface;
10
+
11
+ static selectChurch = async (context?: UserContextInterface, churchId?: string, keyName?: string) => {
12
+ let userChurch = null;
13
+
14
+ if (churchId) {
15
+ UserHelper.userChurches.forEach(uc => {
16
+ if (uc.church.id === churchId) userChurch = uc;
17
+ });
18
+ }
19
+ else if (keyName) UserHelper.userChurches.forEach(uc => { if (uc.church.subDomain === keyName) userChurch = uc; });
20
+ else userChurch = UserHelper.userChurches[0];
21
+ if (!userChurch) return;
22
+ else {
23
+ UserHelper.currentUserChurch = userChurch;
24
+ UserHelper.setupApiHelper(UserHelper.currentUserChurch);
25
+ // TODO - remove context code from here and perform the logic in the component itself.
26
+ if (context) {
27
+ if (context.userChurch !== null) UserHelper.churchChanged = true;
28
+ context.setUserChurch(UserHelper.currentUserChurch);
29
+ }
30
+ }
31
+ }
32
+
33
+ static setupApiHelper(userChurch: LoginUserChurchInterface) {
34
+ ApiHelper.setDefaultPermissions(userChurch.jwt);
35
+ userChurch.apis.forEach(api => { ApiHelper.setPermissions(api.keyName, api.jwt, api.permissions); });
36
+ }
37
+
38
+ static setupApiHelperNoChurch(user: LoginUserChurchInterface) {
39
+ ApiHelper.setDefaultPermissions(user.jwt);
40
+ }
41
+
42
+ static checkAccess({ api, contentType, action }: IPermission): boolean {
43
+ const permissions = ApiHelper.getConfig(api).permisssions;
44
+
45
+ let result = false;
46
+ if (permissions !== undefined) {
47
+ permissions.forEach(element => {
48
+ if (element.contentType === contentType && element.action === action) result = true;
49
+ });
50
+ }
51
+ return result;
52
+ }
53
+
54
+ static createAppUrl(appUrl: string, returnUrl: string) {
55
+ const jwt = ApiHelper.getConfig("MembershipApi").jwt;
56
+
57
+ return `${appUrl}/login/?jwt=${jwt}&returnUrl=${returnUrl}`;
58
+ }
59
+ }
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+
2
+ export { ApiHelper } from "./ApiHelper";
3
+ export { AppearanceHelper } from "./AppearanceHelper";
4
+ export { ArrayHelper } from "./ArrayHelper";
5
+ export { CurrencyHelper } from "./CurrencyHelper"
6
+ export { DateHelper } from "./DateHelper";
7
+ export { FileHelper } from "./FileHelper";
8
+ export { PersonHelper } from "./PersonHelper"
9
+ export { UserHelper } from "./UserHelper";
10
+ export { UniqueIdHelper } from "./UniqueIdHelper";
11
+ export { DonationHelper } from "./DonationHelper";
@@ -0,0 +1,24 @@
1
+ import { PersonInterface } from "./Membership";
2
+
3
+ export interface ApiInterface { name: string, keyName?: string, permissions: RolePermissionInterface[], jwt: string }
4
+ export interface ChurchInterface { id?: string, name?: string, registrationDate?: Date, address1?: string, address2?: string, city?: string, state?: string, zip?: string, country?: string, subDomain?: string, settings?: GenericSettingInterface[], archivedDate?: Date }
5
+ export interface DomainInterface { id?: string, domainName?: string }
6
+ export interface RegisterChurchRequestInterface extends ChurchInterface { appName?: string }
7
+ export interface LoadCreateUserRequestInterface { userEmail: string, fromEmail?: string, subject?: string, body?: string, firstName: string, lastName: string }
8
+ export interface LoginResponseInterface { user: UserInterface, userChurches: LoginUserChurchInterface[], errors: string[] }
9
+ export interface LoginUserChurchInterface { person: PersonInterface, church: ChurchInterface, apis: ApiInterface[], jwt: string, groups: { id: string, name: string, leader:boolean }[] }
10
+
11
+ export interface PermissionInterface { apiName?: string, section?: string, action?: string, displaySection?: string, displayAction?: string }
12
+ export interface RegisterUserInterface { firstName?: string, lastName: string, email?: string, appName: string, appUrl: string }
13
+ export interface RoleInterface { id?: string, churchId?: string, name?: string }
14
+ export interface RolePermissionInterface { id?: string, churchId?: string, roleId?: string, apiName?: string, contentType?: string, contentId?: string, action?: string }
15
+ export interface RoleMemberInterface { id?: string, churchId?: string, roleId?: string, userId?: string, user?: UserInterface, personId?: string }
16
+ export interface ResetPasswordRequestInterface { userEmail: string }
17
+ export interface ResetPasswordResponseInterface { emailed: boolean }
18
+ export interface UserInterface { id?: string, email?: string, authGuid?: string, firstName?: string, lastName?: string, registrationDate?: Date, lastLogin?: Date, password?: string, jwt?: string }
19
+ export interface GenericSettingInterface { id?: string, churchId?: string, keyName?: string, value?: string, public?: number }
20
+ export interface UserChurchInterface { id?: string, userId?: string, churchId?: string, personId?: string }
21
+
22
+ export interface ApiConfig { keyName: string, url: string, jwt: string, permisssions: RolePermissionInterface[] }
23
+ export type ApiListType = "MembershipApi" | "AttendanceApi" | "GivingApi" | "DoingApi" | "MessagingApi" | "LessonsApi" | "ReportingApi" | "ContentApi";
24
+ export interface IPermission { api: string, contentType: string, action: string }
@@ -0,0 +1,8 @@
1
+ import { CampusInterface, ServiceInterface, ServiceTimeInterface, PersonInterface } from "."
2
+
3
+ export interface AttendanceInterface { campus: CampusInterface, service: ServiceInterface, serviceTime: ServiceTimeInterface, groupId: string }
4
+ export interface AttendanceRecordInterface { serviceTime: ServiceTimeInterface, service: ServiceInterface, campus: CampusInterface, week: number, count: number, visitDate: Date, groupId: string }
5
+ export interface VisitInterface { id?: string, personId?: string, serviceId?: string, groupId?: string, visitDate?: Date, visitSessions?: VisitSessionInterface[], person?: PersonInterface }
6
+ export interface VisitSessionInterface { id?: string, visitId?: string, sessionId?: string, visit?: VisitInterface, session?: SessionInterface }
7
+ export interface SessionInterface { id?: string, groupId: string, serviceTimeId: string, sessionDate?: Date, displayName: string }
8
+ export interface SettingInterface { id?: string, keyName?: string, value?: string }
@@ -0,0 +1,10 @@
1
+ export interface LinkInterface { id?: string; churchId?: string; url?: string; text?: string; sort?: number; linkType: string; linkData: string; icon: string; category: string; parentId?: string; children?: any }
2
+ export interface SermonInterface { id?: string, churchId?: string, playlistId?: string, videoType?: string, videoData?: string, videoUrl?: string, title?: string, description?: string, publishDate?: Date, thumbnail?: string, duration?: number, permanentUrl?: boolean }
3
+ export interface PlaylistInterface { id?: string, churchId?: string, title?: string, description?: string, publishDate?: Date, thumbnail?: string }
4
+ export interface StreamingServiceInterface { id?: string, churchId?: string, serviceTime?: Date, earlyStart?: number, duration: number, chatBefore: number, chatAfter: number, provider: string, providerKey: string, videoUrl: string, timezoneOffset: number, recurring: boolean, label: string, sermonId?: string }
5
+ export interface EventInterface { id?: string; churchId?: string; groupId?: string; start?: Date; end?:Date, title?: string; description?: string; allDay?: boolean; visibility?:string; recurrenceRule?:string; exceptionDates?:Date[] }
6
+ export interface EventExceptionInterface { id?: string; churchId?: string; eventId?: string; exceptionDate?: Date; }
7
+ export interface CuratedCalendarInterface { id?: string, churchId?: string, name?:string }
8
+ export interface CuratedEventInterface { id?: string, churchId?: string, curratedCalendarId?: string, groupId?: string, eventId?: string }
9
+ export interface CuratedEventWithEventInterface extends EventInterface, CuratedEventInterface {}
10
+ export type VisibilityOptions = "public" | "private" | "hidden";
@@ -0,0 +1,24 @@
1
+ export interface ActionInterface { id?: string, automationId?: string, actionType?: string, actionData?: string }
2
+ export interface AutomationInterface { id?: string, title: string, recurs: string, active: boolean }
3
+ export interface ConditionInterface { id?: string, conjunctionId?: string, field?: string, fieldData?: string, operator?: string, value?: string, label?: string }
4
+ export interface ConjunctionInterface { id?: string, automationId?: string, parentId?: string, groupType?: string, conjunctions?: ConjunctionInterface[], conditions?: ConditionInterface[] }
5
+ export interface TaskInterface {
6
+ id?: string,
7
+ taskNumber?: number,
8
+ taskType?: string,
9
+ dateCreated?: Date,
10
+ dateClosed?: Date,
11
+ associatedWithType?: string,
12
+ associatedWithId?: string,
13
+ associatedWithLabel?: string,
14
+ createdByType?: string,
15
+ createdById?: string,
16
+ createdByLabel?: string,
17
+ assignedToType?: string,
18
+ assignedToId?: string,
19
+ assignedToLabel?: string,
20
+ title?: string,
21
+ status?: string,
22
+ automationId?: string,
23
+ conversationId?: string
24
+ }
@@ -0,0 +1,45 @@
1
+ import { PersonInterface } from "."
2
+
3
+ export interface DonationBatchInterface { id?: string, name?: string, batchDate?: Date, donationCount?: number, totalAmount?: number }
4
+ export interface DonationInterface { id?: string, batchId?: string, personId?: string, donationDate?: Date, amount?: number, method?: string, methodDetails?: string, notes?: string, person?: PersonInterface, fund?: FundInterface }
5
+ export interface DonationSummaryInterface { week: number, donations?: DonationSummaryDonation[] }
6
+ export interface DonationSummaryDonation { totalAmount: number, fund?: FundInterface }
7
+ export interface FundInterface { id: string, name: string, amount?: number }
8
+ export interface FundDonationInterface { id?: string, donationId?: string, fundId?: string, amount?: number, donation?: DonationInterface }
9
+ export interface PaymentMethodInterface { id?: string, churchId?: string, personId?: string, customerId?: string, email?: string, name?: string }
10
+ export interface StripeCardUpdateInterface { paymentMethodId: string, cardData: StripeCardDataInterface, personId?: string }
11
+ export interface StripeCardDataInterface { card: StripeCardExpirationInterface }
12
+ export interface StripeCardExpirationInterface { exp_month: string, exp_year: string }
13
+ export interface StripeBankAccountInterface { account_holder_name: any, account_holder_type: any, country: string, currency: string, account_number: any, routing_number: any }
14
+ export interface StripeBankAccountUpdateInterface { paymentMethodId: string, customerId: string, personId?: string, bankData: StripeBankAccountHolderDataInterface }
15
+ export interface StripeBankAccountHolderDataInterface { account_holder_name: string, account_holder_type: string }
16
+ export interface StripeBankAccountVerifyInterface { customerId: string, paymentMethodId: string, amountData: { amounts: string[] } }
17
+ export interface StripePersonDonationInterface { id: string, email: string, name: string };
18
+ export interface StripeFundDonationInterface { id: string, amount: number, name?: string };
19
+ export interface StripeDonationInterface { id?: string, type?: string, amount?: number, customerId?: string, billing_cycle_anchor?: number, proration_behavior?: string, interval?: StripeDonationIntervalInterface, person?: StripePersonDonationInterface, funds?: StripeFundDonationInterface[], notes?: string, churchId?: string };
20
+ export interface StripeDonationIntervalInterface { interval: string, interval_count: number };
21
+ export interface SubscriptionInterface { id: string, funds: [], billing_cycle_anchor: number, default_payment_method: string, default_source: string, plan: { amount: number, interval: string, interval_count: number }, customer: string };
22
+
23
+ export class StripePaymentMethod {
24
+ id: string;
25
+ type: string;
26
+ name: string;
27
+ last4: string;
28
+ exp_month?: string;
29
+ exp_year?: string;
30
+ status?: string;
31
+ account_holder_name?: string;
32
+ account_holder_type?: string;
33
+
34
+ constructor(obj?: any) {
35
+ this.id = obj?.id || null;
36
+ this.type = obj?.type || (obj?.object && obj.object === "bank_account" ? "bank" : null);
37
+ this.name = obj?.card?.brand || obj?.bank_name || null;
38
+ this.last4 = obj?.last4 || obj?.card?.last4 || null;
39
+ this.exp_month = obj?.exp_month || obj?.card?.exp_month || null;
40
+ this.exp_year = obj?.exp_year || obj?.card?.exp_year || null;
41
+ this.status = obj?.status || null;
42
+ this.account_holder_name = obj?.account_holder_name || "";
43
+ this.account_holder_type = obj?.account_holder_type || "individual";
44
+ }
45
+ }
@@ -0,0 +1,17 @@
1
+ export interface ErrorLogInterface {
2
+ application?: string,
3
+ errorTime?: Date,
4
+ userId?: string,
5
+ churchId?: string,
6
+ originUrl?: string,
7
+ errorType?: string,
8
+ message?: string,
9
+ details?: string,
10
+ };
11
+
12
+ export interface ErrrorAppDataInterface {
13
+ churchId: string,
14
+ userId: string,
15
+ originUrl: string,
16
+ application: string
17
+ }
@@ -0,0 +1,51 @@
1
+ export interface AnswerInterface { id?: string, value?: string, questionId?: string, formSubmissionId?: string, required?: boolean }
2
+ export interface CampusInterface { id?: string, name?: string }
3
+ export interface ContactInfoInterface { address1?: string, address2?: string, city?: string, state?: string, zip?: string, homePhone?: string, mobilePhone?: string, workPhone?: string, email?: string, pager?: string, fax?: string, skype?: string, workEmail?: string }
4
+ export interface FormInterface { id?: string, name?: string, contentType?: string, restricted?: boolean, accessStartTime?: Date, accessEndTime?: Date, archived: boolean, action?: string }
5
+ export interface FormSubmissionInterface { id?: string, formId?: string, contentType?: string, contentId?: string, form?: FormInterface, answers?: AnswerInterface[], questions?: QuestionInterface[] }
6
+ export interface GroupInterface { id?: string, name?: string, categoryName?: string, memberCount?: number, trackAttendance?: boolean, parentPickup?: boolean, about?: string, photoUrl?: string }
7
+ export interface GroupMemberInterface { id?: string, personId: string, person?: PersonInterface, groupId: string, group?: GroupInterface, leader?: boolean }
8
+ export interface GroupServiceTimeInterface { id?: string, groupId?: string, serviceTimeId?: string, serviceTime?: ServiceTimeInterface }
9
+ export interface HouseholdInterface { id?: string, name?: string }
10
+ export interface HouseholdMemberInterface { id?: string, householdId?: string, household?: HouseholdInterface, personId?: string, person?: PersonInterface, role?: string }
11
+ export interface NameInterface { first?: string, middle?: string, last?: string, nick?: string, display?: string, title?: string, suffix?: string }
12
+ export interface SearchCondition { field: string, operator: string, value: string }
13
+
14
+ export interface PersonInterface {
15
+ id?: string,
16
+ name: NameInterface,
17
+ contactInfo: ContactInfoInterface,
18
+ membershipStatus?: string,
19
+ gender?: string,
20
+ birthDate?: Date,
21
+ maritalStatus?: string,
22
+ anniversary?: Date,
23
+ photo?: string,
24
+ photoUpdated?: Date,
25
+ householdId?: string,
26
+ householdRole?: string,
27
+ userId?: string,
28
+ school?: string,
29
+ grade?: string,
30
+ graduationDate?: string,
31
+ employer?: string,
32
+ formSubmissions?: [FormSubmissionInterface]
33
+ child?: boolean,
34
+ inactiveReason?: string,
35
+ inactiveDate?: Date,
36
+ servicesUser?: boolean,
37
+ calendarUser?: boolean,
38
+ checkInsUser?: boolean,
39
+ registrationsUser?: boolean,
40
+ givingUser?: boolean,
41
+ groupsUser?: boolean,
42
+ conversationId?: string,
43
+ optedOut?: boolean,
44
+ nametagNotes?: string
45
+ }
46
+ export interface QuestionInterface { id?: string, formId?: string, title?: string, fieldType?: string, placeholder?: string, description?: string, required?: boolean, choices?: [{ value?: string, text?: string }] }
47
+ export interface ServiceInterface { id?: string, campusId?: string, name?: string, campus?: CampusInterface }
48
+ export interface ServiceTimeInterface { id?: string, name?: string, longName?: string, serviceId?: string, groups?: GroupInterface[] }
49
+ export interface MemberPermissionInterface { id?: string, churchId?: string, memberId?: string, contentType?: string, contentId?: string, action?: string, personName: string, formName?: string, emailNotification?: boolean }
50
+ export interface FormMemberInterface { person?: PersonInterface, access?: string }
51
+ export interface FormMemberListInterface { members?: FormMemberInterface[] }
@@ -0,0 +1,20 @@
1
+ import { PersonInterface } from "./Membership";
2
+
3
+ export interface ConnectionInterface { id?: string, churchId?: string, conversationId?: string, userId?: string, displayName?: string, timeJoined?: Date, socketId?: string }
4
+ export interface ConversationInterface {
5
+ id?: string, churchId?: string, contentType?: string, contentId?: string, title?: string, dateCreated?: Date, groupId?: string, visibility?: string, firstPostId?: string, lastPostId?: string, postCount?: number, allowAnonymousPosts?: boolean;
6
+ messages?: MessageInterface[],
7
+ }
8
+ export interface MessageInterface {
9
+ id?: string, churchId?: string, conversationId?: string, userId?: string, personId?: string, displayName?: string, timeSent?: Date, timeUpdated?: Date, messageType?: string, content?: string,
10
+ person?: PersonInterface
11
+ }
12
+ export interface PrivateMessageInterface {
13
+ id?: string, churchId?: string, fromPersonId?: string, toPersonId?: string, conversationId?: string, notifyPersonId?: string
14
+ conversation?: ConversationInterface;
15
+ person?: PersonInterface;
16
+ }
17
+
18
+ export interface SocketActionHandlerInterface { action:string, id:string, handleMessage:(data:any) => void }
19
+ export type SocketPayloadAction = "message" | "deleteMessage" | "callout" | "attendance" | "prayerRequest" | "socketId" | "privateMessage" | "privateRoomAdded" | "videoChatInvite" | "reconnect";
20
+ export interface SocketPayloadInterface { action: SocketPayloadAction, data: any }