@churchapps/helpers 1.0.37 → 1.0.39
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/.prettierrc +12 -0
- package/CLAUDE.md +90 -0
- package/dist/ApiHelper.d.ts.map +1 -1
- package/dist/ApiHelper.js +92 -110
- package/dist/ApiHelper.js.map +1 -1
- package/dist/AppearanceHelper.js +12 -12
- package/dist/AppearanceHelper.js.map +1 -1
- package/dist/ArrayHelper.d.ts +1 -1
- package/dist/ArrayHelper.d.ts.map +1 -1
- package/dist/ArrayHelper.js +5 -4
- package/dist/ArrayHelper.js.map +1 -1
- package/dist/DateHelper.d.ts.map +1 -1
- package/dist/DateHelper.js +5 -4
- package/dist/DateHelper.js.map +1 -1
- package/dist/ErrorHelper.d.ts +2 -2
- package/dist/ErrorHelper.d.ts.map +1 -1
- package/dist/ErrorHelper.js.map +1 -1
- package/dist/EventHelper.js +1 -2
- package/dist/EventHelper.js.map +1 -1
- package/dist/FileHelper.d.ts.map +1 -1
- package/dist/FileHelper.js +8 -1
- package/dist/FileHelper.js.map +1 -1
- package/dist/PersonHelper.js +12 -8
- package/dist/PersonHelper.js.map +1 -1
- package/dist/UniqueIdHelper.d.ts.map +1 -1
- package/dist/UniqueIdHelper.js +2 -2
- package/dist/UniqueIdHelper.js.map +1 -1
- package/dist/UserHelper.js +3 -12
- package/dist/UserHelper.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/interfaces/Access.d.ts +1 -1
- package/dist/interfaces/Access.d.ts.map +1 -1
- package/dist/interfaces/Attendance.d.ts.map +1 -1
- package/dist/interfaces/Content.d.ts.map +1 -1
- package/dist/interfaces/Doing.d.ts.map +1 -1
- package/dist/interfaces/Donation.d.ts.map +1 -1
- package/dist/interfaces/Donation.js +9 -15
- package/dist/interfaces/Donation.js.map +1 -1
- package/dist/interfaces/Error.d.ts +1 -1
- package/dist/interfaces/Error.d.ts.map +1 -1
- package/dist/interfaces/Error.js +0 -1
- package/dist/interfaces/Error.js.map +1 -1
- package/dist/interfaces/Membership.d.ts.map +1 -1
- package/dist/interfaces/Messaging.d.ts.map +1 -1
- package/dist/interfaces/Permissions.d.ts.map +1 -1
- package/dist/interfaces/Permissions.js +31 -7
- package/dist/interfaces/Permissions.js.map +1 -1
- package/dist/interfaces/Reporting.d.ts.map +1 -1
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/index.js.map +1 -1
- package/eslint.config.js +33 -0
- package/package.json +17 -4
- package/src/ApiHelper.ts +7 -4
- package/src/AppearanceHelper.ts +8 -8
- package/src/ArrayHelper.ts +2 -1
- package/src/DateHelper.ts +3 -2
- package/src/ErrorHelper.ts +2 -2
- package/src/FileHelper.ts +6 -2
- package/src/UniqueIdHelper.ts +2 -2
- package/src/UserHelper.ts +1 -1
- package/src/index.ts +6 -3
- package/src/interfaces/Access.ts +137 -24
- package/src/interfaces/Attendance.ts +45 -8
- package/src/interfaces/Content.ts +84 -10
- package/src/interfaces/Doing.ts +93 -11
- package/src/interfaces/Donation.ts +145 -45
- package/src/interfaces/Error.ts +17 -17
- package/src/interfaces/Membership.ts +183 -52
- package/src/interfaces/Messaging.ts +96 -12
- package/src/interfaces/Permissions.ts +92 -71
- package/src/interfaces/Reporting.ts +41 -7
- package/src/interfaces/UserContextInterface.ts +13 -13
- package/src/interfaces/index.ts +13 -14
- package/tsconfig.json +6 -6
|
@@ -7,7 +7,11 @@ exports.Permissions = Permissions;
|
|
|
7
7
|
Permissions.attendanceApi = {
|
|
8
8
|
attendance: {
|
|
9
9
|
view: { api: "AttendanceApi", contentType: "Attendance", action: "View" },
|
|
10
|
-
viewSummary: {
|
|
10
|
+
viewSummary: {
|
|
11
|
+
api: "AttendanceApi",
|
|
12
|
+
contentType: "Attendance",
|
|
13
|
+
action: "View Summary"
|
|
14
|
+
},
|
|
11
15
|
edit: { api: "AttendanceApi", contentType: "Attendance", action: "Edit" }
|
|
12
16
|
},
|
|
13
17
|
services: {
|
|
@@ -34,20 +38,36 @@ Permissions.membershipApi = {
|
|
|
34
38
|
},
|
|
35
39
|
people: {
|
|
36
40
|
view: { api: "MembershipApi", contentType: "People", action: "View" },
|
|
37
|
-
viewMembers: {
|
|
41
|
+
viewMembers: {
|
|
42
|
+
api: "MembershipApi",
|
|
43
|
+
contentType: "People",
|
|
44
|
+
action: "View Members"
|
|
45
|
+
},
|
|
38
46
|
edit: { api: "MembershipApi", contentType: "People", action: "Edit" }
|
|
39
47
|
},
|
|
40
48
|
plans: {
|
|
41
49
|
edit: { api: "MembershipApi", contentType: "Plans", action: "Edit" }
|
|
42
50
|
},
|
|
43
51
|
groupMembers: {
|
|
44
|
-
edit: {
|
|
45
|
-
|
|
52
|
+
edit: {
|
|
53
|
+
api: "MembershipApi",
|
|
54
|
+
contentType: "Group Members",
|
|
55
|
+
action: "Edit"
|
|
56
|
+
},
|
|
57
|
+
view: {
|
|
58
|
+
api: "MembershipApi",
|
|
59
|
+
contentType: "Group Members",
|
|
60
|
+
action: "View"
|
|
61
|
+
}
|
|
46
62
|
}
|
|
47
63
|
};
|
|
48
64
|
Permissions.givingApi = {
|
|
49
65
|
donations: {
|
|
50
|
-
viewSummary: {
|
|
66
|
+
viewSummary: {
|
|
67
|
+
api: "GivingApi",
|
|
68
|
+
contentType: "Donations",
|
|
69
|
+
action: "View Summary"
|
|
70
|
+
},
|
|
51
71
|
view: { api: "GivingApi", contentType: "Donations", action: "View" },
|
|
52
72
|
edit: { api: "GivingApi", contentType: "Donations", action: "Edit" }
|
|
53
73
|
},
|
|
@@ -64,7 +84,11 @@ Permissions.contentApi = {
|
|
|
64
84
|
edit: { api: "ContentApi", contentType: "Content", action: "Edit" }
|
|
65
85
|
},
|
|
66
86
|
streamingServices: {
|
|
67
|
-
edit: {
|
|
68
|
-
|
|
87
|
+
edit: {
|
|
88
|
+
api: "ContentApi",
|
|
89
|
+
contentType: "StreamingServices",
|
|
90
|
+
action: "Edit"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
69
93
|
};
|
|
70
94
|
//# sourceMappingURL=Permissions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Permissions.js","sourceRoot":"","sources":["../../src/interfaces/Permissions.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;;AAAxB,
|
|
1
|
+
{"version":3,"file":"Permissions.js","sourceRoot":"","sources":["../../src/interfaces/Permissions.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reporting.d.ts","sourceRoot":"","sources":["../../src/interfaces/Reporting.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;
|
|
1
|
+
{"version":3,"file":"Reporting.d.ts","sourceRoot":"","sources":["../../src/interfaces/Reporting.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,OAAO,EAAE,qBAAqB,EAAE,CAAC;CAClC;AACD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,WAAW,EAAE,8BAA8B,EAAE,CAAC;CAC/C;AACD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AACD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AACD,MAAM,WAAW,8BAA8B;IAC7C,UAAU,EAAE,yBAAyB,EAAE,CAAC;CACzC;AACD,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -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;
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,yDAAuC;AACvC,gDAA8B;
|
|
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"}
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const js = require("@eslint/js");
|
|
2
|
+
const tseslint = require("@typescript-eslint/eslint-plugin");
|
|
3
|
+
const tsparser = require("@typescript-eslint/parser");
|
|
4
|
+
|
|
5
|
+
module.exports = [
|
|
6
|
+
js.configs.recommended,
|
|
7
|
+
{
|
|
8
|
+
files: ["src/**/*.ts"],
|
|
9
|
+
languageOptions: {
|
|
10
|
+
parser: tsparser,
|
|
11
|
+
parserOptions: {
|
|
12
|
+
ecmaVersion: 2020,
|
|
13
|
+
sourceType: "module",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
plugins: {
|
|
17
|
+
"@typescript-eslint": tseslint,
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
21
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
22
|
+
"no-unused-vars": "off",
|
|
23
|
+
"prefer-const": "error",
|
|
24
|
+
"no-console": "warn",
|
|
25
|
+
"comma-dangle": ["error", "never"],
|
|
26
|
+
"object-curly-newline": ["error", { "multiline": true, "consistent": true }],
|
|
27
|
+
"array-bracket-newline": ["error", "consistent"]
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
ignores: ["dist/**", "node_modules/**"],
|
|
32
|
+
},
|
|
33
|
+
];
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@churchapps/helpers",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.39",
|
|
4
4
|
"description": "Library of helper functions not specific to any one ChurchApps project or framework.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"clean": "rimraf dist",
|
|
9
9
|
"tsc": "tsc",
|
|
10
|
-
"build": "npm-run-all clean tsc"
|
|
10
|
+
"build": "npm-run-all clean tsc",
|
|
11
|
+
"lint": "eslint src/**/*.ts",
|
|
12
|
+
"lint:fix": "eslint src/**/*.ts --fix",
|
|
13
|
+
"format": "prettier --write src/**/*.ts"
|
|
11
14
|
},
|
|
12
15
|
"repository": {
|
|
13
16
|
"type": "git",
|
|
@@ -22,9 +25,19 @@
|
|
|
22
25
|
"url": "https://github.com/LiveChurchSolutions/Helpers/issues"
|
|
23
26
|
},
|
|
24
27
|
"homepage": "https://github.com/LiveChurchSolutions/Helpers#readme",
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=20.0.0",
|
|
30
|
+
"npm": ">=10.0.0"
|
|
31
|
+
},
|
|
25
32
|
"devDependencies": {
|
|
26
|
-
"@types/node": "^
|
|
27
|
-
"
|
|
33
|
+
"@types/node": "^24.0.3",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
|
35
|
+
"@typescript-eslint/parser": "^8.35.0",
|
|
36
|
+
"eslint": "^9.29.0",
|
|
37
|
+
"eslint-config-prettier": "^10.1.5",
|
|
38
|
+
"eslint-plugin-prettier": "^5.5.0",
|
|
39
|
+
"npm-run-all2": "^8.0.4",
|
|
40
|
+
"prettier": "^3.6.0",
|
|
28
41
|
"rimraf": "^6.0.1",
|
|
29
42
|
"typescript": "^5.8.3"
|
|
30
43
|
},
|
package/src/ApiHelper.ts
CHANGED
|
@@ -18,7 +18,7 @@ export class ApiHelper {
|
|
|
18
18
|
static setDefaultPermissions(jwt: string) {
|
|
19
19
|
this.apiConfigs.forEach(config => {
|
|
20
20
|
config.jwt = jwt;
|
|
21
|
-
config.
|
|
21
|
+
config.permissions = [];
|
|
22
22
|
});
|
|
23
23
|
this.isAuthenticated = true;
|
|
24
24
|
}
|
|
@@ -27,19 +27,20 @@ export class ApiHelper {
|
|
|
27
27
|
this.apiConfigs.forEach(config => {
|
|
28
28
|
if (config.keyName === keyName) {
|
|
29
29
|
config.jwt = jwt;
|
|
30
|
-
config.
|
|
30
|
+
config.permissions = permissions;
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
this.isAuthenticated = true;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
static clearPermissions() {
|
|
37
|
-
this.apiConfigs.forEach(config => { config.jwt = ""; config.
|
|
37
|
+
this.apiConfigs.forEach(config => { config.jwt = ""; config.permissions = []; });
|
|
38
38
|
this.isAuthenticated = false;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
static async get(path: string, apiName: ApiListType) {
|
|
42
42
|
const config = this.getConfig(apiName);
|
|
43
|
+
if (!config) throw new Error(`API configuration not found: ${apiName}`);
|
|
43
44
|
const requestOptions = { method: "GET", headers: { Authorization: "Bearer " + config.jwt } };
|
|
44
45
|
return await this.fetchWithErrorHandling(config.url + path, requestOptions);
|
|
45
46
|
}
|
|
@@ -52,6 +53,7 @@ export class ApiHelper {
|
|
|
52
53
|
|
|
53
54
|
static async post(path: string, data: any[] | {}, apiName: ApiListType) {
|
|
54
55
|
const config = this.getConfig(apiName);
|
|
56
|
+
if (!config) throw new Error(`API configuration not found: ${apiName}`);
|
|
55
57
|
const requestOptions = {
|
|
56
58
|
method: "POST",
|
|
57
59
|
headers: { Authorization: "Bearer " + config.jwt, "Content-Type": "application/json" },
|
|
@@ -62,6 +64,7 @@ export class ApiHelper {
|
|
|
62
64
|
|
|
63
65
|
static async patch(path: string, data: any[] | {}, apiName: ApiListType) {
|
|
64
66
|
const config = this.getConfig(apiName);
|
|
67
|
+
if (!config) throw new Error(`API configuration not found: ${apiName}`);
|
|
65
68
|
const requestOptions = {
|
|
66
69
|
method: "PATCH",
|
|
67
70
|
headers: { Authorization: "Bearer " + config.jwt, "Content-Type": "application/json" },
|
|
@@ -72,6 +75,7 @@ export class ApiHelper {
|
|
|
72
75
|
|
|
73
76
|
static async delete(path: string, apiName: ApiListType) {
|
|
74
77
|
const config = this.getConfig(apiName);
|
|
78
|
+
if (!config) throw new Error(`API configuration not found: ${apiName}`);
|
|
75
79
|
const requestOptions = {
|
|
76
80
|
method: "DELETE",
|
|
77
81
|
headers: { Authorization: "Bearer " + config.jwt }
|
|
@@ -94,7 +98,6 @@ export class ApiHelper {
|
|
|
94
98
|
headers: { "Content-Type": "application/json" },
|
|
95
99
|
body: JSON.stringify(data)
|
|
96
100
|
};
|
|
97
|
-
console.log(config.url + path, requestOptions);
|
|
98
101
|
return await this.fetchWithErrorHandling(config.url + path, requestOptions);
|
|
99
102
|
}
|
|
100
103
|
|
package/src/AppearanceHelper.ts
CHANGED
|
@@ -35,15 +35,15 @@ export class AppearanceHelper {
|
|
|
35
35
|
let g = 0;
|
|
36
36
|
let b = 0;
|
|
37
37
|
|
|
38
|
-
if (backgroundColor.match(/#[0-9a-fA-F{6}
|
|
39
|
-
r = this.getHexValue(backgroundColor.substring(1,
|
|
40
|
-
g = this.getHexValue(backgroundColor.substring(3,
|
|
41
|
-
b = this.getHexValue(backgroundColor.substring(5,
|
|
38
|
+
if (backgroundColor.match(/#[0-9a-fA-F]{6}/)) {
|
|
39
|
+
r = this.getHexValue(backgroundColor.substring(1, 3));
|
|
40
|
+
g = this.getHexValue(backgroundColor.substring(3, 5));
|
|
41
|
+
b = this.getHexValue(backgroundColor.substring(5, 7));
|
|
42
42
|
valid = true;
|
|
43
|
-
} else if (backgroundColor.match(/#[0-9a-fA-F{3}
|
|
44
|
-
r = this.getHexValue(backgroundColor.substring(1,
|
|
45
|
-
g = this.getHexValue(backgroundColor.substring(2,
|
|
46
|
-
b = this.getHexValue(backgroundColor.substring(3,
|
|
43
|
+
} else if (backgroundColor.match(/#[0-9a-fA-F]{3}/)) {
|
|
44
|
+
r = this.getHexValue(backgroundColor.substring(1, 2));
|
|
45
|
+
g = this.getHexValue(backgroundColor.substring(2, 3));
|
|
46
|
+
b = this.getHexValue(backgroundColor.substring(3, 4));
|
|
47
47
|
valid = true;
|
|
48
48
|
}
|
|
49
49
|
|
package/src/ArrayHelper.ts
CHANGED
|
@@ -52,7 +52,8 @@ export class ArrayHelper {
|
|
|
52
52
|
else {
|
|
53
53
|
let obj = item;
|
|
54
54
|
for (let i = 0; i < propChain.length - 1; i++) {
|
|
55
|
-
if (obj) obj =
|
|
55
|
+
if (obj && obj[propChain[i]] !== undefined) obj = obj[propChain[i]];
|
|
56
|
+
else return false;
|
|
56
57
|
}
|
|
57
58
|
return obj[propChain[propChain.length - 1]] === value;
|
|
58
59
|
}
|
package/src/DateHelper.ts
CHANGED
|
@@ -20,8 +20,9 @@ export class DateHelper {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
static addDays(date: Date, days: number) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const result = new Date(date.getTime());
|
|
24
|
+
result.setDate(result.getDate() + days);
|
|
25
|
+
return result;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
static prettyDate(date: Date) {
|
package/src/ErrorHelper.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorLogInterface,
|
|
1
|
+
import { ErrorLogInterface, ErrorAppDataInterface } from "./interfaces/Error";
|
|
2
2
|
import { ApiHelper } from "./ApiHelper";
|
|
3
3
|
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ export class ErrorHelper {
|
|
|
7
7
|
static getAppData:() => { churchId: string, userId: string, originUrl: string, application: string};
|
|
8
8
|
static customErrorHandler:(errorLog:ErrorLogInterface) => void;
|
|
9
9
|
|
|
10
|
-
static init = (getAppData:() =>
|
|
10
|
+
static init = (getAppData:() => ErrorAppDataInterface, customErrorHandler:(errorLog:ErrorLogInterface) => void) => {
|
|
11
11
|
ErrorHelper.getAppData = getAppData;
|
|
12
12
|
ErrorHelper.customErrorHandler = customErrorHandler;
|
|
13
13
|
}
|
package/src/FileHelper.ts
CHANGED
|
@@ -41,8 +41,12 @@ export class FileHelper {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
static dataURLtoBlob(dataurl: string) {
|
|
44
|
-
let arr = dataurl.split(",")
|
|
45
|
-
|
|
44
|
+
let arr = dataurl.split(",");
|
|
45
|
+
if (arr.length < 2) throw new Error("Invalid data URL format");
|
|
46
|
+
let mimeMatch = arr[0].match(/:(.*?);/);
|
|
47
|
+
if (!mimeMatch) throw new Error("Invalid MIME type in data URL");
|
|
48
|
+
let mime = mimeMatch[1];
|
|
49
|
+
let bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
|
46
50
|
while (n--) {
|
|
47
51
|
u8arr[n] = bstr.charCodeAt(n);
|
|
48
52
|
}
|
package/src/UniqueIdHelper.ts
CHANGED
|
@@ -2,12 +2,12 @@ export class UniqueIdHelper {
|
|
|
2
2
|
|
|
3
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
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",
|
|
5
|
+
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
|
6
6
|
"-", "_"];
|
|
7
7
|
|
|
8
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
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"
|
|
10
|
+
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
11
11
|
|
|
12
12
|
public static isMissing(obj: any) {
|
|
13
13
|
if (obj === undefined || obj === null) return true;
|
package/src/UserHelper.ts
CHANGED
|
@@ -40,7 +40,7 @@ export class UserHelper {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
static checkAccess({ api, contentType, action }: IApiPermission): boolean {
|
|
43
|
-
const permissions = ApiHelper.getConfig(api).
|
|
43
|
+
const permissions = ApiHelper.getConfig(api).permissions;
|
|
44
44
|
|
|
45
45
|
let result = false;
|
|
46
46
|
if (permissions !== undefined) {
|
package/src/index.ts
CHANGED
|
@@ -2,11 +2,14 @@ export * from "./interfaces";
|
|
|
2
2
|
export { ApiHelper } from "./ApiHelper";
|
|
3
3
|
export { AppearanceHelper } from "./AppearanceHelper";
|
|
4
4
|
export { ArrayHelper } from "./ArrayHelper";
|
|
5
|
-
export {
|
|
5
|
+
export { CommonEnvironmentHelper } from "./CommonEnvironmentHelper";
|
|
6
|
+
export { CurrencyHelper } from "./CurrencyHelper";
|
|
6
7
|
export { DateHelper } from "./DateHelper";
|
|
8
|
+
export { DonationHelper } from "./DonationHelper";
|
|
9
|
+
export { ErrorHelper } from "./ErrorHelper";
|
|
10
|
+
export { EventHelper } from "./EventHelper";
|
|
7
11
|
export { FileHelper } from "./FileHelper";
|
|
8
|
-
export { PersonHelper } from "./PersonHelper"
|
|
12
|
+
export { PersonHelper } from "./PersonHelper";
|
|
9
13
|
export { UserHelper } from "./UserHelper";
|
|
10
14
|
export { UniqueIdHelper } from "./UniqueIdHelper";
|
|
11
|
-
export { DonationHelper } from "./DonationHelper";
|
|
12
15
|
|
package/src/interfaces/Access.ts
CHANGED
|
@@ -1,24 +1,137 @@
|
|
|
1
|
-
import { PersonInterface } from "./Membership";
|
|
2
|
-
|
|
3
|
-
export interface ApiInterface {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export interface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export
|
|
24
|
-
|
|
1
|
+
import { PersonInterface } from "./Membership";
|
|
2
|
+
|
|
3
|
+
export interface ApiInterface {
|
|
4
|
+
name: string;
|
|
5
|
+
keyName?: string;
|
|
6
|
+
permissions: RolePermissionInterface[];
|
|
7
|
+
jwt: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ChurchInterface {
|
|
10
|
+
id?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
registrationDate?: Date;
|
|
13
|
+
address1?: string;
|
|
14
|
+
address2?: string;
|
|
15
|
+
city?: string;
|
|
16
|
+
state?: string;
|
|
17
|
+
zip?: string;
|
|
18
|
+
country?: string;
|
|
19
|
+
subDomain?: string;
|
|
20
|
+
settings?: GenericSettingInterface[];
|
|
21
|
+
archivedDate?: Date;
|
|
22
|
+
}
|
|
23
|
+
export interface DomainInterface {
|
|
24
|
+
id?: string;
|
|
25
|
+
domainName?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface RegisterChurchRequestInterface extends ChurchInterface {
|
|
28
|
+
appName?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface LoadCreateUserRequestInterface {
|
|
31
|
+
userEmail: string;
|
|
32
|
+
fromEmail?: string;
|
|
33
|
+
subject?: string;
|
|
34
|
+
body?: string;
|
|
35
|
+
firstName: string;
|
|
36
|
+
lastName: string;
|
|
37
|
+
}
|
|
38
|
+
export interface LoginResponseInterface {
|
|
39
|
+
user: UserInterface;
|
|
40
|
+
userChurches: LoginUserChurchInterface[];
|
|
41
|
+
errors: string[];
|
|
42
|
+
}
|
|
43
|
+
export interface LoginUserChurchInterface {
|
|
44
|
+
person: PersonInterface;
|
|
45
|
+
church: ChurchInterface;
|
|
46
|
+
apis: ApiInterface[];
|
|
47
|
+
jwt: string;
|
|
48
|
+
groups: { id: string; tags: string; name: string; leader: boolean }[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface PermissionInterface {
|
|
52
|
+
apiName?: string;
|
|
53
|
+
section?: string;
|
|
54
|
+
action?: string;
|
|
55
|
+
displaySection?: string;
|
|
56
|
+
displayAction?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface RegisterUserInterface {
|
|
59
|
+
firstName?: string;
|
|
60
|
+
lastName: string;
|
|
61
|
+
email?: string;
|
|
62
|
+
appName: string;
|
|
63
|
+
appUrl: string;
|
|
64
|
+
}
|
|
65
|
+
export interface RoleInterface {
|
|
66
|
+
id?: string;
|
|
67
|
+
churchId?: string;
|
|
68
|
+
name?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface RolePermissionInterface {
|
|
71
|
+
id?: string;
|
|
72
|
+
churchId?: string;
|
|
73
|
+
roleId?: string;
|
|
74
|
+
apiName?: string;
|
|
75
|
+
contentType?: string;
|
|
76
|
+
contentId?: string;
|
|
77
|
+
action?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface RoleMemberInterface {
|
|
80
|
+
id?: string;
|
|
81
|
+
churchId?: string;
|
|
82
|
+
roleId?: string;
|
|
83
|
+
userId?: string;
|
|
84
|
+
user?: UserInterface;
|
|
85
|
+
personId?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ResetPasswordRequestInterface {
|
|
88
|
+
userEmail: string;
|
|
89
|
+
}
|
|
90
|
+
export interface ResetPasswordResponseInterface {
|
|
91
|
+
emailed: boolean;
|
|
92
|
+
}
|
|
93
|
+
export interface UserInterface {
|
|
94
|
+
id?: string;
|
|
95
|
+
email?: string;
|
|
96
|
+
authGuid?: string;
|
|
97
|
+
firstName?: string;
|
|
98
|
+
lastName?: string;
|
|
99
|
+
registrationDate?: Date;
|
|
100
|
+
lastLogin?: Date;
|
|
101
|
+
password?: string;
|
|
102
|
+
jwt?: string;
|
|
103
|
+
}
|
|
104
|
+
export interface GenericSettingInterface {
|
|
105
|
+
id?: string;
|
|
106
|
+
churchId?: string;
|
|
107
|
+
keyName?: string;
|
|
108
|
+
value?: string;
|
|
109
|
+
public?: number;
|
|
110
|
+
}
|
|
111
|
+
export interface UserChurchInterface {
|
|
112
|
+
id?: string;
|
|
113
|
+
userId?: string;
|
|
114
|
+
churchId?: string;
|
|
115
|
+
personId?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface ApiConfig {
|
|
119
|
+
keyName: string;
|
|
120
|
+
url: string;
|
|
121
|
+
jwt: string;
|
|
122
|
+
permissions: RolePermissionInterface[];
|
|
123
|
+
}
|
|
124
|
+
export type ApiListType =
|
|
125
|
+
| "MembershipApi"
|
|
126
|
+
| "AttendanceApi"
|
|
127
|
+
| "GivingApi"
|
|
128
|
+
| "DoingApi"
|
|
129
|
+
| "MessagingApi"
|
|
130
|
+
| "LessonsApi"
|
|
131
|
+
| "ReportingApi"
|
|
132
|
+
| "ContentApi";
|
|
133
|
+
export interface IApiPermission {
|
|
134
|
+
api: string;
|
|
135
|
+
contentType: string;
|
|
136
|
+
action: string;
|
|
137
|
+
}
|
|
@@ -1,8 +1,45 @@
|
|
|
1
|
-
import { CampusInterface, ServiceInterface, ServiceTimeInterface, PersonInterface } from "."
|
|
2
|
-
|
|
3
|
-
export interface AttendanceInterface {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { CampusInterface, ServiceInterface, ServiceTimeInterface, PersonInterface } from ".";
|
|
2
|
+
|
|
3
|
+
export interface AttendanceInterface {
|
|
4
|
+
campus: CampusInterface;
|
|
5
|
+
service: ServiceInterface;
|
|
6
|
+
serviceTime: ServiceTimeInterface;
|
|
7
|
+
groupId: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AttendanceRecordInterface {
|
|
10
|
+
serviceTime: ServiceTimeInterface;
|
|
11
|
+
service: ServiceInterface;
|
|
12
|
+
campus: CampusInterface;
|
|
13
|
+
week: number;
|
|
14
|
+
count: number;
|
|
15
|
+
visitDate: Date;
|
|
16
|
+
groupId: string;
|
|
17
|
+
}
|
|
18
|
+
export interface VisitInterface {
|
|
19
|
+
id?: string;
|
|
20
|
+
personId?: string;
|
|
21
|
+
serviceId?: string;
|
|
22
|
+
groupId?: string;
|
|
23
|
+
visitDate?: Date;
|
|
24
|
+
visitSessions?: VisitSessionInterface[];
|
|
25
|
+
person?: PersonInterface;
|
|
26
|
+
}
|
|
27
|
+
export interface VisitSessionInterface {
|
|
28
|
+
id?: string;
|
|
29
|
+
visitId?: string;
|
|
30
|
+
sessionId?: string;
|
|
31
|
+
visit?: VisitInterface;
|
|
32
|
+
session?: SessionInterface;
|
|
33
|
+
}
|
|
34
|
+
export interface SessionInterface {
|
|
35
|
+
id?: string;
|
|
36
|
+
groupId: string;
|
|
37
|
+
serviceTimeId: string;
|
|
38
|
+
sessionDate?: Date;
|
|
39
|
+
displayName: string;
|
|
40
|
+
}
|
|
41
|
+
export interface SettingInterface {
|
|
42
|
+
id?: string;
|
|
43
|
+
keyName?: string;
|
|
44
|
+
value?: string;
|
|
45
|
+
}
|