@owlmeans/redis-resource 0.1.18-rc.11 → 0.1.18-rc.13
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
CHANGED
|
@@ -13,7 +13,7 @@ Redis-backed resource with pub/sub, keyspace watching and streams for real-time
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
bun add @owlmeans/redis-resource
|
|
16
|
+
bun add @owlmeans/redis-resource@^0.1.18-rc.11
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
@@ -143,7 +143,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
143
143
|
your project's skill store (`.agents/skills/`):
|
|
144
144
|
|
|
145
145
|
```sh
|
|
146
|
-
npx @owlmeans/agent-skills
|
|
146
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.13
|
|
147
147
|
```
|
|
148
148
|
|
|
149
149
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/redis-resource",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-09-
|
|
4
|
+
"version": "0.1.18-rc.13",
|
|
5
|
+
"generatedAt": "2026-09-10T18:54:42.497Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -8,19 +8,23 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/redis-resource
|
|
9
9
|
|
|
10
10
|
**Layer:** Infra
|
|
11
|
-
**Install:** `"@owlmeans/redis-resource": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/redis-resource": "^0.1.18-rc.13"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
## Key Exports
|
|
14
14
|
|
|
15
15
|
| Export | Description |
|
|
16
16
|
|--------|-------------|
|
|
17
17
|
| `makeRedisResource<R>(alias, dbAlias?, serviceAlias?)` | Factory for a Redis-backed `Resource<R>`. Both alias defaults are `DEFAULT_DB_ALIAS` (`'redis'`) |
|
|
18
|
-
| `RedisResource<R>` | `Resource<R>` plus the `PubSubResource`, `WatchableResource` and `StreamResource` capabilities, `db` and `key(id?)` |
|
|
19
|
-
| `RedisDb`, `RedisClient`, `RedisDbService` |
|
|
20
|
-
| `DEFAULT_DB_ALIAS`, `DEFAULT_PAGE_SIZE`, `SCAN_BATCH`, `READ_BATCH
|
|
18
|
+
| `RedisResource<R>` | `Resource<R>` plus the `PubSubResource`, `WatchableResource` and `StreamResource` capabilities, `db`, `name` and `key(id?)` |
|
|
19
|
+
| `RedisDb`, `RedisClient`, `RedisDbService`, `RedisConnection` | The db and connection contracts — `@owlmeans/redis` implements them |
|
|
20
|
+
| `DEFAULT_DB_ALIAS`, `DEFAULT_PAGE_SIZE`, `SCAN_BATCH`, `READ_BATCH` | Constants for the record half |
|
|
21
|
+
| `STREAM_MAX_LENGTH`, `DEFAULT_STREAM_BLOCK`, `RECLAIM_IDLE`, `RECLAIM_COUNT`, `CONSUMER_ID_LENGTH` | Constants for the stream half |
|
|
21
22
|
|
|
22
|
-
Keys are namespaced by the db config's
|
|
23
|
-
`resource.key(id)` → `<
|
|
23
|
+
Keys are namespaced by the db config's key prefix plus the resource's name:
|
|
24
|
+
`resource.key(id)` → `<prefix>-<name>:<id>`, and `key()` with no argument yields the namespace's
|
|
25
|
+
glob. The name is `resource.name` when set and the registration alias otherwise, so two resources
|
|
26
|
+
can share one namespace deliberately — and a `name` given by accident quietly merges two id spaces.
|
|
27
|
+
Every non-word character in either half is collapsed to `_`.
|
|
24
28
|
|
|
25
29
|
## Usage
|
|
26
30
|
|
|
@@ -82,9 +86,11 @@ a renewal must pass a TTL again — otherwise the record becomes persistent.
|
|
|
82
86
|
`UnknownRecordError` when the key is gone. Both use `GETDEL`, so two callers can never be handed
|
|
83
87
|
the same record. Choose by whether absence is an error.
|
|
84
88
|
- `create` generates an id when the record carries none, and refuses an id that is already there
|
|
85
|
-
(`RecordExists`) using `SET NX` — no read-then-write race.
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
(`RecordExists`) using `SET NX` — no read-then-write race. The id is written into the stored
|
|
90
|
+
record, so what comes back always carries one.
|
|
91
|
+
- `update` **replaces** the whole record and throws `UnknownRecordError` for an unknown id (and
|
|
92
|
+
`MisshapedRecord` when the record carries no id at all). It does not merge over what was stored;
|
|
93
|
+
pass every field that must survive.
|
|
88
94
|
- `save` creates when the record carries no id and replaces otherwise — that is the upsert.
|
|
89
95
|
- `purge(where)` refuses an empty criteria object. Use it instead of a page loop that deletes each
|
|
90
96
|
item.
|
|
@@ -93,20 +99,20 @@ a renewal must pass a TTL again — otherwise the record becomes persistent.
|
|
|
93
99
|
namespace. `watch(id, handler, { once?, ttl? })` is the keyspace-notification form for ONE
|
|
94
100
|
record — the handler receives the current value on every write, and `null` once the key is gone.
|
|
95
101
|
They are separate methods; a channel is never passed as a bare string.
|
|
96
|
-
-
|
|
97
|
-
|
|
102
|
+
- `watch` subscribes to `__keyspace@0__:`, while redis publishes keyspace events per database as
|
|
103
|
+
`__keyspace@<db>__:`. So a resource on a connection whose `meta.dbIndex` is anything but 0 gets
|
|
104
|
+
no notifications at all and its `watch` handler silently never fires — deployments sharing one
|
|
105
|
+
instance isolate on the key prefix, not on the db index. The server also needs
|
|
106
|
+
`notify-keyspace-events` enabled; it emits nothing otherwise.
|
|
98
107
|
- `stream(key, value)` appends to a namespaced redis stream, trimmed approximately to
|
|
99
108
|
`STREAM_MAX_LENGTH` so trimming stays cheap. `consume(key, { group?, consumer?, block? })` is the
|
|
100
109
|
async generator that reads it — with no `group` it tails from now with `XREAD`, with one it joins
|
|
101
110
|
the consumer group and reclaims stale entries under the **passed** consumer name. Claiming them
|
|
102
111
|
for a fixed name leaves them owned by a consumer that never reads.
|
|
103
112
|
- Requires redis 6.2 or newer (`GETDEL`).
|
|
104
|
-
- Assert an expiry by reading `PTTL` back from redis, never by trusting that a command was issued
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
## Depends On
|
|
108
|
-
|
|
109
|
-
- `@owlmeans/redis`, `@owlmeans/resource`, `@owlmeans/server-context`, `@owlmeans/basic-ids`
|
|
113
|
+
- Assert an expiry by reading `PTTL` back from redis, never by trusting that a command was issued.
|
|
114
|
+
An expiry set in the wrong unit is still an expiry — just one tens of millennia out — so only the
|
|
115
|
+
value redis reports back proves anything.
|
|
110
116
|
|
|
111
117
|
## Tests
|
|
112
118
|
|
|
@@ -115,3 +121,18 @@ this contract; putting them here would need a devDependency on this package's ow
|
|
|
115
121
|
Gated on `REDIS_URL` (see `/.env.example`); each suite namespaces its keys and flushes them, and a
|
|
116
122
|
spec that walks the namespace boots under its own resource alias so it never sees another test's
|
|
117
123
|
records.
|
|
124
|
+
|
|
125
|
+
## Depends On
|
|
126
|
+
|
|
127
|
+
- `@owlmeans/resource` · `@owlmeans/context` · `@owlmeans/server-context` · `@owlmeans/basic-ids`
|
|
128
|
+
- peer `ioredis` (the client types every method is written against), `ajv`
|
|
129
|
+
|
|
130
|
+
`@owlmeans/redis` is NOT a dependency — it depends on this package, and that is the direction the
|
|
131
|
+
connection contracts flow in.
|
|
132
|
+
|
|
133
|
+
## Related
|
|
134
|
+
|
|
135
|
+
- `redis` — the connection service implementing `RedisDbService`, and the `cfg.dbs` entry a
|
|
136
|
+
resource takes its prefix and db index from
|
|
137
|
+
- `redis-queue` — BullMQ queues on the same connections
|
|
138
|
+
- `resource` — the criteria language, paging and the error classes raised here
|
package/build/resource.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACuC,cAAc,EAEhE,MAAM,oBAAoB,CAAA;AAK3B,OAAO,KAAK,EAA+B,aAAa,EAAE,MAAM,YAAY,CAAA;AAY5E;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC5B,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACuC,cAAc,EAEhE,MAAM,oBAAoB,CAAA;AAK3B,OAAO,KAAK,EAA+B,aAAa,EAAE,MAAM,YAAY,CAAA;AAY5E;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC5B,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,4BAE7C,MAAM,8CACZ,CAmZF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/redis-resource",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"ioredis": "*"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@owlmeans/basic-ids": "^0.1.18-rc.
|
|
29
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
30
|
-
"@owlmeans/resource": "^0.1.18-rc.
|
|
31
|
-
"@owlmeans/server-context": "^0.1.18-rc.
|
|
28
|
+
"@owlmeans/basic-ids": "^0.1.18-rc.10",
|
|
29
|
+
"@owlmeans/context": "^0.1.18-rc.9",
|
|
30
|
+
"@owlmeans/resource": "^0.1.18-rc.10",
|
|
31
|
+
"@owlmeans/server-context": "^0.1.18-rc.13"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@owlmeans/dep-config": "workspace:*",
|