Compare commits

...

79 Commits

Author SHA1 Message Date
jkunz c250bbddaf v2.0.22 2026-04-30 10:03:06 +00:00
jkunz 8fabbf6740 fix(build): tighten TypeScript build configuration and refresh package metadata 2026-04-30 10:03:06 +00:00
jkunz b2b843e823 v2.0.21 2026-03-26 08:33:53 +00:00
jkunz e3e143eeb4 fix(build): migrate project tooling and tests to the smartconfig setup and updated IndexedDB dependencies 2026-03-26 08:33:53 +00:00
philkunz 12119192cf update description 2024-05-29 14:17:47 +02:00
philkunz ed0f497ac9 2.0.20 2024-05-28 01:00:35 +02:00
philkunz 7f7c4a28ee fix(core): update 2024-05-28 01:00:35 +02:00
philkunz 4ee78554a4 2.0.19 2024-05-25 02:02:45 +02:00
philkunz 34b90b438c fix(core): update 2024-05-25 02:02:44 +02:00
philkunz 40dcedf585 2.0.18 2024-05-25 02:02:00 +02:00
philkunz d630bd90a4 fix(core): update 2024-05-25 02:01:59 +02:00
philkunz 56d9072996 2.0.17 2024-05-17 17:46:56 +02:00
philkunz ed1c977387 fix(core): update 2024-05-17 17:46:56 +02:00
philkunz 7425a5c42d 2.0.16 2024-05-17 16:36:57 +02:00
philkunz 65d5d1f6d3 fix(core): update 2024-05-17 16:36:56 +02:00
philkunz 88fd33d8cc 2.0.15 2024-05-17 16:35:41 +02:00
philkunz d11b63637f fix(core): update 2024-05-17 16:35:40 +02:00
philkunz 845ffa3c86 2.0.14 2024-04-18 20:52:00 +02:00
philkunz 77867e26c2 fix(core): update 2024-04-18 20:51:59 +02:00
philkunz 09e247db1e update tsconfig 2024-04-14 18:42:46 +02:00
philkunz 394d9e8f9e update tsconfig 2024-04-01 21:42:49 +02:00
philkunz 92e77a9679 update npmextra.json: githost 2024-04-01 20:00:24 +02:00
philkunz 76cd2061ad update npmextra.json: githost 2024-03-30 21:49:22 +01:00
philkunz 5e4f493a21 2.0.13 2023-10-02 19:11:28 +02:00
philkunz 62f32bd2ba fix(core): update 2023-10-02 19:11:27 +02:00
philkunz d537d04fb6 2.0.12 2023-10-02 19:10:31 +02:00
philkunz b1586354e9 fix(core): update 2023-10-02 19:10:30 +02:00
philkunz ccae316e29 2.0.11 2023-09-30 15:10:42 +02:00
philkunz 5de6e1d591 fix(core): update 2023-09-30 15:10:42 +02:00
philkunz 7fe5f98477 2.0.10 2023-09-23 10:08:50 +02:00
philkunz ce9f998da8 fix(core): update 2023-09-23 10:08:50 +02:00
philkunz 37ab7e51f1 2.0.9 2023-07-27 13:51:41 +02:00
philkunz 0d343329f5 fix(core): update 2023-07-27 13:51:40 +02:00
philkunz 94280da45c 2.0.8 2023-05-01 14:40:20 +02:00
philkunz 9902414f5a fix(core): update 2023-05-01 14:40:19 +02:00
philkunz 65fe260519 2.0.7 2023-05-01 12:45:00 +02:00
philkunz 6f425906e5 fix(core): update 2023-05-01 12:44:59 +02:00
philkunz 257b995ca0 2.0.6 2023-05-01 12:17:40 +02:00
philkunz 2500ba4cd4 fix(core): update 2023-05-01 12:17:39 +02:00
philkunz 20a81e8209 2.0.5 2022-08-01 15:50:05 +02:00
philkunz 18145a27e2 fix(core): update 2022-08-01 15:50:05 +02:00
philkunz f62e0f87ce 2.0.4 2022-07-07 08:49:31 +02:00
philkunz 4e74159a54 fix(core): update 2022-07-07 08:49:31 +02:00
philkunz 2e8d3ca7e8 2.0.3 2022-05-29 20:04:44 +02:00
philkunz dfb4a4f62a fix(core): update 2022-05-29 20:04:44 +02:00
philkunz 948957b03f 2.0.2 2022-05-28 13:40:14 +02:00
philkunz cb69bf3585 fix(core): update 2022-05-28 13:40:14 +02:00
philkunz 3d27c0fada 2.0.1 2022-05-28 12:49:03 +02:00
philkunz 94672fd41c fix(core): update 2022-05-28 12:49:03 +02:00
philkunz 4b3964c7c4 2.0.0 2022-05-28 12:33:10 +02:00
philkunz 7fa246e0e4 BREAKING CHANGE(core): switch to esm 2022-05-28 12:33:10 +02:00
philkunz dac5342a19 1.0.18 2022-01-24 04:40:22 +01:00
philkunz 1829db1d82 fix(core): update 2022-01-24 04:40:21 +01:00
philkunz 3c4cba97c2 1.0.17 2022-01-24 04:39:13 +01:00
philkunz b86bd61cbf fix(core): update 2022-01-24 04:39:12 +01:00
philkunz ad95154284 1.0.16 2020-10-17 16:44:53 +00:00
philkunz 7fb47d224e fix(core): update 2020-10-17 16:44:53 +00:00
philkunz 40175dc4de 1.0.15 2020-10-17 16:38:22 +00:00
philkunz 115d461d29 fix(core): update 2020-10-17 16:38:22 +00:00
philkunz 00964a7db1 1.0.14 2020-09-19 15:06:28 +00:00
philkunz b00db37bf4 fix(core): update 2020-09-19 15:06:27 +00:00
philkunz 995ae20502 1.0.13 2020-09-19 14:58:07 +00:00
philkunz 5c805e57a2 fix(core): update 2020-09-19 14:58:06 +00:00
philkunz 938207f1c5 1.0.12 2020-09-19 14:38:29 +00:00
philkunz e810bd9473 fix(core): update 2020-09-19 14:38:29 +00:00
philkunz 10d1bb35ce 1.0.11 2020-09-19 14:35:55 +00:00
philkunz 8e97b51f1f fix(core): update 2020-09-19 14:35:54 +00:00
philkunz 7159b33425 1.0.10 2020-09-19 14:02:15 +00:00
philkunz 5860066621 fix(core): update 2020-09-19 14:02:15 +00:00
philkunz fca8c434f6 1.0.9 2020-09-18 10:12:03 +00:00
philkunz 6bd3bd4f37 fix(core): update 2020-09-18 10:12:02 +00:00
philkunz 068199b5e9 1.0.8 2020-07-11 17:19:29 +00:00
philkunz 0eb8193e4a fix(core): update 2020-07-11 17:19:29 +00:00
philkunz 34e898e0cf 1.0.7 2020-07-11 17:15:25 +00:00
philkunz 3530e376d6 fix(core): update 2020-07-11 17:15:24 +00:00
philkunz ef141659e2 1.0.6 2020-07-11 16:26:36 +00:00
philkunz 0b3dec53dd fix(core): update 2020-07-11 16:26:35 +00:00
philkunz 1d5cb914ac 1.0.5 2020-07-09 23:03:47 +00:00
philkunz ce7a457509 fix(core): update 2020-07-09 23:03:46 +00:00
27 changed files with 8900 additions and 11324 deletions
+66
View File
@@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
+124
View File
@@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true
-127
View File
@@ -1,127 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
tags:
- lossless
- docker
- notpriv
audit:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high
tags:
- lossless
- docker
- notpriv
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- priv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- notpriv
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true
+41
View File
@@ -0,0 +1,41 @@
{
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "webstore",
"description": "A high-performance storage solution for web applications using IndexedDB.",
"npmPackagename": "@push.rocks/webstore",
"license": "MIT",
"projectDomain": "push.rocks",
"keywords": [
"indexeddb",
"browser storage",
"high performance",
"typescript",
"database",
"web development",
"data persistence",
"storage solution",
"typed requests",
"performance optimization",
"API caching",
"efficient data management"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
},
"@ship.zone/szci": {
"npmGlobalTools": []
}
}
+3 -21
View File
@@ -2,28 +2,10 @@
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
"type": "node-terminal"
}
]
}
+1 -1
View File
@@ -15,7 +15,7 @@
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm"]
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
+58
View File
@@ -0,0 +1,58 @@
# Changelog
## 2026-04-30 - 2.0.22 - fix(build)
tighten TypeScript build configuration and refresh package metadata
- enable noImplicitAny in tsconfig and remove the corresponding build flag from the build script
- update development and runtime dependency patch versions
- add packageManager metadata and include the license file in published package contents
## 2026-03-26 - 2.0.21 - fix(build)
migrate project tooling and tests to the smartconfig setup and updated IndexedDB dependencies
- replace deprecated npmextra.json metadata with .smartconfig.json
- switch IndexedDB import from @tempfix/idb to idb and add pnpm overrides and patch metadata
- update test imports and rename cross-runtime tests to the node+chromium convention
- add Node.js types and initialize the WebStore database property with a definite assignment assertion
## 2024-05-29 - 2.0.20 - metadata
Updated project description.
- Refreshed package description metadata
- Includes routine release housekeeping for versions 2.0.19-2.0.20
## 2024-05-17 - 2.0.14-2.0.19 - core
Applied a series of routine core updates across multiple patch releases.
- Repeated `fix(core): update` changes were released from 2.0.14 through 2.0.19
- Changes appear to be maintenance-level updates with no further detail in commit history
## 2024-04-14 - 2.0.13 - build
Updated project configuration and package host metadata.
- Updated `tsconfig`
- Updated `npmextra.json` githost settings
## 2023-05-01 - 2.0.5-2.0.12 - core
Released a sequence of routine core patch updates.
- Repeated `fix(core): update` changes were published from 2.0.5 through 2.0.12
- No additional implementation details were provided in commit messages
## 2022-05-28 - 2.0.0 - core
Released the 2.0 major version with a breaking module format change.
- Breaking change: switched package output to ESM
- Included routine core update follow-up releases through 2.0.4
## 2020-10-17 - 1.0.16-1.0.18 - core
Released routine maintenance updates leading up to the final 1.x release.
- Repeated `fix(core): update` changes were published for 1.0.16 and 1.0.17
- Version 1.0.18 introduced the breaking change later released as part of 2.0.0: switch to ESM
## 2020-07-09 - 1.0.1-1.0.15 - core
Published a long series of routine core maintenance releases.
- Repeated `fix(core): update` changes were released across versions 1.0.1 through 1.0.15
- Commit history does not include more specific change details
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2020 Lossless GmbH (hello@lossless.com)
Copyright (c) 2020 Task Venture Capital GmbH (hello@task.vc)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
-18
View File
@@ -1,18 +0,0 @@
{
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "webstore",
"shortDescription": "high performance storage in the browser using indexed db",
"npmPackagename": "@pushrocks/webstore",
"license": "MIT",
"projectDomain": "push.rocks"
}
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
}
}
-11026
View File
File diff suppressed because it is too large Load Diff
+55 -13
View File
@@ -1,27 +1,34 @@
{
"name": "@pushrocks/webstore",
"version": "1.0.4",
"name": "@push.rocks/webstore",
"version": "2.0.22",
"private": false,
"description": "high performance storage in the browser using indexed db",
"description": "A high-performance storage solution for web applications using IndexedDB.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)",
"format": "(gitzone format)"
"buildDocs": "tsdoc"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tstest": "^1.0.39",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^14.0.20",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.15.0"
"@git.zone/tsbuild": "^4.4.0",
"@git.zone/tsrun": "^2.0.2",
"@git.zone/tstest": "^3.6.3",
"@push.rocks/smartntml": "^2.0.8",
"@types/node": "^25.6.0"
},
"dependencies": {
"idb": "^5.0.4"
"@api.global/typedrequest-interfaces": "^3.0.19",
"@push.rocks/lik": "^6.4.1",
"@push.rocks/smartenv": "^6.0.0",
"@push.rocks/smartjson": "^6.0.1",
"@push.rocks/smartpromise": "^4.2.3",
"@push.rocks/smartrx": "^3.0.10",
"fake-indexeddb": "^6.2.5",
"idb": "^8.0.3"
},
"browserslist": [
"last 1 chrome versions"
@@ -35,7 +42,42 @@
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
".smartconfig.json",
"license",
"readme.md"
]
],
"keywords": [
"indexeddb",
"browser storage",
"high performance",
"typescript",
"database",
"web development",
"data persistence",
"storage solution",
"typed requests",
"performance optimization",
"API caching",
"efficient data management"
],
"pnpm": {
"onlyBuiltDependencies": [
"esbuild",
"puppeteer",
"sharp",
"mongodb-memory-server"
],
"overrides": {
"@push.rocks/smartrequest": "^5.0.1"
},
"patchedDependencies": {
"agentkeepalive@4.5.0": "patches/agentkeepalive@4.5.0.patch"
}
},
"homepage": "https://code.foss.global/push.rocks/webstore",
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/webstore.git"
},
"packageManager": "pnpm@10.28.2"
}
+16
View File
@@ -0,0 +1,16 @@
diff --git a/History.md b/History.md
deleted file mode 100644
index 6877834dd92a5c71416d47b8d5f92a16aff5c1e6..0000000000000000000000000000000000000000
diff --git a/index.js b/index.js
index 6ca1513463724d5ab388b5fa4cfc44df0d93ff3d..cfe41dce77cb5e402e917980b0895c379b8f2033 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,7 @@
'use strict';
-module.exports = require('./lib/agent');
+const HttpAgent = require('./lib/agent');
+module.exports = HttpAgent;
+module.exports.HttpAgent = HttpAgent;
module.exports.HttpsAgent = require('./lib/https_agent');
module.exports.constants = require('./lib/constants');
+8088
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
+187 -28
View File
@@ -1,39 +1,198 @@
# @pushrocks/webstore
high performance storage in the browser using indexed db
# @push.rocks/webstore
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/webstore)
* [gitlab.com (source)](https://gitlab.com/pushrocks/webstore)
* [github.com (source mirror)](https://github.com/pushrocks/webstore)
* [docs (typedoc)](https://pushrocks.gitlab.io/webstore/)
A high-performance, isomorphic key-value storage solution powered by IndexedDB — works seamlessly in the browser and Node.js with zero config.
## Status for master
## Issue Reporting and Security
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/webstore/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/webstore/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/webstore)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/webstore)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/webstore)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/webstore)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/webstore)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
## Install
Install via npm:
```bash
npm install @push.rocks/webstore
```
Or with pnpm:
```bash
pnpm add @push.rocks/webstore
```
## Usage
Use TypeScript for best in class intellisense
`@push.rocks/webstore` provides a clean, Promise-based API over IndexedDB. It auto-detects the runtime environment — in the browser it uses native IndexedDB, on Node.js it transparently loads `fake-indexeddb` for testing and server-side use.
## Contribution
> All methods are fully typed via TypeScript generics. ESM-only (`"type": "module"`).
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
### 🏗️ Creating a Store
For further information read the linked docs at the top of this readme.
Create a `WebStore` instance by specifying a database name and an object store name:
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
```typescript
import { WebStore } from '@push.rocks/webstore';
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
const store = new WebStore<{ name: string; age: number }>({
dbName: 'myAppDatabase',
storeName: 'users',
});
```
The generic type parameter `<T>` defines the shape of values stored — giving you full type safety on `get` and `set` operations.
### 📝 Storing Data
```typescript
await store.set('user:1', { name: 'Alice', age: 30 });
await store.set('user:2', { name: 'Bob', age: 25 });
```
Initialization is automatic — the first call to any data method triggers `init()` behind the scenes, so you don't need to call it manually.
### 📖 Retrieving Data
```typescript
const user = await store.get('user:1');
console.log(user); // { name: 'Alice', age: 30 }
```
Returns `undefined` if the key doesn't exist.
### ✅ Checking Key Existence
```typescript
const exists = await store.check('user:1');
console.log(exists); // true
const missing = await store.check('user:999');
console.log(missing); // false
```
### 🗑️ Deleting Data
Remove a single entry:
```typescript
await store.delete('user:1');
```
Or clear the entire store:
```typescript
await store.clear();
```
### 🔑 Listing All Keys
```typescript
const allKeys = await store.keys();
console.log(allKeys); // ['user:1', 'user:2']
```
### 🌐 Isomorphic by Design
`WebStore` automatically detects the runtime:
- **Browser** → uses the native `IndexedDB` API directly
- **Node.js** → auto-loads `fake-indexeddb` to provide an in-memory IndexedDB implementation
This means the exact same code works in both environments — perfect for universal/isomorphic apps, SSR frameworks, and testing.
```typescript
// Works identically in Node.js and the browser
const store = new WebStore<string>({
dbName: 'config',
storeName: 'settings',
});
await store.set('theme', 'dark');
const theme = await store.get('theme'); // 'dark'
```
### ⚡ Typed Request Caching
For API-heavy applications, `TypedrequestCache` provides a specialized cache layer for typed requests (compatible with `@api.global/typedrequest-interfaces`). It serializes request method + payload as the cache key and stores the full response.
```typescript
import { TypedrequestCache } from '@push.rocks/webstore';
const cache = new TypedrequestCache('api.example.com');
// Cache a request/response pair
await cache.setByRequest({
method: 'getUserProfile',
request: { userId: '123' },
response: { name: 'Alice', role: 'admin' },
});
// Retrieve cached response by matching method + request
const cached = await cache.getByRequest({
method: 'getUserProfile',
request: { userId: '123' },
});
console.log(cached.response); // { name: 'Alice', role: 'admin' }
```
> **Note:** `setByRequest` will throw if the typed request has no `response` field — you can only cache completed request/response pairs.
### 🔄 Lazy Initialization & Deduplication
`WebStore` handles initialization lazily and safely:
- The first data operation automatically triggers `init()`
- Concurrent calls during init are safely queued via a deferred promise
- Calling `init()` explicitly multiple times is safe — subsequent calls are no-ops
```typescript
const store = new WebStore({ dbName: 'mydb', storeName: 'data' });
// Both of these trigger init, but it only runs once
const [a, b] = await Promise.all([
store.get('key1'),
store.get('key2'),
]);
```
## API Reference
### `WebStore<T>`
| Method | Signature | Description |
|--------|-----------|-------------|
| `init()` | `() => Promise<void>` | Explicitly initialize the database (called automatically) |
| `get()` | `(key: string) => Promise<T>` | Retrieve a value by key |
| `set()` | `(key: string, val: T) => Promise<IDBValidKey>` | Store a value under a key |
| `check()` | `(key: string) => Promise<boolean>` | Check if a key exists |
| `delete()` | `(key: string) => Promise<void>` | Delete a single entry |
| `clear()` | `() => Promise<void>` | Remove all entries from the store |
| `keys()` | `() => Promise<IDBValidKey[]>` | Get all keys in the store |
### `TypedrequestCache`
| Method | Signature | Description |
|--------|-----------|-------------|
| `setByRequest()` | `(req: ITypedRequest) => Promise<void>` | Cache a completed typed request |
| `getByRequest()` | `(req: ITypedRequest) => Promise<ITypedRequest>` | Retrieve a cached response by request |
## License and Legal Information
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./license) file.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
### Company Information
Task Venture Capital GmbH
Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
+44
View File
@@ -0,0 +1,44 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as smartntml from '@push.rocks/smartntml';
const smartntmlInstance = new smartntml.Smartntml();
import * as webstore from '../ts/index.js';
let testWebstore: webstore.WebStore;
tap.test('first test', async () => {
testWebstore = new webstore.WebStore({
dbName: 'mytest-db',
storeName: 'mytest-store',
});
expect(testWebstore).toBeInstanceOf(webstore.WebStore);
});
tap.test('should allow storing a string', async () => {
await testWebstore.set('mystring', 'heythere');
expect(await testWebstore.get('mystring')).toEqual('heythere');
});
tap.test('should allow storing an object', async () => {
await testWebstore.set('testProp1', {
wow: 'wowVal',
});
console.log(JSON.stringify(await testWebstore.get('testProp1')));
});
tap.test('should overwrite a value', async () => {
await testWebstore.set('testProp1', {
wow: 'wowVal2',
});
console.log(JSON.stringify(await testWebstore.get('testProp1')));
});
tap.test('should correctly check the existence of keys', async () => {
const resultNotThere = await testWebstore.check('notThere');
const resultThere = await testWebstore.check('testProp1');
expect(resultNotThere).toBeFalse();
expect(resultThere).toBeTrue();
});
export default tap.start();
-24
View File
@@ -1,24 +0,0 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as webstore from '../ts/index';
let testWebstore: webstore.WebStore;
tap.test('first test', async () => {
testWebstore = new webstore.WebStore({
storeName: 'mystore'
});
expect(testWebstore).to.be.instanceOf(webstore.WebStore);
});
tap.test('should init the database', async () => {
await testWebstore.init();
});
tap.test('should store a value', async () => {
await testWebstore.set('testProp1', {
wow: 'wowVal'
});
console.log(JSON.stringify(await testWebstore.get('testProp1')));
});
tap.start();
@@ -0,0 +1,11 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as webstore from '../ts/index.js';
let testTypedrequestcache: webstore.TypedrequestCache;
tap.test('first test', async () => {
testTypedrequestcache = new webstore.TypedrequestCache('https://test.lossless.com/typedrequest');
expect(testTypedrequestcache).toBeInstanceOf(webstore.TypedrequestCache);
});
export default tap.start();
+40
View File
@@ -0,0 +1,40 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as webstore from '../ts/index.js';
let testWebstore: webstore.WebStore;
tap.test('first test', async () => {
testWebstore = new webstore.WebStore({
dbName: 'mytest-db',
storeName: 'mytest-store',
});
expect(testWebstore).toBeInstanceOf(webstore.WebStore);
});
tap.test('should allow storing a string', async () => {
await testWebstore.set('mystring', 'heythere');
expect(await testWebstore.get('mystring')).toEqual('heythere');
});
tap.test('should allow storing an object', async () => {
await testWebstore.set('testProp1', {
wow: 'wowVal',
});
console.log(JSON.stringify(await testWebstore.get('testProp1')));
});
tap.test('should overwrite a value', async () => {
await testWebstore.set('testProp1', {
wow: 'wowVal2',
});
console.log(JSON.stringify(await testWebstore.get('testProp1')));
});
tap.test('should correctly check the existence of keys', async () => {
const resultNotThere = await testWebstore.check('notThere');
const resultThere = await testWebstore.check('testProp1');
expect(resultNotThere).toBeFalse();
expect(resultThere).toBeTrue();
});
export default tap.start();
+8
View File
@@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/webstore',
version: '2.0.22',
description: 'A high-performance storage solution for web applications using IndexedDB.'
}
+2 -1
View File
@@ -1 +1,2 @@
export * from './webstiore.classes.webstore';
export * from './webstore.classes.typedrequestcache.js';
export * from './webstore.classes.webstore.js';
-44
View File
@@ -1,44 +0,0 @@
import * as plugins from './webstore.plugins';
export interface IWebStoreOptions {
storeName: string;
}
export class WebStore<T> {
public db: plugins.idb.IDBPDatabase;
public objectStore: plugins.idb.IDBPObjectStore;
public options: IWebStoreOptions;
constructor(optionsArg: IWebStoreOptions) {
this.options = optionsArg;
}
public async init () {
this.db = await plugins.idb.openDB(this.options.storeName, 1, {
upgrade(db) {
db.createObjectStore('keyval');
},
});
}
async get(key) {
return this.db.get('keyval', key);
}
async set(key, val) {
return this.db.put('keyval', val, key);
}
async delete(key) {
return this.db.delete('keyval', key);
}
async clear() {
return this.db.clear('keyval');
}
async keys() {
return this.db.getAllKeys('keyval');
}
}
+47
View File
@@ -0,0 +1,47 @@
import { WebStore } from './webstore.classes.webstore.js';
import * as plugins from './webstore.plugins.js';
/**
* a cache that can be used to store and retrieve typedrequests
*/
export class TypedrequestCache {
private webstore: WebStore;
constructor(domainArg = 'default') {
this.webstore = new WebStore<plugins.typedrequestInterfaces.ITypedRequest>({
dbName: 'trStore',
storeName: `trStore-${domainArg}`,
});
}
private buildKey(requestArg: plugins.typedrequestInterfaces.ITypedRequest) {
return plugins.smartjson.stringify({
method: requestArg.method,
request: requestArg.request,
});
}
/**
* stores by request
* @param typedrequestarg
*/
public async setByRequest(
typedrequestArg: plugins.typedrequestInterfaces.ITypedRequest
): Promise<void> {
if (!typedrequestArg.response) {
throw new Error('You cannot store requests without a response present');
}
await this.webstore.set(this.buildKey(typedrequestArg), typedrequestArg);
}
/**
* get by full tyoedrequest by partial typedrequest
* @param typedrequestarg
*/
public async getByRequest(
typedrequestArg: plugins.typedrequestInterfaces.ITypedRequest
): Promise<plugins.typedrequestInterfaces.ITypedRequest> {
const result = await this.webstore.get(this.buildKey(typedrequestArg));
return result;
}
}
+75
View File
@@ -0,0 +1,75 @@
import * as plugins from './webstore.plugins.js';
export interface IWebStoreOptions {
dbName: string;
storeName: string;
}
export class WebStore<T = any> {
public db!: plugins.idb.IDBPDatabase;
public options: IWebStoreOptions;
private initCalled: boolean = false;
private readyDeferred = plugins.smartpromise.defer();
constructor(optionsArg: IWebStoreOptions) {
this.options = optionsArg;
}
public async init() {
if (this.initCalled) {
await this.readyDeferred.promise;
return;
}
this.initCalled = true;
const smartenv = new plugins.smartenv.Smartenv();
if (!smartenv.isBrowser && !globalThis.indexedDB) {
console.log('hey');
console.log(globalThis.indexedDB);
await smartenv.getSafeNodeModule('fake-indexeddb/auto');
if (!globalThis.indexedDB) {
const mod = await smartenv.getSafeNodeModule('fake-indexeddb');
globalThis.indexedDB = new mod.IDBFactory();
}
}
this.db = await plugins.idb.openDB(this.options.dbName, 1, {
upgrade: (db) => {
db.createObjectStore(this.options.storeName);
},
});
this.readyDeferred.resolve();
return;
}
async get(key: string): Promise<T> {
await this.init();
return this.db.get(this.options.storeName, key);
}
async check(keyArg: string): Promise<boolean> {
await this.init();
const result = await this.get(keyArg);
return !!result;
}
async set(key: string, val: T) {
await this.init();
return this.db.put(this.options.storeName, val, key);
}
async delete(key: string) {
await this.init();
return this.db.delete(this.options.storeName, key);
}
async clear() {
await this.init();
return this.db.clear(this.options.storeName);
}
async keys() {
await this.init();
return this.db.getAllKeys(this.options.storeName);
}
}
+16 -3
View File
@@ -1,5 +1,18 @@
// pushrocks scope
import * as lik from '@push.rocks/lik';
import * as smartenv from '@push.rocks/smartenv';
import * as smartjson from '@push.rocks/smartjson';
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartrx from '@push.rocks/smartrx';
export { lik, smartenv, smartjson, smartpromise, smartrx };
// apiglobal scope
import * as typedrequestInterfaces from '@api.global/typedrequest-interfaces';
export { typedrequestInterfaces };
// thirdparty scope
import * as idb from 'idb';
export {
idb
}
export { idb };
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noImplicitAny": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true,
"types": ["node"]
},
"exclude": [
"dist_*/**/*.d.ts"
]
}
-17
View File
@@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}