@churchapps/helpers 1.2.24 → 1.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/interfaces/Messaging.d.ts +21 -0
- package/dist/interfaces/Messaging.d.ts.map +1 -1
- package/dist/interfaces/Permissions.d.ts +9 -0
- package/dist/interfaces/Permissions.d.ts.map +1 -1
- package/dist/interfaces/Permissions.js +5 -0
- package/dist/interfaces/Permissions.js.map +1 -1
- package/package.json +10 -5
- package/.github/FUNDING.yml +0 -1
- package/.yarnrc.yml +0 -6
- package/eslint.config.js +0 -48
- package/scripts/build-cjs.js +0 -33
- package/src/ApiHelper.ts +0 -169
- package/src/AppearanceHelper.ts +0 -69
- package/src/ArrayHelper.ts +0 -139
- package/src/CommonEnvironmentHelper.ts +0 -104
- package/src/CurrencyHelper.ts +0 -66
- package/src/DateHelper.ts +0 -180
- package/src/DonationHelper.ts +0 -25
- package/src/ErrorHelper.ts +0 -38
- package/src/EventHelper.ts +0 -83
- package/src/FileHelper.ts +0 -57
- package/src/PersonHelper.ts +0 -80
- package/src/PlanHelper.ts +0 -135
- package/src/UniqueIdHelper.ts +0 -159
- package/src/UserHelper.ts +0 -61
- package/src/contentProviders/ContentProvider.ts +0 -15
- package/src/contentProviders/LessonsContentProvider.ts +0 -278
- package/src/contentProviders/index.ts +0 -2
- package/src/index.ts +0 -16
- package/src/interfaces/Access.ts +0 -138
- package/src/interfaces/Attendance.ts +0 -45
- package/src/interfaces/Content.ts +0 -84
- package/src/interfaces/Doing.ts +0 -142
- package/src/interfaces/Donation.ts +0 -193
- package/src/interfaces/Error.ts +0 -17
- package/src/interfaces/Lessons.ts +0 -61
- package/src/interfaces/Membership.ts +0 -184
- package/src/interfaces/Messaging.ts +0 -96
- package/src/interfaces/Permissions.ts +0 -78
- package/src/interfaces/Reporting.ts +0 -41
- package/src/interfaces/UserContextInterface.ts +0 -13
- package/src/interfaces/index.ts +0 -14
- package/tsconfig.json +0 -36
|
@@ -83,4 +83,25 @@ export interface SocketPayloadInterface {
|
|
|
83
83
|
action: SocketPayloadAction;
|
|
84
84
|
data: any;
|
|
85
85
|
}
|
|
86
|
+
export interface TextingProviderInterface {
|
|
87
|
+
id?: string;
|
|
88
|
+
churchId?: string;
|
|
89
|
+
provider?: string;
|
|
90
|
+
apiKey?: string;
|
|
91
|
+
apiSecret?: string;
|
|
92
|
+
fromNumber?: string;
|
|
93
|
+
enabled?: boolean;
|
|
94
|
+
}
|
|
95
|
+
export interface SentTextInterface {
|
|
96
|
+
id?: string;
|
|
97
|
+
churchId?: string;
|
|
98
|
+
groupId?: string;
|
|
99
|
+
recipientPersonId?: string;
|
|
100
|
+
senderPersonId?: string;
|
|
101
|
+
message?: string;
|
|
102
|
+
recipientCount?: number;
|
|
103
|
+
successCount?: number;
|
|
104
|
+
failCount?: number;
|
|
105
|
+
timeSent?: Date;
|
|
106
|
+
}
|
|
86
107
|
//# sourceMappingURL=Messaging.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Messaging.d.ts","sourceRoot":"","sources":["../../src/interfaces/Messaging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,qBAAqB;IACpC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,S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E,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CACpC;AACD,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,eAAe,GACf,SAAS,GACT,YAAY,GACZ,eAAe,GACf,UAAU,GACV,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,GACjB,WAAW,CAAC;AAChB,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,IAAI,EAAE,GAAG,CAAC;CACX;AACD,MAAM,WAAW,wBAAwB;IACvC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AACD,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -139,6 +139,15 @@ export declare class Permissions {
|
|
|
139
139
|
};
|
|
140
140
|
};
|
|
141
141
|
};
|
|
142
|
+
static messagingApi: {
|
|
143
|
+
texting: {
|
|
144
|
+
send: {
|
|
145
|
+
api: string;
|
|
146
|
+
contentType: string;
|
|
147
|
+
action: string;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
};
|
|
142
151
|
static contentApi: {
|
|
143
152
|
chat: {
|
|
144
153
|
host: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Permissions.d.ts","sourceRoot":"","sources":["../../src/interfaces/Permissions.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;IACtB,MAAM,CAAC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;MAWlB;IAEF,MAAM,CAAC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkClB;IAEF,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAcd;IAEF,MAAM,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;MAUf;CACH"}
|
|
1
|
+
{"version":3,"file":"Permissions.d.ts","sourceRoot":"","sources":["../../src/interfaces/Permissions.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;IACtB,MAAM,CAAC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;MAWlB;IAEF,MAAM,CAAC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkClB;IAEF,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAcd;IAEF,MAAM,CAAC,YAAY;;;;;;;;MAIjB;IAEF,MAAM,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;MAUf;CACH"}
|
|
@@ -61,6 +61,11 @@ export class Permissions {
|
|
|
61
61
|
edit: { api: "GivingApi", contentType: "Settings", action: "Edit" }
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
+
static messagingApi = {
|
|
65
|
+
texting: {
|
|
66
|
+
send: { api: "MessagingApi", contentType: "Texting", action: "Send" }
|
|
67
|
+
}
|
|
68
|
+
};
|
|
64
69
|
static contentApi = {
|
|
65
70
|
chat: { host: { api: "ContentApi", contentType: "Chat", action: "Host" } },
|
|
66
71
|
content: { edit: { api: "ContentApi", contentType: "Content", action: "Edit" } },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Permissions.js","sourceRoot":"","sources":["../../src/interfaces/Permissions.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAW;IACtB,MAAM,CAAC,aAAa,GAAG;QACrB,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE;YACzE,WAAW,EAAE;gBACX,GAAG,EAAE,eAAe;gBACpB,WAAW,EAAE,YAAY;gBACzB,MAAM,EAAE,cAAc;aACvB;YACD,IAAI,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE;SAC1E;QACD,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;KACtF,CAAC;IAEF,MAAM,CAAC,aAAa,GAAG;QACrB,KAAK,EAAE;YACL,IAAI,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE;YACpE,IAAI,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE;SACrE;QACD,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;QACrF,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;QACnF,KAAK,EAAE;YAC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AAO,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;QAChF,iBAAiB,EAAE;YACjB,IAAI,EAAE;gBACJ,GAAG,EAAE,YAAY;gBACjB,WAAW,EAAE,mBAAmB;gBAChC,MAAM,EAAE,MAAM;aACf;SACF;KACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@churchapps/helpers",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.26",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Library of helper functions not specific to any one ChurchApps project or framework.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,16 +11,21 @@
|
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
14
17
|
"scripts": {
|
|
15
18
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
16
19
|
"clean": "rimraf dist",
|
|
17
|
-
"
|
|
20
|
+
"tsc": "tsc",
|
|
21
|
+
"build": "npm-run-all clean tsc",
|
|
18
22
|
"lint": "eslint --fix src/",
|
|
19
23
|
"publish": "npm run build && npm publish --access=public"
|
|
20
24
|
},
|
|
21
25
|
"repository": {
|
|
22
26
|
"type": "git",
|
|
23
|
-
"url": "
|
|
27
|
+
"url": "https://github.com/ChurchApps/Packages.git",
|
|
28
|
+
"directory": "helpers"
|
|
24
29
|
},
|
|
25
30
|
"keywords": [
|
|
26
31
|
"ChurchApps"
|
|
@@ -28,9 +33,9 @@
|
|
|
28
33
|
"author": "ChurchApps.org",
|
|
29
34
|
"license": "MIT",
|
|
30
35
|
"bugs": {
|
|
31
|
-
"url": "https://github.com/
|
|
36
|
+
"url": "https://github.com/ChurchApps/Packages/issues"
|
|
32
37
|
},
|
|
33
|
-
"homepage": "https://github.com/
|
|
38
|
+
"homepage": "https://github.com/ChurchApps/Packages/tree/main/helpers#readme",
|
|
34
39
|
"engines": {
|
|
35
40
|
"node": ">=20.0.0",
|
|
36
41
|
"yarn": ">=1.22.0",
|
package/.github/FUNDING.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
github: [ChurchApps]
|
package/.yarnrc.yml
DELETED
package/eslint.config.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import tseslint from "@typescript-eslint/eslint-plugin";
|
|
2
|
-
import tsparser from "@typescript-eslint/parser";
|
|
3
|
-
import unusedImports from "eslint-plugin-unused-imports";
|
|
4
|
-
|
|
5
|
-
export default [
|
|
6
|
-
{ ignores: ["node_modules/", "dist/", "build/", ".next/", "coverage/", "*.config.js"] },
|
|
7
|
-
{
|
|
8
|
-
files: ["**/*.{ts,tsx,js,jsx}"],
|
|
9
|
-
languageOptions: {
|
|
10
|
-
parser: tsparser,
|
|
11
|
-
parserOptions: { ecmaVersion: "latest", sourceType: "module" }
|
|
12
|
-
},
|
|
13
|
-
plugins: {
|
|
14
|
-
"@typescript-eslint": tseslint,
|
|
15
|
-
"unused-imports": unusedImports
|
|
16
|
-
},
|
|
17
|
-
rules: {
|
|
18
|
-
"prefer-const": "error",
|
|
19
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
20
|
-
"@typescript-eslint/no-unused-vars": ["warn", { args: "all", argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
|
|
21
|
-
"unused-imports/no-unused-imports": "error",
|
|
22
|
-
"no-trailing-spaces": "error",
|
|
23
|
-
"eol-last": ["error", "always"],
|
|
24
|
-
"quotes": ["error", "double", { avoidEscape: true, allowTemplateLiterals: true }],
|
|
25
|
-
"semi": ["error", "always"],
|
|
26
|
-
"comma-dangle": ["error", "never"],
|
|
27
|
-
"indent": ["warn", 2, { SwitchCase: 1 }],
|
|
28
|
-
"comma-spacing": ["error", { before: false, after: true }],
|
|
29
|
-
"key-spacing": ["error", { beforeColon: false, afterColon: true, mode: "strict" }],
|
|
30
|
-
"keyword-spacing": ["error", { before: true, after: true }],
|
|
31
|
-
"space-infix-ops": "error",
|
|
32
|
-
"no-multi-spaces": ["error", { ignoreEOLComments: true }],
|
|
33
|
-
"block-spacing": ["error", "always"],
|
|
34
|
-
"brace-style": ["error", "1tbs", { allowSingleLine: true }],
|
|
35
|
-
curly: ["error", "multi-line"],
|
|
36
|
-
"nonblock-statement-body-position": ["error", "beside"],
|
|
37
|
-
"object-curly-spacing": ["error", "always"],
|
|
38
|
-
"object-curly-newline": ["error", { ObjectExpression: { multiline: true }, ObjectPattern: { multiline: true }, ImportDeclaration: { multiline: true }, ExportDeclaration: { multiline: true } }],
|
|
39
|
-
"object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
|
|
40
|
-
"array-bracket-spacing": ["error", "never"],
|
|
41
|
-
"array-bracket-newline": ["error", { multiline: true, minItems: 8 }],
|
|
42
|
-
"array-element-newline": ["error", { ArrayExpression: "consistent", ArrayPattern: { minItems: 8 } }],
|
|
43
|
-
"function-paren-newline": ["error", "consistent"],
|
|
44
|
-
"function-call-argument-newline": ["error", "consistent"],
|
|
45
|
-
"max-len": ["warn", { code: 250, ignoreStrings: true, ignoreTemplateLiterals: true, ignoreComments: true, ignoreUrls: true, ignoreRegExpLiterals: true }]
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
];
|
package/scripts/build-cjs.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = path.dirname(__filename);
|
|
7
|
-
|
|
8
|
-
async function buildCjs() {
|
|
9
|
-
try {
|
|
10
|
-
const distDir = path.join(__dirname, '..', 'dist');
|
|
11
|
-
|
|
12
|
-
// Read the ES module index
|
|
13
|
-
const esmContent = await fs.readFile(path.join(distDir, 'index.js'), 'utf8');
|
|
14
|
-
|
|
15
|
-
// Convert ES module syntax to CommonJS
|
|
16
|
-
let cjsContent = esmContent
|
|
17
|
-
.replace(/export \* from "(.+?)";/g, 'Object.assign(module.exports, require("$1"));')
|
|
18
|
-
.replace(/export \{ (.+?) \} from "(.+?)";/g, (match, exports, from) => {
|
|
19
|
-
const exportList = exports.split(',').map(e => e.trim());
|
|
20
|
-
return exportList.map(exp => `module.exports.${exp} = require("${from}").${exp};`).join('\n');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Write CommonJS version
|
|
24
|
-
await fs.writeFile(path.join(distDir, 'index.cjs'), cjsContent);
|
|
25
|
-
|
|
26
|
-
console.log('CommonJS build created successfully');
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error('Error building CommonJS version:', error);
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
buildCjs();
|
package/src/ApiHelper.ts
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { ApiConfig, RolePermissionInterface, ApiListType } from "./interfaces/index.js";
|
|
2
|
-
import { ErrorHelper } from "./ErrorHelper.js";
|
|
3
|
-
|
|
4
|
-
// Global singleton pattern to ensure single instance across all packages
|
|
5
|
-
declare global {
|
|
6
|
-
interface Window {
|
|
7
|
-
__CHURCHAPPS_API_HELPER__?: ApiHelperClass;
|
|
8
|
-
}
|
|
9
|
-
var __CHURCHAPPS_API_HELPER__: ApiHelperClass | undefined;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
class ApiHelperClass {
|
|
13
|
-
|
|
14
|
-
apiConfigs: ApiConfig[] = [];
|
|
15
|
-
isAuthenticated = false;
|
|
16
|
-
onRequest: (url:string, requestOptions:any) => void;
|
|
17
|
-
onError: (url:string, requestOptions:any, error: any) => void;
|
|
18
|
-
|
|
19
|
-
getConfig(keyName: string) {
|
|
20
|
-
let result: ApiConfig = null;
|
|
21
|
-
this.apiConfigs.forEach(config => { if (config.keyName === keyName) result = config; });
|
|
22
|
-
//if (result === null) throw new Error("Unconfigured API: " + keyName);
|
|
23
|
-
return result;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
setDefaultPermissions(jwt: string) {
|
|
27
|
-
this.apiConfigs.forEach(config => {
|
|
28
|
-
config.jwt = jwt;
|
|
29
|
-
config.permissions = [];
|
|
30
|
-
});
|
|
31
|
-
this.isAuthenticated = true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
setPermissions(keyName: string, jwt: string, permissions: RolePermissionInterface[]) {
|
|
35
|
-
this.apiConfigs.forEach(config => {
|
|
36
|
-
if (config.keyName === keyName) {
|
|
37
|
-
config.jwt = jwt;
|
|
38
|
-
config.permissions = permissions;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
this.isAuthenticated = true;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
clearPermissions() {
|
|
45
|
-
this.apiConfigs.forEach(config => { config.jwt = ""; config.permissions = []; });
|
|
46
|
-
this.isAuthenticated = false;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async get(path: string, apiName: ApiListType) {
|
|
50
|
-
const config = this.getConfig(apiName);
|
|
51
|
-
if (!config) throw new Error(`API configuration not found: ${apiName}`);
|
|
52
|
-
const requestOptions = { method: "GET", headers: { Authorization: "Bearer " + config.jwt } };
|
|
53
|
-
return await this.fetchWithErrorHandling(config.url + path, requestOptions);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async getAnonymous(path: string, apiName: ApiListType) {
|
|
57
|
-
const config = this.getConfig(apiName);
|
|
58
|
-
if (!config) throw new Error(`API configuration not found: ${apiName}`);
|
|
59
|
-
const requestOptions = { method: "GET" };
|
|
60
|
-
return await this.fetchWithErrorHandling(config.url + path, requestOptions);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async post(path: string, data: any[] | {}, apiName: ApiListType) {
|
|
64
|
-
const config = this.getConfig(apiName);
|
|
65
|
-
if (!config) throw new Error(`API configuration not found: ${apiName}`);
|
|
66
|
-
const requestOptions = {
|
|
67
|
-
method: "POST",
|
|
68
|
-
headers: { Authorization: "Bearer " + config.jwt, "Content-Type": "application/json" },
|
|
69
|
-
body: JSON.stringify(data)
|
|
70
|
-
};
|
|
71
|
-
return await this.fetchWithErrorHandling(config.url + path, requestOptions);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async patch(path: string, data: any[] | {}, apiName: ApiListType) {
|
|
75
|
-
const config = this.getConfig(apiName);
|
|
76
|
-
if (!config) throw new Error(`API configuration not found: ${apiName}`);
|
|
77
|
-
const requestOptions = {
|
|
78
|
-
method: "PATCH",
|
|
79
|
-
headers: { Authorization: "Bearer " + config.jwt, "Content-Type": "application/json" },
|
|
80
|
-
body: JSON.stringify(data)
|
|
81
|
-
};
|
|
82
|
-
return await this.fetchWithErrorHandling(config.url + path, requestOptions);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async delete(path: string, apiName: ApiListType) {
|
|
86
|
-
const config = this.getConfig(apiName);
|
|
87
|
-
if (!config) throw new Error(`API configuration not found: ${apiName}`);
|
|
88
|
-
const requestOptions = {
|
|
89
|
-
method: "DELETE",
|
|
90
|
-
headers: { Authorization: "Bearer " + config.jwt }
|
|
91
|
-
};
|
|
92
|
-
if (this.onRequest) this.onRequest(config.url + path, requestOptions);
|
|
93
|
-
try {
|
|
94
|
-
const response = await fetch(config.url + path, requestOptions);
|
|
95
|
-
if (!response.ok) await this.throwApiError(response);
|
|
96
|
-
} catch (e) {
|
|
97
|
-
if (this.onError) this.onError(config.url + path, requestOptions, e);
|
|
98
|
-
throw (e);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async postAnonymous(path: string, data: any[] | {}, apiName: ApiListType) {
|
|
103
|
-
const config = this.getConfig(apiName);
|
|
104
|
-
if (!config) throw new Error(`API configuration not found: ${apiName}`);
|
|
105
|
-
const requestOptions = {
|
|
106
|
-
method: "POST",
|
|
107
|
-
headers: { "Content-Type": "application/json" },
|
|
108
|
-
body: JSON.stringify(data)
|
|
109
|
-
};
|
|
110
|
-
return await this.fetchWithErrorHandling(config.url + path, requestOptions);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async fetchWithErrorHandling(url: string, requestOptions: any) {
|
|
114
|
-
if (this.onRequest) this.onRequest(url, requestOptions);
|
|
115
|
-
try {
|
|
116
|
-
const response = await fetch(url, requestOptions);
|
|
117
|
-
if (!response.ok) await this.throwApiError(response);
|
|
118
|
-
else {
|
|
119
|
-
if (response.status !== 204 ) {
|
|
120
|
-
return response.json();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
} catch (e) {
|
|
124
|
-
throw (e);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
private async throwApiError(response: Response) {
|
|
129
|
-
let msg = response.statusText;
|
|
130
|
-
try {
|
|
131
|
-
msg = await response.text();
|
|
132
|
-
} catch {}
|
|
133
|
-
try {
|
|
134
|
-
const json = await response.json();
|
|
135
|
-
msg = json.errors[0];
|
|
136
|
-
} catch { }
|
|
137
|
-
ErrorHelper.logError(response.status.toString(), response.url, msg);
|
|
138
|
-
throw new Error(msg || "Error");
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Force singleton with immediate global assignment
|
|
144
|
-
const getGlobalObject = () => {
|
|
145
|
-
if (typeof window !== "undefined") return window;
|
|
146
|
-
if (typeof global !== "undefined") return global;
|
|
147
|
-
if (typeof globalThis !== "undefined") return globalThis;
|
|
148
|
-
return {};
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
// Get or create singleton immediately - FORCE SINGLE INSTANCE
|
|
152
|
-
const ensureSingleton = () => {
|
|
153
|
-
const globalObj = getGlobalObject() as any;
|
|
154
|
-
|
|
155
|
-
// Use a more unique key to avoid conflicts
|
|
156
|
-
const SINGLETON_KEY = "__CHURCHAPPS_API_HELPER_SINGLETON__";
|
|
157
|
-
|
|
158
|
-
if (!globalObj[SINGLETON_KEY]) {
|
|
159
|
-
globalObj[SINGLETON_KEY] = new ApiHelperClass();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return globalObj[SINGLETON_KEY];
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// Export the singleton instance
|
|
166
|
-
export const ApiHelper = ensureSingleton();
|
|
167
|
-
|
|
168
|
-
// Also export the class for type usage
|
|
169
|
-
export type { ApiHelperClass };
|
package/src/AppearanceHelper.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export interface AppearanceInterface { primaryColor?: string, primaryContrast?: string, secondaryColor?: string, secondaryContrast?: string, logoLight?: string, logoDark?: string, favicon_400x400?: string, favicon_16x16?: string }
|
|
3
|
-
|
|
4
|
-
export class AppearanceHelper {
|
|
5
|
-
|
|
6
|
-
public static getLogoDark(appearanceSettings: AppearanceInterface, defaultLogo: string) {
|
|
7
|
-
return (appearanceSettings?.logoDark) ? appearanceSettings.logoDark : defaultLogo;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public static getLogoLight(appearanceSettings: AppearanceInterface, defaultLogo: string) {
|
|
11
|
-
return (appearanceSettings?.logoLight) ? appearanceSettings.logoLight : defaultLogo;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public static getFavicon(appearanceSettings: AppearanceInterface, size: "400" | "16") {
|
|
15
|
-
if (size === "400") {
|
|
16
|
-
return appearanceSettings?.favicon_400x400;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (size === "16") {
|
|
20
|
-
return appearanceSettings?.favicon_16x16;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public static getLogo(appearanceSettings: AppearanceInterface, defaultLogoLight: string, defaultLogoDark: string, backgroundColor: string) {
|
|
27
|
-
const isDark = (appearanceSettings.logoDark) ? this.isDark(backgroundColor) : false;
|
|
28
|
-
if (isDark) return this.getLogoDark(appearanceSettings, defaultLogoDark);
|
|
29
|
-
else return this.getLogoLight(appearanceSettings, defaultLogoLight);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private static isDark(backgroundColor: string) {
|
|
33
|
-
let valid = false;
|
|
34
|
-
let r = 0;
|
|
35
|
-
let g = 0;
|
|
36
|
-
let b = 0;
|
|
37
|
-
|
|
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
|
-
valid = true;
|
|
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
|
-
valid = true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!valid) return false;
|
|
51
|
-
else {
|
|
52
|
-
//HSP brightness formula. Some colors have a bigger impact on our perceived brightness than others.
|
|
53
|
-
const rWeight = .299 * Math.pow(r, 2);
|
|
54
|
-
const gWeight = .587 * Math.pow(g, 2);
|
|
55
|
-
const bWeight = .114 * Math.pow(b, 2);
|
|
56
|
-
const brightness = Math.sqrt(rWeight + gWeight + bWeight);
|
|
57
|
-
//return brightness < 128; //
|
|
58
|
-
return brightness < 156;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private static getHexValue(hex: string) {
|
|
64
|
-
let result = parseInt(hex, 16);
|
|
65
|
-
if (hex.length === 1) result = result * 16;
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
}
|
package/src/ArrayHelper.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { UniqueIdHelper } from "./UniqueIdHelper.js";
|
|
2
|
-
|
|
3
|
-
export class ArrayHelper {
|
|
4
|
-
static getIds(array: any[], propertyName: string) {
|
|
5
|
-
const result: string[] = [];
|
|
6
|
-
for (const item of array) {
|
|
7
|
-
const id = item[propertyName]?.toString();
|
|
8
|
-
if (!UniqueIdHelper.isMissing(id) && result.indexOf(id) === -1) result.push(id);
|
|
9
|
-
}
|
|
10
|
-
return result;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static sortBy(array: any[], propertyName: string, descending: boolean = false) {
|
|
14
|
-
array.sort((a, b) => {
|
|
15
|
-
const valA = a[propertyName];
|
|
16
|
-
const valB = b[propertyName];
|
|
17
|
-
if (valA < valB) return descending ? 1 : -1;
|
|
18
|
-
else return descending ? -1 : 1;
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static getIndex(array: any[], propertyName: string, value: any) {
|
|
23
|
-
for (let i = 0; i < array.length; i++) {
|
|
24
|
-
const item = array[i];
|
|
25
|
-
if (ArrayHelper.compare(item, propertyName, value)) return i;
|
|
26
|
-
}
|
|
27
|
-
return -1;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static getOne(array: any[], propertyName: string, value: any) {
|
|
31
|
-
for (const item of array || []) if (ArrayHelper.compare(item, propertyName, value)) return item;
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static getAll(array: any[], propertyName: string, value: any) {
|
|
36
|
-
const result: any[] = [];
|
|
37
|
-
for (const item of array || []) {
|
|
38
|
-
if (ArrayHelper.compare(item, propertyName, value)) result.push(item);
|
|
39
|
-
}
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static getAllArray(array: any[], propertyName: string, values: any[]) {
|
|
44
|
-
const result: any[] = [];
|
|
45
|
-
for (const item of array || []) if (values.indexOf(item[propertyName]) > -1) result.push(item);
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private static compare(item: any, propertyName: string, value: any) {
|
|
50
|
-
const propChain = propertyName.split(".");
|
|
51
|
-
if (propChain.length === 1) return item[propertyName] === value;
|
|
52
|
-
else {
|
|
53
|
-
let obj = item;
|
|
54
|
-
for (let i = 0; i < propChain.length - 1; i++) {
|
|
55
|
-
if (obj && obj[propChain[i]] !== undefined) obj = obj[propChain[i]];
|
|
56
|
-
else return false;
|
|
57
|
-
}
|
|
58
|
-
return obj[propChain[propChain.length - 1]] === value;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
static getUniqueValues(array: any[], propertyName: string) {
|
|
63
|
-
const result: any[] = [];
|
|
64
|
-
|
|
65
|
-
for (const item of array) {
|
|
66
|
-
const val = (propertyName.indexOf(".") === -1) ? item[propertyName] : this.getDeepValue(item, propertyName);
|
|
67
|
-
if (result.indexOf(val) === -1) result.push(val);
|
|
68
|
-
}
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
static getUnique(array: any[]) {
|
|
73
|
-
const result: any[] = [];
|
|
74
|
-
const jsonList: string[] = [];
|
|
75
|
-
for (const item of array) {
|
|
76
|
-
const json = JSON.stringify(item);
|
|
77
|
-
if (jsonList.indexOf(json) === -1) {
|
|
78
|
-
result.push(item);
|
|
79
|
-
jsonList.push(json);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
static getAllOperatorArray(array: any[], propertyName: string, values: any[], operator: string, dataType = "string") {
|
|
86
|
-
const result: any[] = [];
|
|
87
|
-
values.forEach(v => {
|
|
88
|
-
const filtered = this.getAllOperator(array, propertyName, v, operator.replace("notIn", "notEqual").replace("in", "equals").replace("donatedToAny", "equals").replace("donatedTo", "equals").replace("attendedCampus", "equals").replace("attendedAny", "equals").replace("attendedServiceTime", "equals").replace("attendedService", "equals").replace("attendedGroup", "equals"), dataType);
|
|
89
|
-
filtered.forEach(f => result.push(f));
|
|
90
|
-
});
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
static getAllOperator(array: any[], propertyName: string, value: any, operator: string, dataType = "string") {
|
|
95
|
-
const result: any[] = [];
|
|
96
|
-
for (const item of array) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
let propVal = item[propertyName] || "";
|
|
100
|
-
let compVal = value || "";
|
|
101
|
-
if (dataType === "number") {
|
|
102
|
-
propVal = parseFloat(propVal);
|
|
103
|
-
compVal = parseFloat(compVal);
|
|
104
|
-
} else if (dataType === "string") {
|
|
105
|
-
propVal = propVal.toLowerCase();
|
|
106
|
-
compVal = compVal.toLowerCase();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
switch (operator) {
|
|
110
|
-
case "equals": if (propVal === compVal) result.push(item); break;
|
|
111
|
-
case "startsWith": if (propVal.indexOf(compVal) === 0) result.push(item); break;
|
|
112
|
-
case "endsWith": if (propVal.indexOf(compVal) === propVal.length - compVal.length) result.push(item); break;
|
|
113
|
-
case "contains": if (propVal.indexOf(compVal) > -1) result.push(item); break;
|
|
114
|
-
case "greaterThan": if (propVal > compVal) result.push(item); break;
|
|
115
|
-
case "greaterThanEqual": if (propVal >= compVal) result.push(item); break;
|
|
116
|
-
case "lessThan": if (propVal < compVal) result.push(item); break;
|
|
117
|
-
case "lessThanEqual": if (propVal <= compVal) result.push(item); break;
|
|
118
|
-
case "notEqual": if (propVal !== compVal) result.push(item); break;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
static getDeepValue(item: any, propertyName: string) {
|
|
125
|
-
const propertyNames = propertyName.split(".");
|
|
126
|
-
let result: any = item;
|
|
127
|
-
propertyNames.forEach(name => {
|
|
128
|
-
if (result != null) result = result[name];
|
|
129
|
-
});
|
|
130
|
-
return result;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
static fillArray(contents: string, length: number) {
|
|
134
|
-
const result = [];
|
|
135
|
-
for (let i = 0; i < length; i++) result.push(contents);
|
|
136
|
-
return result;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
}
|