universe-code 0.0.51 → 0.0.52

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,15 +1,18 @@
1
-
2
1
  let config = null;
3
2
 
4
3
  export const configureIdb = (options) => {
5
- config = options;
4
+ if (!options || !options.dbName || !options.storeName) {
5
+ throw new Error("configureIdb requires dbName and storeName");
6
+ }
7
+
8
+ config = options;
6
9
  };
7
10
 
8
11
  export const getConfig = () => {
9
- if (!config) {
10
- throw new Error(
11
- "IndexedDB not configured. Call configureIdb() before using the store."
12
- );
13
- }
14
- return config;
12
+ if (!config) {
13
+ throw new Error(
14
+ "IndexedDB not configured. Call configureIdb() before using the store."
15
+ );
16
+ }
17
+ return config;
15
18
  };
@@ -3,18 +3,18 @@ import { getConfig } from "./config.js";
3
3
 
4
4
  let db = null;
5
5
  let store = null;
6
- let manager = null; // ⬅️ IMPORTANT
6
+ let manager = null;
7
7
 
8
8
  // ✅ index db connection
9
9
  const connectDB = async () => {
10
- const { DB_NAME, DB_VERSION } = getConfig();
10
+ const { dbName, dbVersion, storeName } = getConfig(); // ✅ FIXED
11
11
 
12
12
  if (!manager) {
13
- manager = new DBManager(DB_NAME, DB_VERSION);
13
+ manager = new DBManager(dbName, dbVersion);
14
14
  }
15
15
 
16
16
  if (!db) {
17
- db = await manager.connect([{ name: STORE_NAME }]);
17
+ db = await manager.connect([{ name: storeName }]); // ✅ FIXED
18
18
  }
19
19
 
20
20
  return db;
@@ -23,17 +23,17 @@ const connectDB = async () => {
23
23
  export const getIdbStore = async () => {
24
24
  if (!store) {
25
25
  const database = await connectDB();
26
- const { STORE_NAME } = getConfig();
26
+ const { storeName } = getConfig(); // ✅ FIXED
27
27
 
28
28
  store = {
29
- get: (key) => DB.get(database, STORE_NAME, key),
29
+ get: (key) => DB.get(database, storeName, key),
30
30
  getWithExpiry: (key, ttl, api) =>
31
- DB.getWithExpiry(database, STORE_NAME, key, ttl, api),
32
- put: (data) => DB.put(database, STORE_NAME, data),
33
- remove: (key) => DB.remove(database, STORE_NAME, key),
34
- clear: () => DB.clear(database, STORE_NAME),
31
+ DB.getWithExpiry(database, storeName, key, ttl, api),
32
+ put: (data) => DB.put(database, storeName, data),
33
+ remove: (key) => DB.remove(database, storeName, key),
34
+ clear: () => DB.clear(database, storeName),
35
35
  };
36
36
  }
37
37
 
38
38
  return store;
39
- };
39
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universe-code",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "description": "Universal utility functions for all JS frameworks",
5
5
  "license": "ISC",
6
6
  "type": "module",