-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
830 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Deno | ||
uses: denoland/setup-deno@v1 | ||
|
||
- name: Verify formatting | ||
run: deno fmt --check | ||
|
||
- name: Run linter | ||
run: deno task lint | ||
|
||
- name: Run TypeScript checking | ||
run: deno task check | ||
|
||
- name: Run tests | ||
run: deno task test | ||
|
||
- name: Publish dry run | ||
run: deno publish --dry-run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Publish | ||
|
||
on: | ||
workflow_run: | ||
workflows: [ci] | ||
types: [completed] | ||
branches: [main] | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Deno | ||
uses: denoland/setup-deno@v1 | ||
|
||
- name: Publish package | ||
run: deno publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
{ | ||
"deno.enable": true, | ||
"deno.lint": true, | ||
"deno.unstable": true, | ||
"deno.importMap": "./_test/import_map.web_storage.json", | ||
"editor.defaultFormatter": "denoland.vscode-deno", | ||
"editor.tabSize": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
and this project adheres to | ||
[Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.1.0] | ||
|
||
- Initial release on JSR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,9 @@ | ||
# Pluggable Storage Modules for Deno | ||
# Pluggable Storage Modules | ||
|
||
NOTE: This is an experimental module. | ||
NOTE: This is an experimental library. | ||
|
||
Each module here provides the same interface to a hierarchical key -> value | ||
storage mechanism. So they can be imported directly or as swappable interface | ||
via an import map, for example: | ||
via an import map. | ||
|
||
```json | ||
{ | ||
"imports": { | ||
"$store": "https://deno.land/x/storage_modules/deno_fs.ts" | ||
} | ||
} | ||
``` | ||
|
||
## Functions | ||
|
||
Each function takes a hierarchical key as an array of strings. It's up to the | ||
storage module how those are translated to the underlying storage. But it may be | ||
best to assume the first level key to be a grouping level, eg. a database name. | ||
|
||
Any JSON serializable value can be stored. | ||
|
||
See the [types](./types.ts) for a description of the module interface. | ||
|
||
## Modules | ||
|
||
### web_storage.ts | ||
|
||
This uses `localStorage` of the standard | ||
[Web Storage](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API) | ||
API. | ||
|
||
The parts of the key are joined with a `/` to form a single key string for use | ||
with the `localStorage` API. | ||
|
||
Import mapping: `"$store": "https://deno.land/x/storage_modules/web_storage.ts"` | ||
|
||
### deno_fs.ts | ||
|
||
This stores values in individual files under a directory hierarchy via | ||
[Deno fs](https://deno.land/api?s=Deno.readTextFile) calls. By default this is | ||
under a `.store` dir under the current working dir. This can be overridden via | ||
the environment var `STORE_FS_ROOT`. | ||
|
||
Each level of the key becomes a directory up to the last segment which becomes a | ||
JSON file. | ||
|
||
eg: `["one", "two", "three"]` -> `.store/one/two/three.json` | ||
|
||
Import mapping: `"$store": "https://deno.land/x/storage_modules/deno_fs.ts"` | ||
|
||
### deno_kv.ts | ||
|
||
Use the [Deno KV](https://deno.land/manual/runtime/kv) API for storage. | ||
|
||
Import mapping: `"$store": "https://deno.land/x/storage_modules/deno_kv.ts"` | ||
|
||
### deno_kv_fs.ts | ||
|
||
Combination of a readonly `deno_fs.ts` and `deno_kv.ts`, allowing fallback or | ||
immutable storage in the filesystem, and mutable storage via the KV store. | ||
|
||
By default the filesystem takes priority, and cannot be overridden by KV values, | ||
unless the env var `STORE_PRIMARY` is set to `kv`, in which case the KV always | ||
overrides filesystem values. | ||
See [./store/README.md] for more details. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
{ | ||
"unstable": [ | ||
"kv" | ||
], | ||
"tasks": { | ||
"test:web_storage": "deno test --check --import-map=./_test/import_map.web_storage.json", | ||
"test:deno_fs": "deno test --check --allow-read --allow-write --allow-env --import-map=./_test/import_map.deno_fs.json", | ||
"test:deno_kv": "deno test --check --unstable --allow-env --import-map=./_test/import_map.deno_kv.json", | ||
"test:deno_kv_fs": "deno test --check --unstable --allow-read --allow-env --import-map=./_test/import_map.deno_kv_fs.json", | ||
"test": "deno task test:web_storage; deno task test:deno_fs; deno task test:deno_kv; deno task test:deno_kv_fs", | ||
"check": "deno fmt && deno lint && deno task test" | ||
"test": "deno test --allow-env --allow-read --allow-write --allow-net", | ||
"reload": "deno cache --reload **/*.ts jsr:@check/deps", | ||
"check": "deno check **/*.ts", | ||
"lint": "deno lint", | ||
"ok": "deno fmt && deno task lint && deno task check && deno task test && deno publish --dry-run --allow-dirty", | ||
"outdated": "deno run --allow-read=. --allow-net=jsr.io,registry.npmjs.org jsr:@check/deps", | ||
"lock": "rm -f deno.lock && deno task check" | ||
}, | ||
"workspaces": [ | ||
"./store", | ||
"./store-common", | ||
"./store-deno-fs", | ||
"./store-deno-kv", | ||
"./store-deno-kv-fs", | ||
"./store-web-storage" | ||
], | ||
"imports": { | ||
"@std/assert": "jsr:@std/assert@^1.0.0-rc.3", | ||
"@std/fs": "jsr:@std/fs@^1.0.0-rc.3", | ||
"@std/path": "jsr:@std/path@^1.0.0-rc.3", | ||
"@std/url": "jsr:@std/url@^1.0.0-rc.2" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Common types and utilities for Pluggable Storage Modules | ||
|
||
See [@jollytoad/store](https://jsr.io/@jollytoad/store) for the bigger picture. | ||
|
||
This package provides the storage module interface definition and some reusable | ||
utility function for use by implementations. | ||
|
||
- [the interface](./types.ts) | ||
- [key conversion utils](./key-utils.ts) | ||
- [test utils](./test-storage-module.ts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@jollytoad/store-common", | ||
"version": "0.1.0", | ||
"exports": { | ||
"./key-utils": "./key-utils.ts", | ||
"./test-storage-module": "./test-storage-module.ts", | ||
"./types": "./types.ts" | ||
} | ||
} |
Oops, something went wrong.