@churchapps/helpers 1.0.39 → 1.0.41

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 (48) hide show
  1. package/dist/ApiHelper.d.ts +25 -17
  2. package/dist/ApiHelper.d.ts.map +1 -1
  3. package/dist/ApiHelper.js +37 -21
  4. package/dist/ApiHelper.js.map +1 -1
  5. package/dist/AppearanceHelper.js +1 -5
  6. package/dist/AppearanceHelper.js.map +1 -1
  7. package/dist/ArrayHelper.js +3 -7
  8. package/dist/ArrayHelper.js.map +1 -1
  9. package/dist/CommonEnvironmentHelper.js +74 -80
  10. package/dist/CommonEnvironmentHelper.js.map +1 -1
  11. package/dist/CurrencyHelper.js +1 -5
  12. package/dist/CurrencyHelper.js.map +1 -1
  13. package/dist/DateHelper.js +8 -15
  14. package/dist/DateHelper.js.map +1 -1
  15. package/dist/DonationHelper.js +1 -5
  16. package/dist/DonationHelper.js.map +1 -1
  17. package/dist/ErrorHelper.js +28 -32
  18. package/dist/ErrorHelper.js.map +1 -1
  19. package/dist/EventHelper.js +37 -41
  20. package/dist/EventHelper.js.map +1 -1
  21. package/dist/FileHelper.js +37 -41
  22. package/dist/FileHelper.js.map +1 -1
  23. package/dist/PersonHelper.js +3 -7
  24. package/dist/PersonHelper.js.map +1 -1
  25. package/dist/UniqueIdHelper.js +8 -12
  26. package/dist/UniqueIdHelper.js.map +1 -1
  27. package/dist/UserHelper.js +38 -40
  28. package/dist/UserHelper.js.map +1 -1
  29. package/dist/index.js +14 -44
  30. package/dist/index.js.map +1 -1
  31. package/dist/interfaces/Access.js +1 -2
  32. package/dist/interfaces/Attendance.js +1 -2
  33. package/dist/interfaces/Content.js +1 -2
  34. package/dist/interfaces/Doing.js +1 -2
  35. package/dist/interfaces/Donation.js +10 -5
  36. package/dist/interfaces/Donation.js.map +1 -1
  37. package/dist/interfaces/Error.js +1 -2
  38. package/dist/interfaces/Membership.js +1 -2
  39. package/dist/interfaces/Messaging.js +1 -2
  40. package/dist/interfaces/Permissions.js +83 -87
  41. package/dist/interfaces/Permissions.js.map +1 -1
  42. package/dist/interfaces/Reporting.js +1 -2
  43. package/dist/interfaces/UserContextInterface.js +1 -2
  44. package/dist/interfaces/index.js +11 -27
  45. package/dist/interfaces/index.js.map +1 -1
  46. package/package.json +10 -7
  47. package/src/ApiHelper.ts +51 -17
  48. package/tsconfig.json +3 -3
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=Membership.js.map
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=Messaging.js.map
@@ -1,94 +1,90 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Permissions = void 0;
4
- class Permissions {
5
- }
6
- exports.Permissions = Permissions;
7
- Permissions.attendanceApi = {
8
- attendance: {
9
- view: { api: "AttendanceApi", contentType: "Attendance", action: "View" },
10
- viewSummary: {
11
- api: "AttendanceApi",
12
- contentType: "Attendance",
13
- action: "View Summary"
1
+ export class Permissions {
2
+ static attendanceApi = {
3
+ attendance: {
4
+ view: { api: "AttendanceApi", contentType: "Attendance", action: "View" },
5
+ viewSummary: {
6
+ api: "AttendanceApi",
7
+ contentType: "Attendance",
8
+ action: "View Summary"
9
+ },
10
+ edit: { api: "AttendanceApi", contentType: "Attendance", action: "Edit" }
11
+ },
12
+ services: {
13
+ edit: { api: "AttendanceApi", contentType: "Services", action: "Edit" }
14
+ }
15
+ };
16
+ static membershipApi = {
17
+ roles: {
18
+ view: { api: "MembershipApi", contentType: "Roles", action: "View" },
19
+ edit: { api: "MembershipApi", contentType: "Roles", action: "Edit" }
20
+ },
21
+ settings: {
22
+ edit: { api: "MembershipApi", contentType: "Settings", action: "Edit" }
23
+ },
24
+ server: {
25
+ admin: { api: "MembershipApi", contentType: "Server", action: "Admin" }
26
+ },
27
+ forms: {
28
+ admin: { api: "MembershipApi", contentType: "Forms", action: "Admin" },
29
+ edit: { api: "MembershipApi", contentType: "Forms", action: "Edit" }
14
30
  },
15
- edit: { api: "AttendanceApi", contentType: "Attendance", action: "Edit" }
16
- },
17
- services: {
18
- edit: { api: "AttendanceApi", contentType: "Services", action: "Edit" }
19
- }
20
- };
21
- Permissions.membershipApi = {
22
- roles: {
23
- view: { api: "MembershipApi", contentType: "Roles", action: "View" },
24
- edit: { api: "MembershipApi", contentType: "Roles", action: "Edit" }
25
- },
26
- settings: {
27
- edit: { api: "MembershipApi", contentType: "Settings", action: "Edit" }
28
- },
29
- server: {
30
- admin: { api: "MembershipApi", contentType: "Server", action: "Admin" }
31
- },
32
- forms: {
33
- admin: { api: "MembershipApi", contentType: "Forms", action: "Admin" },
34
- edit: { api: "MembershipApi", contentType: "Forms", action: "Edit" }
35
- },
36
- groups: {
37
- edit: { api: "MembershipApi", contentType: "Groups", action: "Edit" }
38
- },
39
- people: {
40
- view: { api: "MembershipApi", contentType: "People", action: "View" },
41
- viewMembers: {
42
- api: "MembershipApi",
43
- contentType: "People",
44
- action: "View Members"
31
+ groups: {
32
+ edit: { api: "MembershipApi", contentType: "Groups", action: "Edit" }
45
33
  },
46
- edit: { api: "MembershipApi", contentType: "People", action: "Edit" }
47
- },
48
- plans: {
49
- edit: { api: "MembershipApi", contentType: "Plans", action: "Edit" }
50
- },
51
- groupMembers: {
52
- edit: {
53
- api: "MembershipApi",
54
- contentType: "Group Members",
55
- action: "Edit"
34
+ people: {
35
+ view: { api: "MembershipApi", contentType: "People", action: "View" },
36
+ viewMembers: {
37
+ api: "MembershipApi",
38
+ contentType: "People",
39
+ action: "View Members"
40
+ },
41
+ edit: { api: "MembershipApi", contentType: "People", action: "Edit" }
56
42
  },
57
- view: {
58
- api: "MembershipApi",
59
- contentType: "Group Members",
60
- action: "View"
43
+ plans: {
44
+ edit: { api: "MembershipApi", contentType: "Plans", action: "Edit" }
45
+ },
46
+ groupMembers: {
47
+ edit: {
48
+ api: "MembershipApi",
49
+ contentType: "Group Members",
50
+ action: "Edit"
51
+ },
52
+ view: {
53
+ api: "MembershipApi",
54
+ contentType: "Group Members",
55
+ action: "View"
56
+ }
61
57
  }
62
- }
63
- };
64
- Permissions.givingApi = {
65
- donations: {
66
- viewSummary: {
67
- api: "GivingApi",
68
- contentType: "Donations",
69
- action: "View Summary"
58
+ };
59
+ static givingApi = {
60
+ donations: {
61
+ viewSummary: {
62
+ api: "GivingApi",
63
+ contentType: "Donations",
64
+ action: "View Summary"
65
+ },
66
+ view: { api: "GivingApi", contentType: "Donations", action: "View" },
67
+ edit: { api: "GivingApi", contentType: "Donations", action: "Edit" }
70
68
  },
71
- view: { api: "GivingApi", contentType: "Donations", action: "View" },
72
- edit: { api: "GivingApi", contentType: "Donations", action: "Edit" }
73
- },
74
- settings: {
75
- view: { api: "GivingApi", contentType: "Settings", action: "View" },
76
- edit: { api: "GivingApi", contentType: "Settings", action: "Edit" }
77
- }
78
- };
79
- Permissions.contentApi = {
80
- chat: {
81
- host: { api: "ContentApi", contentType: "Chat", action: "Host" }
82
- },
83
- content: {
84
- edit: { api: "ContentApi", contentType: "Content", action: "Edit" }
85
- },
86
- streamingServices: {
87
- edit: {
88
- api: "ContentApi",
89
- contentType: "StreamingServices",
90
- action: "Edit"
69
+ settings: {
70
+ view: { api: "GivingApi", contentType: "Settings", action: "View" },
71
+ edit: { api: "GivingApi", contentType: "Settings", action: "Edit" }
91
72
  }
92
- }
93
- };
73
+ };
74
+ static contentApi = {
75
+ chat: {
76
+ host: { api: "ContentApi", contentType: "Chat", action: "Host" }
77
+ },
78
+ content: {
79
+ edit: { api: "ContentApi", contentType: "Content", action: "Edit" }
80
+ },
81
+ streamingServices: {
82
+ edit: {
83
+ api: "ContentApi",
84
+ contentType: "StreamingServices",
85
+ action: "Edit"
86
+ }
87
+ }
88
+ };
89
+ }
94
90
  //# sourceMappingURL=Permissions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Perm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AAG,EAAE,eAAe;gBACpB,WAAW,EAAE,eAAe;gBAC5B,MAAM,EAAE,MAAM;aACf;SACF;KACF,CAAC;IAEF,MAAM,CAAC,SAAS,GAAG;QACjB,SAAS,EAAE;YACT,WAAW,EAAE;gBACX,GAAG,EAAE,WAAW;gBAChB,WAAW,EAAE,WAAW;gBACxB,MAAM,EAAE,cAAc;aACvB;YACD,IAAI,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE;YACpE,IAAI,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE;SACrE;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE;YACnE,IAAI,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE;SACpE;KACF,CAAC;IAEF,MAAM,CAAC,UAAU,GAAG;QAClB,IAAI,EAAE;YACJ,IAAI,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;SACjE;QACD,OAAO,EAAE;YACP,IAAI,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE;SACpE;QACD,iBAAiB,EAAE;YACjB,IAAI,EAAE;gBACJ,GAAG,EAAE,YAAY;gBACjB,WAAW,EAAE,mBAAmB;gBAChC,MAAM,EAAE,MAAM;aACf;SACF;KACF,CAAC"}
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=Reporting.js.map
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=UserContextInterface.js.map
@@ -1,29 +1,13 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Error"), exports);
18
- __exportStar(require("./UserContextInterface"), exports);
19
- __exportStar(require("./Permissions"), exports);
1
+ export * from "./Error";
2
+ export * from "./UserContextInterface";
3
+ export * from "./Permissions";
20
4
  // API interfaces
21
- __exportStar(require("./Access"), exports);
22
- __exportStar(require("./Attendance"), exports);
23
- __exportStar(require("./Content"), exports);
24
- __exportStar(require("./Doing"), exports);
25
- __exportStar(require("./Donation"), exports);
26
- __exportStar(require("./Membership"), exports);
27
- __exportStar(require("./Messaging"), exports);
28
- __exportStar(require("./Reporting"), exports);
5
+ export * from "./Access";
6
+ export * from "./Attendance";
7
+ export * from "./Content";
8
+ export * from "./Doing";
9
+ export * from "./Donation";
10
+ export * from "./Membership";
11
+ export * from "./Messaging";
12
+ export * from "./Reporting";
29
13
  //# sourceMappingURL=index.js.map
@@ -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,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAE9B,iBAAiB;AACjB,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"}
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@churchapps/helpers",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "Library of helper functions not specific to any one ChurchApps project or framework.",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
6
9
  "scripts": {
7
10
  "test": "echo \"Error: no test specified\" && exit 1",
8
11
  "clean": "rimraf dist",
@@ -30,14 +33,14 @@
30
33
  "npm": ">=10.0.0"
31
34
  },
32
35
  "devDependencies": {
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",
36
+ "@types/node": "^24.0.10",
37
+ "@typescript-eslint/eslint-plugin": "^8.35.1",
38
+ "@typescript-eslint/parser": "^8.35.1",
39
+ "eslint": "^9.30.1",
37
40
  "eslint-config-prettier": "^10.1.5",
38
- "eslint-plugin-prettier": "^5.5.0",
41
+ "eslint-plugin-prettier": "^5.5.1",
39
42
  "npm-run-all2": "^8.0.4",
40
- "prettier": "^3.6.0",
43
+ "prettier": "^3.6.2",
41
44
  "rimraf": "^6.0.1",
42
45
  "typescript": "^5.8.3"
43
46
  },
package/src/ApiHelper.ts CHANGED
@@ -1,21 +1,29 @@
1
1
  import { ApiConfig, RolePermissionInterface, ApiListType } from "./interfaces";
2
2
  import { ErrorHelper } from "./ErrorHelper";
3
3
 
4
- export class ApiHelper {
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 {
5
13
 
6
- static apiConfigs: ApiConfig[] = [];
7
- static isAuthenticated = false;
8
- static onRequest: (url:string, requestOptions:any) => void;
9
- static onError: (url:string, requestOptions:any, error: any) => void;
14
+ apiConfigs: ApiConfig[] = [];
15
+ isAuthenticated = false;
16
+ onRequest: (url:string, requestOptions:any) => void;
17
+ onError: (url:string, requestOptions:any, error: any) => void;
10
18
 
11
- static getConfig(keyName: string) {
19
+ getConfig(keyName: string) {
12
20
  let result: ApiConfig = null;
13
21
  this.apiConfigs.forEach(config => { if (config.keyName === keyName) result = config });
14
22
  //if (result === null) throw new Error("Unconfigured API: " + keyName);
15
23
  return result;
16
24
  }
17
25
 
18
- static setDefaultPermissions(jwt: string) {
26
+ setDefaultPermissions(jwt: string) {
19
27
  this.apiConfigs.forEach(config => {
20
28
  config.jwt = jwt;
21
29
  config.permissions = [];
@@ -23,7 +31,7 @@ export class ApiHelper {
23
31
  this.isAuthenticated = true;
24
32
  }
25
33
 
26
- static setPermissions(keyName: string, jwt: string, permissions: RolePermissionInterface[]) {
34
+ setPermissions(keyName: string, jwt: string, permissions: RolePermissionInterface[]) {
27
35
  this.apiConfigs.forEach(config => {
28
36
  if (config.keyName === keyName) {
29
37
  config.jwt = jwt;
@@ -33,25 +41,25 @@ export class ApiHelper {
33
41
  this.isAuthenticated = true;
34
42
  }
35
43
 
36
- static clearPermissions() {
44
+ clearPermissions() {
37
45
  this.apiConfigs.forEach(config => { config.jwt = ""; config.permissions = []; });
38
46
  this.isAuthenticated = false;
39
47
  }
40
48
 
41
- static async get(path: string, apiName: ApiListType) {
49
+ async get(path: string, apiName: ApiListType) {
42
50
  const config = this.getConfig(apiName);
43
51
  if (!config) throw new Error(`API configuration not found: ${apiName}`);
44
52
  const requestOptions = { method: "GET", headers: { Authorization: "Bearer " + config.jwt } };
45
53
  return await this.fetchWithErrorHandling(config.url + path, requestOptions);
46
54
  }
47
55
 
48
- static async getAnonymous(path: string, apiName: ApiListType) {
56
+ async getAnonymous(path: string, apiName: ApiListType) {
49
57
  const config = this.getConfig(apiName);
50
58
  const requestOptions = { method: "GET" };
51
59
  return await this.fetchWithErrorHandling(config.url + path, requestOptions);
52
60
  }
53
61
 
54
- static async post(path: string, data: any[] | {}, apiName: ApiListType) {
62
+ async post(path: string, data: any[] | {}, apiName: ApiListType) {
55
63
  const config = this.getConfig(apiName);
56
64
  if (!config) throw new Error(`API configuration not found: ${apiName}`);
57
65
  const requestOptions = {
@@ -62,7 +70,7 @@ export class ApiHelper {
62
70
  return await this.fetchWithErrorHandling(config.url + path, requestOptions);
63
71
  }
64
72
 
65
- static async patch(path: string, data: any[] | {}, apiName: ApiListType) {
73
+ async patch(path: string, data: any[] | {}, apiName: ApiListType) {
66
74
  const config = this.getConfig(apiName);
67
75
  if (!config) throw new Error(`API configuration not found: ${apiName}`);
68
76
  const requestOptions = {
@@ -73,7 +81,7 @@ export class ApiHelper {
73
81
  return await this.fetchWithErrorHandling(config.url + path, requestOptions);
74
82
  }
75
83
 
76
- static async delete(path: string, apiName: ApiListType) {
84
+ async delete(path: string, apiName: ApiListType) {
77
85
  const config = this.getConfig(apiName);
78
86
  if (!config) throw new Error(`API configuration not found: ${apiName}`);
79
87
  const requestOptions = {
@@ -91,7 +99,7 @@ export class ApiHelper {
91
99
  }
92
100
  }
93
101
 
94
- static async postAnonymous(path: string, data: any[] | {}, apiName: ApiListType) {
102
+ async postAnonymous(path: string, data: any[] | {}, apiName: ApiListType) {
95
103
  const config = this.getConfig(apiName);
96
104
  const requestOptions = {
97
105
  method: "POST",
@@ -101,7 +109,7 @@ export class ApiHelper {
101
109
  return await this.fetchWithErrorHandling(config.url + path, requestOptions);
102
110
  }
103
111
 
104
- static async fetchWithErrorHandling(url: string, requestOptions: any) {
112
+ async fetchWithErrorHandling(url: string, requestOptions: any) {
105
113
  if (this.onRequest) this.onRequest(url, requestOptions);
106
114
  try {
107
115
  const response = await fetch(url, requestOptions);
@@ -118,7 +126,7 @@ export class ApiHelper {
118
126
  }
119
127
  }
120
128
 
121
- private static async throwApiError(response: Response) {
129
+ private async throwApiError(response: Response) {
122
130
  let msg = response.statusText;
123
131
  try {
124
132
  msg = await response.text();
@@ -133,3 +141,29 @@ export class ApiHelper {
133
141
  }
134
142
 
135
143
  }
144
+
145
+ // Create singleton instance using global reference
146
+ function getApiHelperInstance(): ApiHelperClass {
147
+ // Determine global object (window in browser, global in Node.js)
148
+ const globalObj = (typeof window !== 'undefined' ? window :
149
+ typeof global !== 'undefined' ? global :
150
+ {}) as any;
151
+
152
+ // Create or return existing singleton instance
153
+ if (!globalObj.__CHURCHAPPS_API_HELPER__) {
154
+ globalObj.__CHURCHAPPS_API_HELPER__ = new ApiHelperClass();
155
+
156
+ // Add debug logging to track instance creation
157
+ if (typeof console !== 'undefined') {
158
+ console.log('ChurchApps ApiHelper singleton instance created');
159
+ }
160
+ }
161
+
162
+ return globalObj.__CHURCHAPPS_API_HELPER__;
163
+ }
164
+
165
+ // Export singleton instance
166
+ export const ApiHelper = getApiHelperInstance();
167
+
168
+ // Also export the class for type usage
169
+ export type { ApiHelperClass };
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES2020",
3
+ "target": "ES2022",
4
4
  "typeRoots": [
5
5
  "./types",
6
6
  "node_modules/@types"
@@ -8,7 +8,7 @@
8
8
  "lib": [
9
9
  "dom",
10
10
  "dom.iterable",
11
- "esnext"
11
+ "ES2022"
12
12
  ],
13
13
  "allowJs": true,
14
14
  "skipLibCheck": true,
@@ -16,7 +16,7 @@
16
16
  "allowSyntheticDefaultImports": true,
17
17
  "strict": false,
18
18
  "forceConsistentCasingInFileNames": true,
19
- "module": "commonjs",
19
+ "module": "ES2022",
20
20
  "moduleResolution": "node",
21
21
  "resolveJsonModule": true,
22
22
  "isolatedModules": true,