need4deed-sdk 0.0.7 → 0.0.11

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,6 @@
1
+ export declare enum Endpoint {
2
+ OPPORTUNITY = "/opportunity",
3
+ EVENT = "/event",
4
+ TESTIMONIAL = "/testimonial",
5
+ VOLUNTEER = "/volunteer"
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Endpoint = void 0;
4
+ var Endpoint;
5
+ (function (Endpoint) {
6
+ Endpoint["OPPORTUNITY"] = "/opportunity";
7
+ Endpoint["EVENT"] = "/event";
8
+ Endpoint["TESTIMONIAL"] = "/testimonial";
9
+ Endpoint["VOLUNTEER"] = "/volunteer";
10
+ })(Endpoint || (exports.Endpoint = Endpoint = {}));
@@ -0,0 +1 @@
1
+ export * from "./endpoints";
@@ -0,0 +1,17 @@
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("./endpoints"), exports);
@@ -0,0 +1 @@
1
+ export * from "./utils";
@@ -0,0 +1,17 @@
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("./utils"), exports);
@@ -0,0 +1,13 @@
1
+ export declare function fetchFn<R, D = R>({ url, options, fnDTO, }: {
2
+ url: string;
3
+ options?: RequestInit;
4
+ fnDTO?: (data: R) => D;
5
+ }): Promise<D>;
6
+ /**
7
+ * Converts the keys of an object from snake_case to camelCase.
8
+ * Handles nested objects and arrays recursively.
9
+ *
10
+ * @param snakeCaseObject The object with keys in snake_case.
11
+ * @returns A new object with keys converted to camelCase.
12
+ */
13
+ export declare function snakeToCamelCase(snakeCaseObject: any): any;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchFn = fetchFn;
4
+ exports.snakeToCamelCase = snakeToCamelCase;
5
+ function fetchFn({ url, options, fnDTO, }) {
6
+ return fetch(url, options)
7
+ .then((response) => {
8
+ if (response.ok)
9
+ return response.json();
10
+ throw new Error(response.statusText);
11
+ })
12
+ .then((data) => {
13
+ return fnDTO ? fnDTO(data) : data;
14
+ });
15
+ }
16
+ /**
17
+ * Converts the keys of an object from snake_case to camelCase.
18
+ * Handles nested objects and arrays recursively.
19
+ *
20
+ * @param snakeCaseObject The object with keys in snake_case.
21
+ * @returns A new object with keys converted to camelCase.
22
+ */
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ function snakeToCamelCase(snakeCaseObject) {
25
+ if (snakeCaseObject === null || typeof snakeCaseObject !== "object") {
26
+ return snakeCaseObject;
27
+ }
28
+ // Handle arrays
29
+ if (Array.isArray(snakeCaseObject)) {
30
+ return snakeCaseObject.map((item) => snakeToCamelCase(item));
31
+ }
32
+ // Handle objects
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ const camelCaseObject = {};
35
+ Object.keys(snakeCaseObject).forEach((key) => {
36
+ if (Object.prototype.hasOwnProperty.call(snakeCaseObject, key)) {
37
+ let camelCaseKey;
38
+ // skip if all caps
39
+ if (key.match(/^[A-Z0-9_]+$/)) {
40
+ camelCaseKey = key;
41
+ }
42
+ else {
43
+ // Convert snake_case key to camelCase
44
+ const parts = key.split("_");
45
+ camelCaseKey =
46
+ parts[0] +
47
+ parts
48
+ .slice(1)
49
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
50
+ .join("");
51
+ }
52
+ // Recursively convert nested values
53
+ camelCaseObject[camelCaseKey] = snakeToCamelCase(snakeCaseObject[key]);
54
+ }
55
+ });
56
+ return camelCaseObject;
57
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./constants";
2
+ export * from "./core";
3
+ export * from "./types";
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
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("./constants"), exports);
18
+ __exportStar(require("./core"), exports);
19
+ __exportStar(require("./types"), exports);