funuicss 3.6.17 → 3.6.19

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.
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- // import { useTheme } from "../ui/theme/theme"
3
2
  var __assign = (this && this.__assign) || function () {
4
3
  __assign = Object.assign || function(t) {
5
4
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -12,154 +11,7 @@ var __assign = (this && this.__assign) || function () {
12
11
  return __assign.apply(this, arguments);
13
12
  };
14
13
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getAvailableVariants = exports.hasComponentVariant = exports.useComponentConfiguration = exports.mergeComponentConfig = exports.getComponentConfig = void 0;
16
- // // utils/componentUtils.ts
17
- // // Type definitions
18
- // export interface ComponentProps {
19
- // [key: string]: any
20
- // }
21
- // export interface ComponentMetadata {
22
- // createdAt?: Date
23
- // updatedAt?: Date
24
- // isCustom?: boolean
25
- // baseVariant?: string
26
- // }
27
- // export interface ComponentVariant {
28
- // componentProps: ComponentProps
29
- // metadata?: ComponentMetadata
30
- // }
31
- // export interface ComponentConfig {
32
- // componentProps: ComponentProps
33
- // variantExists: boolean
34
- // actualVariant: string
35
- // availableVariants: string[]
36
- // metadata: ComponentMetadata
37
- // }
38
- // export interface ProjectData {
39
- // components?: {
40
- // [componentName: string]: {
41
- // [variantName: string]: ComponentVariant
42
- // }
43
- // }
44
- // }
45
- // export interface MergedConfig {
46
- // props: ComponentProps
47
- // variant: string
48
- // hasConfig: boolean
49
- // }
50
- // export interface UseComponentConfigReturn extends ComponentConfig {
51
- // mergeWithLocal: (localProps?: ComponentProps) => MergedConfig
52
- // getProp: <T = any>(propName: string, defaultValue?: T) => T
53
- // }
54
- // /**
55
- // * Universal component config getter
56
- // */
57
- // export const getComponentConfig = (
58
- // projectData: ProjectData | null | undefined,
59
- // componentName: string,
60
- // variantName: string = 'default'
61
- // ): ComponentConfig => {
62
- // if (!projectData?.components?.[componentName]) {
63
- // return {
64
- // componentProps: {},
65
- // variantExists: false,
66
- // actualVariant: variantName,
67
- // availableVariants: [],
68
- // metadata: {}
69
- // }
70
- // }
71
- // const component = projectData.components[componentName]
72
- // const availableVariants = Object.keys(component)
73
- // // Find the best variant match
74
- // let targetVariant = variantName
75
- // if (!availableVariants.includes(variantName)) {
76
- // if (availableVariants.includes('default')) {
77
- // targetVariant = 'default'
78
- // } else if (availableVariants.length > 0) {
79
- // targetVariant = availableVariants[0]
80
- // } else {
81
- // return {
82
- // componentProps: {},
83
- // variantExists: false,
84
- // actualVariant: variantName,
85
- // availableVariants: [],
86
- // metadata: {}
87
- // }
88
- // }
89
- // }
90
- // const variantData = component[targetVariant] || {}
91
- // return {
92
- // componentProps: variantData.componentProps || {},
93
- // variantExists: true,
94
- // actualVariant: targetVariant,
95
- // availableVariants,
96
- // metadata: variantData.metadata || {}
97
- // }
98
- // }
99
- // /**
100
- // * Merge component config with local props - only applies config if variant exists
101
- // */
102
- // export const mergeComponentConfig = (
103
- // config: ComponentConfig,
104
- // localProps: ComponentProps = {}
105
- // ): MergedConfig => {
106
- // // Only apply config if variant exists and has actual configuration
107
- // const hasValidConfig = config.variantExists && Object.keys(config.componentProps).length > 0
108
- // if (!hasValidConfig) {
109
- // return {
110
- // props: localProps,
111
- // variant: config.actualVariant,
112
- // hasConfig: false
113
- // }
114
- // }
115
- // return {
116
- // // Props: config overrides local only if variant exists
117
- // props: {
118
- // ...localProps,
119
- // ...config.componentProps
120
- // },
121
- // // Metadata
122
- // variant: config.actualVariant,
123
- // hasConfig: true
124
- // }
125
- // }
126
- // /**
127
- // * Hook for easy component config usage - only applies if variant is provided and exists
128
- // */
129
- // export const useComponentConfiguration = (
130
- // componentName: string,
131
- // variantName?: string // Make variantName optional
132
- // ): UseComponentConfigReturn => {
133
- // const { projectData } = useTheme()
134
- // // Only get config if variantName is provided
135
- // const config = variantName ? getComponentConfig(projectData, componentName, variantName) : {
136
- // componentProps: {},
137
- // variantExists: false,
138
- // actualVariant: '',
139
- // availableVariants: [],
140
- // metadata: {}
141
- // }
142
- // const mergeWithLocal = (
143
- // localProps: ComponentProps = {}
144
- // ): MergedConfig => {
145
- // // If no variant name was provided, return local props as-is
146
- // if (!variantName) {
147
- // return {
148
- // props: localProps,
149
- // variant: '',
150
- // hasConfig: false
151
- // }
152
- // }
153
- // return mergeComponentConfig(config, localProps)
154
- // }
155
- // const getProp = <T = any>(propName: string, defaultValue?: T): T =>
156
- // (config.componentProps[propName] ?? defaultValue) as T
157
- // return {
158
- // ...config,
159
- // mergeWithLocal,
160
- // getProp
161
- // }
162
- // }
14
+ exports.getAvailableVariants = exports.hasComponentVariant = exports.useComponentProps = exports.useComponentConfiguration = exports.mergeComponentConfig = exports.getComponentConfig = void 0;
163
15
  var theme_1 = require("../ui/theme/theme");
164
16
  var react_1 = require("react");
165
17
  /**
@@ -219,29 +71,37 @@ var getComponentConfig = function (projectData, componentName, variantName) {
219
71
  };
220
72
  exports.getComponentConfig = getComponentConfig;
221
73
  /**
222
- * Deep merge utility for nested objects
223
- * Config props override local props, but we preserve nested structure
74
+ * Smart merge utility - LOCAL PROPS OVERRIDE CONFIG PROPS
75
+ * If a prop exists in both local and config, local wins
224
76
  */
225
- var deepMerge = function (target, source) {
226
- var result = __assign({}, target);
227
- for (var key in source) {
228
- if (source[key] !== undefined) {
229
- // For objects, do shallow merge (we don't go too deep to avoid complexity)
230
- if (typeof source[key] === 'object' && !Array.isArray(source[key]) && source[key] !== null) {
231
- result[key] = __assign(__assign({}, (target[key] || {})), source[key]);
77
+ var smartMergeWithLocalOverride = function (configProps, localProps) {
78
+ var result = __assign({}, configProps);
79
+ // Apply local props - they override config props
80
+ for (var key in localProps) {
81
+ if (localProps[key] !== undefined) {
82
+ // For objects, do smart merge but local object properties still override
83
+ if (typeof localProps[key] === 'object' &&
84
+ !Array.isArray(localProps[key]) &&
85
+ localProps[key] !== null &&
86
+ typeof configProps[key] === 'object' &&
87
+ !Array.isArray(configProps[key]) &&
88
+ configProps[key] !== null) {
89
+ // Merge nested objects but local properties still win
90
+ result[key] = __assign(__assign({}, configProps[key]), localProps[key]);
232
91
  }
233
92
  else {
234
- result[key] = source[key];
93
+ // Primitive values or arrays - local always wins
94
+ result[key] = localProps[key];
235
95
  }
236
96
  }
237
97
  }
238
98
  return result;
239
99
  };
240
100
  /**
241
- * Merge component config with local props - only applies config if variant exists
101
+ * Merge component config with local props - LOCAL PROPS OVERRIDE CONFIG
242
102
  *
243
103
  * @param config - Component configuration from getComponentConfig
244
- * @param localProps - Props passed directly to the component
104
+ * @param localProps - Props passed directly to the component (OVERRIDES CONFIG)
245
105
  * @returns Merged configuration with metadata
246
106
  */
247
107
  var mergeComponentConfig = function (config, localProps) {
@@ -255,17 +115,16 @@ var mergeComponentConfig = function (config, localProps) {
255
115
  hasConfig: false
256
116
  };
257
117
  }
118
+ // LOCAL PROPS OVERRIDE CONFIG PROPS
258
119
  return {
259
- // Props: config overrides local, with deep merge for nested objects
260
- props: deepMerge(localProps, config.componentProps),
261
- // Metadata
120
+ props: smartMergeWithLocalOverride(config.componentProps, localProps),
262
121
  variant: config.actualVariant,
263
122
  hasConfig: true
264
123
  };
265
124
  };
266
125
  exports.mergeComponentConfig = mergeComponentConfig;
267
126
  /**
268
- * Hook for easy component config usage - only applies if variant is provided and exists
127
+ * Hook for easy component config usage with LOCAL PROP OVERRIDE
269
128
  * Uses useMemo to prevent unnecessary re-computation
270
129
  *
271
130
  * @param componentName - Name of the component
@@ -287,7 +146,7 @@ var useComponentConfiguration = function (componentName, variantName) {
287
146
  }
288
147
  return (0, exports.getComponentConfig)(projectData, componentName, variantName);
289
148
  }, [projectData, componentName, variantName]);
290
- // Memoize merge function
149
+ // Memoize merge function - LOCAL PROPS OVERRIDE CONFIG
291
150
  var mergeWithLocal = (0, react_1.useMemo)(function () {
292
151
  return function (localProps) {
293
152
  if (localProps === void 0) { localProps = {}; }
@@ -302,7 +161,7 @@ var useComponentConfiguration = function (componentName, variantName) {
302
161
  return (0, exports.mergeComponentConfig)(config, localProps);
303
162
  };
304
163
  }, [config, variantName]);
305
- // Memoize getProp function
164
+ // Memoize getProp function (gets from config only, not merged)
306
165
  var getProp = (0, react_1.useMemo)(function () {
307
166
  return function (propName, defaultValue) { var _a; return ((_a = config.componentProps[propName]) !== null && _a !== void 0 ? _a : defaultValue); };
308
167
  }, [config.componentProps]);
@@ -310,8 +169,22 @@ var useComponentConfiguration = function (componentName, variantName) {
310
169
  };
311
170
  exports.useComponentConfiguration = useComponentConfiguration;
312
171
  /**
313
- * Utility function to check if a component variant exists
314
- * Useful for conditional rendering logic
172
+ * Hook that directly returns merged props with local override
173
+ * Perfect for direct use in components
174
+ */
175
+ var useComponentProps = function (componentName, variantName, localProps) {
176
+ if (variantName === void 0) { variantName = 'default'; }
177
+ if (localProps === void 0) { localProps = {}; }
178
+ var projectData = (0, theme_1.useTheme)().projectData;
179
+ return (0, react_1.useMemo)(function () {
180
+ var config = (0, exports.getComponentConfig)(projectData, componentName, variantName);
181
+ var merged = (0, exports.mergeComponentConfig)(config, localProps);
182
+ return merged.props;
183
+ }, [projectData, componentName, variantName, localProps]);
184
+ };
185
+ exports.useComponentProps = useComponentProps;
186
+ /**
187
+ * Quick utility to check if a component variant exists
315
188
  */
316
189
  var hasComponentVariant = function (projectData, componentName, variantName) {
317
190
  var _a, _b;
@@ -320,7 +193,6 @@ var hasComponentVariant = function (projectData, componentName, variantName) {
320
193
  exports.hasComponentVariant = hasComponentVariant;
321
194
  /**
322
195
  * Get all available variants for a component
323
- * Useful for variant selectors/dropdowns
324
196
  */
325
197
  var getAvailableVariants = function (projectData, componentName) {
326
198
  var _a;
@@ -1,10 +0,0 @@
1
- export namespace Requests {
2
- export function getDocs(collectionName: any, docs_limit: any, extraQueries?: any[]): Promise<any>;
3
- export function getDoc(collectionName: any, id: any): Promise<any>;
4
- export function query(collectionName: any, queriesArr: any[] | undefined, docs_limit: any): Promise<any>;
5
- export function add_document(cName: any, data: any, dbCollection?: string): Promise<any>;
6
- export function set_doc(cName: any, doc_id: any, data: any): Promise<any>;
7
- export function update(cName: any, doc_id: any, data: any): Promise<any>;
8
- export function _delete(cName: any, doc_id: any): Promise<any>;
9
- export { _delete as delete };
10
- }
@@ -1,273 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
- if (ar || !(i in from)) {
52
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
- ar[i] = from[i];
54
- }
55
- }
56
- return to.concat(ar || Array.prototype.slice.call(from));
57
- };
58
- var __importDefault = (this && this.__importDefault) || function (mod) {
59
- return (mod && mod.__esModule) ? mod : { "default": mod };
60
- };
61
- Object.defineProperty(exports, "__esModule", { value: true });
62
- exports.Requests = void 0;
63
- var Firebase_1 = __importDefault(require("./Firebase"));
64
- var firestore_1 = require("firebase/firestore");
65
- // ⏳ Convert timestamp to "x time ago"
66
- function timeAgo(timestamp) {
67
- if (!timestamp)
68
- return "";
69
- var now = new Date();
70
- var date = timestamp.toDate ? timestamp.toDate() : new Date(timestamp);
71
- var seconds = Math.floor((now - date) / 1000);
72
- var intervals = {
73
- year: 31536000,
74
- month: 2592000,
75
- week: 604800,
76
- day: 86400,
77
- hour: 3600,
78
- minute: 60,
79
- second: 1,
80
- };
81
- for (var key in intervals) {
82
- var value = intervals[key];
83
- if (seconds >= value) {
84
- var count = Math.floor(seconds / value);
85
- return "".concat(count, " ").concat(key).concat(count > 1 ? "s" : "", " ago");
86
- }
87
- }
88
- return "just now";
89
- }
90
- // ⏳ Apply timeAgo to createdAt & updatedAt fields
91
- function formatTimestamps(docData) {
92
- return __assign(__assign({}, docData), { createdAt: docData.createdAt ? timeAgo(docData.createdAt) : null, updatedAt: docData.updatedAt ? timeAgo(docData.updatedAt) : null });
93
- }
94
- exports.Requests = {
95
- // 📥 Get all docs
96
- getDocs: function (collectionName, docs_limit, extraQueries) {
97
- if (extraQueries === void 0) { extraQueries = []; }
98
- return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
99
- var Resourceq, snapshot, data, err_1;
100
- return __generator(this, function (_a) {
101
- switch (_a.label) {
102
- case 0:
103
- _a.trys.push([0, 2, , 3]);
104
- Resourceq = firestore_1.query.apply(void 0, __spreadArray(__spreadArray([(0, firestore_1.collection)(Firebase_1.default, collectionName)], extraQueries, false), (docs_limit ? [(0, firestore_1.limit)(docs_limit)] : []), false));
105
- return [4 /*yield*/, (0, firestore_1.getDocs)(Resourceq)];
106
- case 1:
107
- snapshot = _a.sent();
108
- if (snapshot.docs.length > 0) {
109
- data = snapshot.docs.map(function (d) { return (__assign({ id: d.id }, formatTimestamps(d.data()))); });
110
- resolve(data);
111
- }
112
- else {
113
- resolve([]);
114
- }
115
- return [3 /*break*/, 3];
116
- case 2:
117
- err_1 = _a.sent();
118
- reject("Error fetching documents: ".concat(err_1.message));
119
- return [3 /*break*/, 3];
120
- case 3: return [2 /*return*/];
121
- }
122
- });
123
- }); });
124
- },
125
- // 📥 Get single doc
126
- getDoc: function (collectionName, id) {
127
- return new Promise(function (resolve, reject) {
128
- (0, firestore_1.onSnapshot)((0, firestore_1.doc)(Firebase_1.default, collectionName, id), function (gdoc) {
129
- var data = gdoc.data();
130
- if (data) {
131
- resolve({ data: formatTimestamps(data), id: gdoc.id });
132
- }
133
- else {
134
- resolve({ message: "No data found", data: "" });
135
- }
136
- }, function (err) { return reject("Error fetching document: ".concat(err.message)); });
137
- });
138
- },
139
- // 🔎 Flexible query (add more queries)
140
- query: function (collectionName, queriesArr, docs_limit) {
141
- if (queriesArr === void 0) { queriesArr = []; }
142
- return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
143
- var Resourceq, snapshot, data, err_2;
144
- return __generator(this, function (_a) {
145
- switch (_a.label) {
146
- case 0:
147
- _a.trys.push([0, 2, , 3]);
148
- Resourceq = firestore_1.query.apply(void 0, __spreadArray(__spreadArray([(0, firestore_1.collection)(Firebase_1.default, collectionName)], queriesArr, false), (docs_limit ? [(0, firestore_1.limit)(docs_limit)] : []), false));
149
- return [4 /*yield*/, (0, firestore_1.getDocs)(Resourceq)];
150
- case 1:
151
- snapshot = _a.sent();
152
- if (snapshot.docs.length > 0) {
153
- data = snapshot.docs.map(function (d) { return (__assign({ id: d.id }, formatTimestamps(d.data()))); });
154
- resolve({ data: data });
155
- }
156
- else {
157
- resolve({ message: "No data", data: [] });
158
- }
159
- return [3 /*break*/, 3];
160
- case 2:
161
- err_2 = _a.sent();
162
- reject("Error querying documents: ".concat(err_2.message));
163
- console.log(err_2);
164
- return [3 /*break*/, 3];
165
- case 3: return [2 /*return*/];
166
- }
167
- });
168
- }); });
169
- },
170
- // ➕ Add new doc with createdAt + updatedAt
171
- add_document: function (cName, data, dbCollection) {
172
- if (dbCollection === void 0) { dbCollection = ''; }
173
- return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
174
- var docRef, err_3;
175
- return __generator(this, function (_a) {
176
- switch (_a.label) {
177
- case 0:
178
- _a.trys.push([0, 3, , 4]);
179
- return [4 /*yield*/, (0, firestore_1.addDoc)((0, firestore_1.collection)(Firebase_1.default, cName), __assign(__assign({}, data), { createdAt: (0, firestore_1.serverTimestamp)(), updatedAt: (0, firestore_1.serverTimestamp)() }))];
180
- case 1:
181
- docRef = _a.sent();
182
- // Then update the same doc with its ID
183
- return [4 /*yield*/, (0, firestore_1.updateDoc)(docRef, dbCollection === 'users' ? { uid: docRef.id } : { id: docRef.id })];
184
- case 2:
185
- // Then update the same doc with its ID
186
- _a.sent();
187
- resolve(docRef);
188
- return [3 /*break*/, 4];
189
- case 3:
190
- err_3 = _a.sent();
191
- reject("Error adding document: ".concat(err_3.message));
192
- return [3 /*break*/, 4];
193
- case 4: return [2 /*return*/];
194
- }
195
- });
196
- }); });
197
- },
198
- // ✍️ Set/merge doc with updatedAt
199
- set_doc: function (cName, doc_id, data) {
200
- return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
201
- var res, err_4;
202
- return __generator(this, function (_a) {
203
- switch (_a.label) {
204
- case 0:
205
- _a.trys.push([0, 2, , 3]);
206
- return [4 /*yield*/, (0, firestore_1.setDoc)((0, firestore_1.doc)(Firebase_1.default, cName, doc_id), __assign(__assign({}, data), { updatedAt: (0, firestore_1.serverTimestamp)(), createdAt: (0, firestore_1.serverTimestamp)() }), { merge: true })];
207
- case 1:
208
- res = _a.sent();
209
- resolve(res);
210
- return [3 /*break*/, 3];
211
- case 2:
212
- err_4 = _a.sent();
213
- reject("Error setting document: ".concat(err_4.message));
214
- return [3 /*break*/, 3];
215
- case 3: return [2 /*return*/];
216
- }
217
- });
218
- }); });
219
- },
220
- // 🔄 Update doc with updatedAt
221
- update: function (cName, doc_id, data) {
222
- return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
223
- var res, err_5;
224
- return __generator(this, function (_a) {
225
- switch (_a.label) {
226
- case 0:
227
- _a.trys.push([0, 2, , 3]);
228
- return [4 /*yield*/, (0, firestore_1.updateDoc)((0, firestore_1.doc)(Firebase_1.default, cName, doc_id), __assign(__assign({}, data), { updatedAt: (0, firestore_1.serverTimestamp)() }))];
229
- case 1:
230
- res = _a.sent();
231
- resolve(res);
232
- return [3 /*break*/, 3];
233
- case 2:
234
- err_5 = _a.sent();
235
- reject("Error updating document: ".concat(err_5.message));
236
- return [3 /*break*/, 3];
237
- case 3: return [2 /*return*/];
238
- }
239
- });
240
- }); });
241
- },
242
- // ❌ Delete doc
243
- delete: function (cName, doc_id) {
244
- return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
245
- var err_6;
246
- return __generator(this, function (_a) {
247
- switch (_a.label) {
248
- case 0:
249
- _a.trys.push([0, 2, , 3]);
250
- return [4 /*yield*/, (0, firestore_1.deleteDoc)((0, firestore_1.doc)(Firebase_1.default, cName, doc_id))];
251
- case 1:
252
- _a.sent();
253
- resolve("Document ".concat(doc_id, " successfully deleted"));
254
- return [3 /*break*/, 3];
255
- case 2:
256
- err_6 = _a.sent();
257
- reject("Error deleting document: ".concat(err_6.message));
258
- return [3 /*break*/, 3];
259
- case 3: return [2 /*return*/];
260
- }
261
- });
262
- }); });
263
- },
264
- };
265
- // // Add document
266
- // Requests.add_document("users", { name: "John Doe", email: "john@example.com" });
267
- // // Update document
268
- // Requests.update("users", "docID123", { name: "Jane Doe" });
269
- // // Query with multiple conditions
270
- // Requests.query("users", [
271
- // where("status", "==", "active"),
272
- // where("level", "==", "admin"),
273
- // ], 10).then(res => console.log(res.data));
@@ -1,2 +0,0 @@
1
- declare const _default: import("@firebase/firestore").Firestore;
2
- export default _default;
package/utils/Firebase.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var app_1 = require("firebase/app");
4
- var firestore_1 = require("firebase/firestore");
5
- var firebaseConfig = {
6
- apiKey: "AIzaSyBi6mv2y56aKgJOv-MTHhwL1OaKnXlRNxE",
7
- authDomain: "funui-4bcd1.firebaseapp.com",
8
- projectId: "funui-4bcd1",
9
- storageBucket: "funui-4bcd1.firebasestorage.app",
10
- messagingSenderId: "321671406212",
11
- appId: "1:321671406212:web:344738ff231449368f18d1",
12
- measurementId: "G-PDMZ8J0R37"
13
- };
14
- // Initialize Firebase app
15
- var db = (0, app_1.initializeApp)(firebaseConfig);
16
- exports.default = (0, firestore_1.getFirestore)();