idb-refined 0.0.1
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/README.md +111 -0
- package/dist/cleanOldEntries.d.ts +10 -0
- package/dist/cleanOldEntries.js +16 -0
- package/dist/cleanWhenTooLarge.d.ts +10 -0
- package/dist/cleanWhenTooLarge.js +25 -0
- package/dist/delete.d.ts +9 -0
- package/dist/delete.js +12 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +7 -0
- package/dist/initDb.d.ts +12 -0
- package/dist/initDb.js +60 -0
- package/dist/putWithEviction.d.ts +11 -0
- package/dist/putWithEviction.js +13 -0
- package/dist/schema.d.ts +27 -0
- package/dist/schema.js +49 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# idb-refined
|
|
2
|
+
|
|
3
|
+
Thin TypeScript IndexedDB helper on top of [idb](https://www.npmjs.com/package/idb): init DB with auto-version, clean by date or size, add with eviction, and delete helpers.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add idb-refined
|
|
9
|
+
# or
|
|
10
|
+
npm install idb-refined
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## API
|
|
14
|
+
|
|
15
|
+
| Function | Purpose |
|
|
16
|
+
|----------|---------|
|
|
17
|
+
| **initDb(name, options?)** | Open or create a DB. Version is auto-detected when you pass a declarative `schema`; optional manual `version` + `upgrade`. Returns idb’s `IDBPDatabase`. |
|
|
18
|
+
| **cleanOldEntries(db, storeName, options)** | Delete entries where `dateKey` < `before` (timestamp ms). Options: `{ dateKey, before }`. Requires an index on `dateKey`. |
|
|
19
|
+
| **cleanWhenTooLarge(db, storeName, options)** | Evict oldest entries (by `dateKey`) until count ≤ `maxCount`. Options: `{ dateKey, maxCount }`. Returns count deleted. |
|
|
20
|
+
| **putWithEviction(db, storeName, value, options)** | Put value, then if store count > `maxCount` evict oldest by `dateKey`. Options: `{ key?, dateKey, maxCount }`. |
|
|
21
|
+
| **deleteByKey(db, storeName, key)** | Delete a single entry by key. |
|
|
22
|
+
| **clearStore(db, storeName)** | Delete all entries in a store. |
|
|
23
|
+
| **deleteDB(name)** | Re-export of idb’s `deleteDB`. |
|
|
24
|
+
|
|
25
|
+
## Use cases
|
|
26
|
+
|
|
27
|
+
- **Cache with TTL:** initDb, put items with `expiresAt`, call `cleanOldEntries` on startup or interval.
|
|
28
|
+
- **Cache with max size:** Use `putWithEviction` or call `cleanWhenTooLarge` after adding.
|
|
29
|
+
- **Cache with TTL + max size:** `putWithEviction` + periodic `cleanOldEntries` for expired.
|
|
30
|
+
- **Log / event buffer:** `putWithEviction` with `dateKey: 'createdAt'` and `maxCount`.
|
|
31
|
+
- **Simple key-value:** initDb, `db.get` / `db.put` / `deleteByKey`; optional cleanup when too large.
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
### Cache with TTL and max size
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { initDb, putWithEviction, cleanOldEntries, deleteByKey } from "idb-refined";
|
|
39
|
+
|
|
40
|
+
const db = await initDb("my-cache", {
|
|
41
|
+
schema: {
|
|
42
|
+
stores: {
|
|
43
|
+
cache: { keyPath: "id", indexes: ["expiresAt"] },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Add item; if store has more than 1000 entries, evict oldest
|
|
49
|
+
await putWithEviction(
|
|
50
|
+
db,
|
|
51
|
+
"cache",
|
|
52
|
+
{ id: "k1", data: "v1", expiresAt: Date.now() + 3600 },
|
|
53
|
+
{ dateKey: "expiresAt", maxCount: 1000 }
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// Periodic: remove expired
|
|
57
|
+
await cleanOldEntries(db, "cache", {
|
|
58
|
+
dateKey: "expiresAt",
|
|
59
|
+
before: Date.now(),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Delete one
|
|
63
|
+
await deleteByKey(db, "cache", "k1");
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Log buffer (cap size)
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
await putWithEviction(
|
|
70
|
+
db,
|
|
71
|
+
"logs",
|
|
72
|
+
{ id: generateId(), message, createdAt: Date.now() },
|
|
73
|
+
{ dateKey: "createdAt", maxCount: 5000 }
|
|
74
|
+
);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Manual cleanup when too large
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const deleted = await cleanWhenTooLarge(db, "cache", {
|
|
81
|
+
dateKey: "expiresAt",
|
|
82
|
+
maxCount: 500,
|
|
83
|
+
});
|
|
84
|
+
console.log(`Evicted ${deleted} entries`);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Requirements
|
|
88
|
+
|
|
89
|
+
- Stores that use `cleanOldEntries`, `cleanWhenTooLarge`, or `putWithEviction` must have an **index** on the date field (e.g. `expiresAt`, `createdAt`). Define it in your schema:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
schema: {
|
|
93
|
+
stores: {
|
|
94
|
+
cache: { keyPath: "id", indexes: ["expiresAt"] },
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
- Eviction is **count-based** only (no byte-size or quota check).
|
|
100
|
+
|
|
101
|
+
## Releasing
|
|
102
|
+
|
|
103
|
+
1. Bump version: `pnpm version patch` (or `minor` / `major`).
|
|
104
|
+
2. Commit and push: `git push && git push --tags`.
|
|
105
|
+
3. Pushing a tag matching `v*` (e.g. `v0.0.2`) triggers the [Publish to npm](.github/workflows/publish.yml) workflow, which runs build and `pnpm publish`.
|
|
106
|
+
|
|
107
|
+
**Required:** Add an `NPM_TOKEN` secret in the repo (Settings → Secrets and variables → Actions). Use an npm [access token](https://www.npmjs.com/settings/~/tokens) or granular token with publish permission.
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
MIT
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IDBPDatabase } from "idb";
|
|
2
|
+
export interface CleanOldEntriesOptions {
|
|
3
|
+
dateKey: string;
|
|
4
|
+
before: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Delete entries in a store where the date/timestamp field is before the threshold.
|
|
8
|
+
* Requires an index on `dateKey`. Uses timestamp in ms (e.g. Date.now()).
|
|
9
|
+
*/
|
|
10
|
+
export declare function cleanOldEntries(db: IDBPDatabase<unknown>, storeName: string, options: CleanOldEntriesOptions): Promise<void>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete entries in a store where the date/timestamp field is before the threshold.
|
|
3
|
+
* Requires an index on `dateKey`. Uses timestamp in ms (e.g. Date.now()).
|
|
4
|
+
*/
|
|
5
|
+
export async function cleanOldEntries(db, storeName, options) {
|
|
6
|
+
const { dateKey, before } = options;
|
|
7
|
+
const tx = db.transaction(storeName, "readwrite");
|
|
8
|
+
const store = tx.objectStore(storeName);
|
|
9
|
+
const index = store.index(dateKey);
|
|
10
|
+
const range = IDBKeyRange.upperBound(before, true);
|
|
11
|
+
const keysToDelete = await index.getAllKeys(range);
|
|
12
|
+
for (const key of keysToDelete) {
|
|
13
|
+
store.delete(key);
|
|
14
|
+
}
|
|
15
|
+
await tx.done;
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IDBPDatabase } from "idb";
|
|
2
|
+
export interface CleanWhenTooLargeOptions {
|
|
3
|
+
dateKey: string;
|
|
4
|
+
maxCount: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Evict oldest entries (by dateKey) until store count <= maxCount.
|
|
8
|
+
* Requires an index on dateKey. Returns the number of entries deleted.
|
|
9
|
+
*/
|
|
10
|
+
export declare function cleanWhenTooLarge(db: IDBPDatabase<unknown>, storeName: string, options: CleanWhenTooLargeOptions): Promise<number>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evict oldest entries (by dateKey) until store count <= maxCount.
|
|
3
|
+
* Requires an index on dateKey. Returns the number of entries deleted.
|
|
4
|
+
*/
|
|
5
|
+
export async function cleanWhenTooLarge(db, storeName, options) {
|
|
6
|
+
const { dateKey, maxCount } = options;
|
|
7
|
+
const count = await db.count(storeName);
|
|
8
|
+
if (count <= maxCount)
|
|
9
|
+
return 0;
|
|
10
|
+
const toDelete = count - maxCount;
|
|
11
|
+
const tx = db.transaction(storeName, "readwrite");
|
|
12
|
+
const store = tx.objectStore(storeName);
|
|
13
|
+
const index = store.index(dateKey);
|
|
14
|
+
const keysToDelete = [];
|
|
15
|
+
let cursor = await index.openKeyCursor(null, "next");
|
|
16
|
+
while (cursor != null && keysToDelete.length < toDelete) {
|
|
17
|
+
keysToDelete.push(cursor.primaryKey);
|
|
18
|
+
cursor = await cursor.continue();
|
|
19
|
+
}
|
|
20
|
+
for (const key of keysToDelete) {
|
|
21
|
+
store.delete(key);
|
|
22
|
+
}
|
|
23
|
+
await tx.done;
|
|
24
|
+
return keysToDelete.length;
|
|
25
|
+
}
|
package/dist/delete.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IDBPDatabase } from "idb";
|
|
2
|
+
/**
|
|
3
|
+
* Delete a single entry by key.
|
|
4
|
+
*/
|
|
5
|
+
export declare function deleteByKey(db: IDBPDatabase<unknown>, storeName: string, key: IDBValidKey): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Delete all entries in a store.
|
|
8
|
+
*/
|
|
9
|
+
export declare function clearStore(db: IDBPDatabase<unknown>, storeName: string): Promise<void>;
|
package/dist/delete.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delete a single entry by key.
|
|
3
|
+
*/
|
|
4
|
+
export async function deleteByKey(db, storeName, key) {
|
|
5
|
+
await db.delete(storeName, key);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Delete all entries in a store.
|
|
9
|
+
*/
|
|
10
|
+
export async function clearStore(db, storeName) {
|
|
11
|
+
await db.clear(storeName);
|
|
12
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { initDb } from "./initDb.js";
|
|
2
|
+
export type { InitDbOptions } from "./initDb.js";
|
|
3
|
+
export { cleanOldEntries } from "./cleanOldEntries.js";
|
|
4
|
+
export type { CleanOldEntriesOptions } from "./cleanOldEntries.js";
|
|
5
|
+
export { cleanWhenTooLarge } from "./cleanWhenTooLarge.js";
|
|
6
|
+
export type { CleanWhenTooLargeOptions } from "./cleanWhenTooLarge.js";
|
|
7
|
+
export { putWithEviction } from "./putWithEviction.js";
|
|
8
|
+
export type { PutWithEvictionOptions } from "./putWithEviction.js";
|
|
9
|
+
export { deleteByKey, clearStore } from "./delete.js";
|
|
10
|
+
export { deleteDB } from "idb";
|
|
11
|
+
export type { IDBPDatabase, DBSchema } from "idb";
|
|
12
|
+
export type { SchemaDef, StoreDef } from "./schema.js";
|
|
13
|
+
export { fingerprint, applySchema } from "./schema.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { initDb } from "./initDb.js";
|
|
2
|
+
export { cleanOldEntries } from "./cleanOldEntries.js";
|
|
3
|
+
export { cleanWhenTooLarge } from "./cleanWhenTooLarge.js";
|
|
4
|
+
export { putWithEviction } from "./putWithEviction.js";
|
|
5
|
+
export { deleteByKey, clearStore } from "./delete.js";
|
|
6
|
+
export { deleteDB } from "idb";
|
|
7
|
+
export { fingerprint, applySchema } from "./schema.js";
|
package/dist/initDb.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IDBPDatabase } from "idb";
|
|
2
|
+
import type { SchemaDef } from "./schema.js";
|
|
3
|
+
export interface InitDbOptions {
|
|
4
|
+
schema?: SchemaDef;
|
|
5
|
+
version?: number;
|
|
6
|
+
upgrade?: (db: IDBPDatabase<unknown>) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Open or create a database. When `schema` is provided, version is auto-detected
|
|
10
|
+
* from a fingerprint; when `version` and/or `upgrade` are provided, use them directly.
|
|
11
|
+
*/
|
|
12
|
+
export declare function initDb(name: string, options?: InitDbOptions): Promise<IDBPDatabase<unknown>>;
|
package/dist/initDb.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { openDB } from "idb";
|
|
2
|
+
import { fingerprint, applySchema } from "./schema.js";
|
|
3
|
+
const META_DB_NAME = "idb-refined-meta";
|
|
4
|
+
const META_STORE = "meta";
|
|
5
|
+
/**
|
|
6
|
+
* Open or create a database. When `schema` is provided, version is auto-detected
|
|
7
|
+
* from a fingerprint; when `version` and/or `upgrade` are provided, use them directly.
|
|
8
|
+
*/
|
|
9
|
+
export async function initDb(name, options) {
|
|
10
|
+
if (options?.schema != null) {
|
|
11
|
+
return initDbWithSchema(name, options.schema, options.upgrade);
|
|
12
|
+
}
|
|
13
|
+
const version = options?.version ?? 1;
|
|
14
|
+
return openDB(name, version, {
|
|
15
|
+
upgrade: options?.upgrade,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async function initDbWithSchema(name, schema, customUpgrade) {
|
|
19
|
+
const fp = fingerprint(schema);
|
|
20
|
+
const metaDb = await openDB(META_DB_NAME, 1, {
|
|
21
|
+
upgrade(db) {
|
|
22
|
+
if (!db.objectStoreNames.contains(META_STORE)) {
|
|
23
|
+
db.createObjectStore(META_STORE, { keyPath: "dbName" });
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const stored = (await metaDb.get(META_STORE, name));
|
|
28
|
+
metaDb.close();
|
|
29
|
+
let currentVersion = 0;
|
|
30
|
+
try {
|
|
31
|
+
const probe = await openDB(name);
|
|
32
|
+
currentVersion = probe.version;
|
|
33
|
+
probe.close();
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// DB does not exist yet
|
|
37
|
+
}
|
|
38
|
+
const needUpgrade = stored == null || stored.schemaFingerprint !== fp;
|
|
39
|
+
const newVersion = needUpgrade
|
|
40
|
+
? Math.max((stored?.version ?? 0) + 1, currentVersion + 1)
|
|
41
|
+
: stored.version;
|
|
42
|
+
const db = (await openDB(name, newVersion, {
|
|
43
|
+
upgrade(db, _oldVersion, _newVersion, transaction) {
|
|
44
|
+
if (needUpgrade) {
|
|
45
|
+
applySchema(db, schema, transaction);
|
|
46
|
+
}
|
|
47
|
+
customUpgrade?.(db);
|
|
48
|
+
},
|
|
49
|
+
}));
|
|
50
|
+
if (needUpgrade) {
|
|
51
|
+
const metaDb2 = await openDB(META_DB_NAME, 1);
|
|
52
|
+
await metaDb2.put(META_STORE, {
|
|
53
|
+
dbName: name,
|
|
54
|
+
schemaFingerprint: fp,
|
|
55
|
+
version: newVersion,
|
|
56
|
+
});
|
|
57
|
+
metaDb2.close();
|
|
58
|
+
}
|
|
59
|
+
return db;
|
|
60
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IDBPDatabase } from "idb";
|
|
2
|
+
export interface PutWithEvictionOptions {
|
|
3
|
+
key?: IDBValidKey;
|
|
4
|
+
dateKey: string;
|
|
5
|
+
maxCount: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Put a value in the store, then if count > maxCount evict oldest entries (by dateKey).
|
|
9
|
+
* Value must include the keyPath field, or pass options.key.
|
|
10
|
+
*/
|
|
11
|
+
export declare function putWithEviction<T = unknown>(db: IDBPDatabase<unknown>, storeName: string, value: T, options: PutWithEvictionOptions): Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cleanWhenTooLarge } from "./cleanWhenTooLarge.js";
|
|
2
|
+
/**
|
|
3
|
+
* Put a value in the store, then if count > maxCount evict oldest entries (by dateKey).
|
|
4
|
+
* Value must include the keyPath field, or pass options.key.
|
|
5
|
+
*/
|
|
6
|
+
export async function putWithEviction(db, storeName, value, options) {
|
|
7
|
+
const { key, dateKey, maxCount } = options;
|
|
8
|
+
await db.put(storeName, value, key);
|
|
9
|
+
const count = await db.count(storeName);
|
|
10
|
+
if (count > maxCount) {
|
|
11
|
+
await cleanWhenTooLarge(db, storeName, { dateKey, maxCount });
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IDBPDatabase, IDBPTransaction } from "idb";
|
|
2
|
+
/**
|
|
3
|
+
* Definition for a single object store.
|
|
4
|
+
* - keyPath: optional key path (e.g. 'id')
|
|
5
|
+
* - autoIncrement: optional
|
|
6
|
+
* - indexes: array of index names (keyPath = name) or record indexName -> keyPath | keyPath[]
|
|
7
|
+
*/
|
|
8
|
+
export interface StoreDef {
|
|
9
|
+
keyPath?: string;
|
|
10
|
+
autoIncrement?: boolean;
|
|
11
|
+
indexes?: string[] | Record<string, string | string[]>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Declarative schema: store names -> store definitions.
|
|
15
|
+
*/
|
|
16
|
+
export interface SchemaDef {
|
|
17
|
+
stores: Record<string, StoreDef>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Stable fingerprint for schema (sorted keys) so any schema change produces a different string.
|
|
21
|
+
*/
|
|
22
|
+
export declare function fingerprint(schema: SchemaDef): string;
|
|
23
|
+
/**
|
|
24
|
+
* Create object stores and indexes from schema. Call this from within an upgrade callback.
|
|
25
|
+
* Pass the upgrade transaction so existing stores can get new indexes. Skips stores/indexes that already exist.
|
|
26
|
+
*/
|
|
27
|
+
export declare function applySchema(db: IDBPDatabase<unknown>, schema: SchemaDef, transaction: IDBPTransaction<unknown, string[], "versionchange">): void;
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable fingerprint for schema (sorted keys) so any schema change produces a different string.
|
|
3
|
+
*/
|
|
4
|
+
export function fingerprint(schema) {
|
|
5
|
+
const normalized = {};
|
|
6
|
+
for (const name of Object.keys(schema.stores).sort()) {
|
|
7
|
+
const def = schema.stores[name];
|
|
8
|
+
const indexes = def.indexes == null
|
|
9
|
+
? undefined
|
|
10
|
+
: Array.isArray(def.indexes)
|
|
11
|
+
? [...def.indexes].sort()
|
|
12
|
+
: Object.fromEntries(Object.keys(def.indexes)
|
|
13
|
+
.sort()
|
|
14
|
+
.map((k) => [
|
|
15
|
+
k,
|
|
16
|
+
def.indexes[k],
|
|
17
|
+
]));
|
|
18
|
+
normalized[name] = {
|
|
19
|
+
keyPath: def.keyPath,
|
|
20
|
+
autoIncrement: def.autoIncrement,
|
|
21
|
+
indexes,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return JSON.stringify(normalized);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create object stores and indexes from schema. Call this from within an upgrade callback.
|
|
28
|
+
* Pass the upgrade transaction so existing stores can get new indexes. Skips stores/indexes that already exist.
|
|
29
|
+
*/
|
|
30
|
+
export function applySchema(db, schema, transaction) {
|
|
31
|
+
for (const [storeName, def] of Object.entries(schema.stores)) {
|
|
32
|
+
const store = !db.objectStoreNames.contains(storeName)
|
|
33
|
+
? db.createObjectStore(storeName, {
|
|
34
|
+
keyPath: def.keyPath,
|
|
35
|
+
autoIncrement: def.autoIncrement ?? false,
|
|
36
|
+
})
|
|
37
|
+
: transaction.objectStore(storeName);
|
|
38
|
+
if (def.indexes) {
|
|
39
|
+
const indexEntries = Array.isArray(def.indexes)
|
|
40
|
+
? def.indexes.map((name) => [name, name])
|
|
41
|
+
: Object.entries(def.indexes);
|
|
42
|
+
for (const [indexName, keyPath] of indexEntries) {
|
|
43
|
+
if (!store.indexNames.contains(indexName)) {
|
|
44
|
+
store.createIndex(indexName, keyPath);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "idb-refined",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Thin TypeScript IndexedDB helper: initDb (auto-version), clean by date/size, add with eviction, delete helpers",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"lint-staged": {
|
|
20
|
+
"src/**/*.ts": [
|
|
21
|
+
"eslint --fix",
|
|
22
|
+
"prettier --write"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"idb": "^8.0.3"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@commitlint/cli": "^19.8.1",
|
|
30
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
31
|
+
"@eslint/js": "^9.39.2",
|
|
32
|
+
"eslint": "^9.39.2",
|
|
33
|
+
"eslint-config-prettier": "^9.1.2",
|
|
34
|
+
"fake-indexeddb": "^6.2.5",
|
|
35
|
+
"husky": "^9.1.7",
|
|
36
|
+
"lint-staged": "^15.5.2",
|
|
37
|
+
"prettier": "^3.8.1",
|
|
38
|
+
"typescript": "^5.6.3",
|
|
39
|
+
"typescript-eslint": "^8.54.0",
|
|
40
|
+
"vitest": "^2.1.9"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"indexeddb",
|
|
44
|
+
"idb",
|
|
45
|
+
"cache",
|
|
46
|
+
"browser",
|
|
47
|
+
"storage"
|
|
48
|
+
],
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsc -p tsconfig.build.json",
|
|
52
|
+
"lint": "eslint src",
|
|
53
|
+
"lint:fix": "eslint src --fix",
|
|
54
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
55
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"test:watch": "vitest"
|
|
58
|
+
}
|
|
59
|
+
}
|