@owlmeans/client-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
@@ -12,7 +12,7 @@ Client-side resource persistence layer — browser key-value storage backed reso
12
12
  ## Installation
13
13
 
14
14
  ```bash
15
- bun add @owlmeans/client-resource
15
+ bun add @owlmeans/client-resource@^0.1.18-rc.12
16
16
  ```
17
17
 
18
18
  ## Usage
@@ -80,7 +80,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
80
80
  your project's skill store (`.agents/skills/`):
81
81
 
82
82
  ```sh
83
- npx @owlmeans/agent-skills
83
+ npx @owlmeans/agent-skills@^0.1.18-rc.12
84
84
  ```
85
85
 
86
86
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
3
  "package": "@owlmeans/client-resource",
4
- "version": "0.1.18-rc.11",
5
- "generatedAt": "2026-09-01T16:28:56.993Z",
4
+ "version": "0.1.18-rc.13",
5
+ "generatedAt": "2026-09-04T22:43:25.448Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -8,7 +8,7 @@ user-invocable: false
8
8
  # @owlmeans/client-resource
9
9
 
10
10
  **Layer:** Client
11
- **Install:** `"@owlmeans/client-resource": "^0.1.18-rc.11"` in `dependencies`
11
+ **Install:** `"@owlmeans/client-resource": "^0.1.18-rc.13"` in `dependencies`
12
12
 
13
13
  ## Key Exports
14
14
 
@@ -27,12 +27,22 @@ import { appendClientResource } from '@owlmeans/client-resource'
27
27
  appendClientResource<Config, Context, Project>(context, 'projects')
28
28
 
29
29
  const projects = context.resource<ClientResource<Project>>('projects')
30
- await projects.list({ status: ['open', 'blocked'] }, { sort: ['createdAt'] })
30
+ const { items, total } = await projects.list({ status: ['open', 'blocked'] }, { sort: ['createdAt'] })
31
31
  ```
32
32
 
33
- The backing store comes from `cfg.dbs` — the entry whose `alias` matches the resource's, with
34
- `schema` naming the store (`@owlmeans/web-db` supplies the browser one). Without an entry the
35
- resource falls back to the default `client-db` service under its own alias.
33
+ The backing store comes from `cfg.dbs` — the `DbConfig` entry whose `alias` equals the resource's.
34
+ `service` is the field that selects the backend: it names the `ClientDbService` to ask, and it is
35
+ required by the type, as is `host`, which nothing on this path reads. `schema` names the store
36
+ inside that service and defaults to the resource alias. So an entry is
37
+ `{ alias: 'projects', service: MY_DB, host: [], schema? }`.
38
+
39
+ With no matching entry the resource asks `DEFAULT_DB_ALIAS` (`client-db`) for a store named after
40
+ itself — which is why a single-backend app (`@owlmeans/web-db` registered under that alias) writes
41
+ no `dbs` entries at all, and a second backend is chosen by adding one that names another service.
42
+
43
+ That binding happens in `init()`, which the context runs while it initializes. Every operation
44
+ before it throws `ResourceError('nodb-client-resource:<alias>')` — read that as "this resource was
45
+ used before its context was ready", not as a storage failure.
36
46
 
37
47
  ## A key-value store dressed as a resource
38
48
 
@@ -43,17 +53,23 @@ is. So:
43
53
  - `load(where)`, `get(where)`, `list`, `count` and `purge` read the whole set and evaluate through
44
54
  the shared in-memory engine from `@owlmeans/resource`, which is what makes a criteria object mean
45
55
  here exactly what it means against a relational store. `{ sort }` orders the result the same way.
46
- - **Unpaged**: `list(where)` with no `size` returns every match; `size: 0` says the same thing
47
- explicitly, and `page` without `size` throws `UnsupportedArgumentError('page-without-size')`.
48
- - `create` mints an id when the record carries none and throws `RecordExists` for one already
49
- stored; `update` **replaces** the whole record and throws `UnknownRecordError` for an unknown id;
50
- `save` creates or replaces. `take(id)` **deletes** the record it returns.
56
+ - `list` answers with the shared `ListResult` `{ items, total }`, and `page` / `size` echoed back
57
+ as well when a size was asked for. **Unpaged by default**: no `size` (or `size: 0`) returns every
58
+ match, and `page` without `size` throws `UnsupportedArgumentError('page-without-size')`. The
59
+ contract is the one every store shares [[resource]].
60
+ - `create` mints a base58 id when the record carries none and throws `RecordExists` for one already
61
+ stored; `update` **replaces** the whole record, throwing `MisshapedRecord('id')` for a record that
62
+ carries no id and `UnknownRecordError` for an id the store does not hold; `save` creates when
63
+ there is no id or no stored record and replaces otherwise. `take(id)` **deletes** the record it
64
+ returns.
51
65
  - `purge(where)` refuses an empty criteria object. `erase()` empties the store, index included.
52
66
 
53
67
  ## Depends On
54
68
 
55
- - `@owlmeans/resource`, `@owlmeans/client-context`, `@scure/base`, `@noble/hashes`
69
+ - `@owlmeans/resource` (the shared criteria engine), `@owlmeans/client-context`, `@owlmeans/context`
70
+ - `@scure/base`, `@noble/hashes` — the base58 id minted for a record that arrives without one
56
71
 
57
72
  ## Related
58
73
 
74
+ - [[resource]] — the criteria engine, `ListResult` and the shared resource contract
59
75
  - [[web-db]] — the browser IndexedDB backend behind `ClientDbService`
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAM3E,OAAO,KAAK,EAAuC,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAM7F,KAAK,MAAM,GAAG,YAAY,CAAA;AAC1B,UAAU,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;CAAI;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,cAAc,GAAG,cAAc,EACjF,SAAS,CAAC,EAAE,OAAO,MAAM,KAAG,CAuJ7B,CAAA"}
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAM3E,OAAO,KAAK,EAAuC,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAM7F,KAAK,MAAM,GAAG,YAAY,CAAA;AAC1B,UAAU,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;CAAI;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,cAAc,GAAG,cAAc,WACxE,CAAC,SAAS,MAAM,KAAG,CAuJ7B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/client-resource",
3
- "version": "0.1.18-rc.11",
3
+ "version": "0.1.18-rc.13",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -22,9 +22,9 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@noble/hashes": "^1.5.0",
25
- "@owlmeans/client-context": "^0.1.18-rc.11",
26
- "@owlmeans/context": "^0.1.18-rc.7",
27
- "@owlmeans/resource": "^0.1.18-rc.8",
25
+ "@owlmeans/client-context": "^0.1.18-rc.13",
26
+ "@owlmeans/context": "^0.1.18-rc.8",
27
+ "@owlmeans/resource": "^0.1.18-rc.9",
28
28
  "@scure/base": "^2.3.0"
29
29
  },
30
30
  "devDependencies": {