@owlmeans/static-resource 0.1.18-rc.9 → 0.1.18
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 +2 -2
- package/agent-meta/manifest.json +3 -3
- package/agent-meta/skills/static-resource/SKILL.md +6 -4
- package/build/resource.d.ts.map +1 -1
- package/build/resource.js +13 -6
- package/build/resource.js.map +1 -1
- package/package.json +5 -5
- package/src/resource.ts +15 -9
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ In-memory `Resource<T>` backed by static config data — for read-only data load
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
bun add @owlmeans/static-resource@^0.1.18
|
|
15
|
+
bun add @owlmeans/static-resource@^0.1.18
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
@@ -63,7 +63,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
63
63
|
your project's skill store (`.agents/skills/`):
|
|
64
64
|
|
|
65
65
|
```sh
|
|
66
|
-
npx @owlmeans/agent-skills@^0.1.18
|
|
66
|
+
npx @owlmeans/agent-skills@^0.1.18
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
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
|
-
"schemaVersion":
|
|
2
|
+
"schemaVersion": 3,
|
|
3
3
|
"package": "@owlmeans/static-resource",
|
|
4
|
-
"version": "0.1.18
|
|
5
|
-
"generatedAt": "2026-
|
|
4
|
+
"version": "0.1.18",
|
|
5
|
+
"generatedAt": "2026-10-28T00:31:34.772Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -8,7 +8,7 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/static-resource
|
|
9
9
|
|
|
10
10
|
**Layer:** Infra
|
|
11
|
-
**Install:** `"@owlmeans/static-resource": "^0.1.18
|
|
11
|
+
**Install:** `"@owlmeans/static-resource": "^0.1.18"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
The whole `Resource` contract over a `Map` held at module scope. Use it where records must be
|
|
14
14
|
reachable through the context like any other resource but have no database behind them — fixtures,
|
|
@@ -40,9 +40,11 @@ await fixtures.list({ name: { $startsWith: 'Owl' } }, { sort: ['name'] })
|
|
|
40
40
|
|
|
41
41
|
## Semantics
|
|
42
42
|
|
|
43
|
-
- The store is a map keyed by id
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
- The store is a map keyed by id. **`create` mints one (`randomUUID()`) when the record carries
|
|
44
|
+
none** — what a Mongo or Postgres `create()` does, so code written against those backends runs
|
|
45
|
+
unchanged over this one — and honours a supplied id, throwing `RecordExists` only when that id is
|
|
46
|
+
already stored. `update` and `save` need an id and throw `MisshapedRecord('id')` without one;
|
|
47
|
+
`update` also throws `UnknownRecordError`, and `save` is the upsert.
|
|
46
48
|
- `load(id)` / `get(id)` / `delete(id)` / `take(id)` hit the map directly. `take(id)` **deletes**
|
|
47
49
|
the record it returns and throws `UnknownRecordError` on a miss.
|
|
48
50
|
- `load(where)`, `get(where)`, `list`, `count` and `purge` go through the shared in-memory engine
|
package/build/resource.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAC2B,QAAQ,EAAE,cAAc,EAC9D,MAAM,oBAAoB,CAAA;AAI3B,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAYvE,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,cAAc,GAAG,cAAc,UACrE,MAAM,QAAwB,MAAM,KAC1C,QAAQ,CAAC,CAAC,CAkIZ,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,OACpE,CAAC,UAAS,MAAM,QAAwB,MAAM,KAClD,CAAC,GAAG,oBAWN,CAAA"}
|
package/build/resource.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
1
2
|
import { appendContextual } from '@owlmeans/context';
|
|
2
3
|
import { DEFAULT_ALIAS } from './consts.js';
|
|
3
|
-
import {
|
|
4
|
+
import { MisshapedRecord, RecordExists, recordQueryHelper, UnknownRecordError, UnsupportedArgumentError } from '@owlmeans/resource';
|
|
4
5
|
const stores = {};
|
|
5
6
|
/**
|
|
6
7
|
* Milliseconds until the record expires, which is what `setTimeout` wants. A number is seconds
|
|
@@ -27,7 +28,7 @@ export const createStaticResource = (alias = DEFAULT_ALIAS, key) => {
|
|
|
27
28
|
/** An id hits the map directly; criteria go through the shared in-memory engine. */
|
|
28
29
|
const first = (idOrWhere, opts) => typeof idOrWhere === 'string'
|
|
29
30
|
? getStore().get(idOrWhere) ?? null
|
|
30
|
-
: firstMatch(records(), idOrWhere, opts);
|
|
31
|
+
: recordQueryHelper.firstMatch(records(), idOrWhere, opts);
|
|
31
32
|
const write = (record, opts) => {
|
|
32
33
|
if (record.id == null) {
|
|
33
34
|
/**
|
|
@@ -54,12 +55,18 @@ export const createStaticResource = (alias = DEFAULT_ALIAS, key) => {
|
|
|
54
55
|
if (opts?.page != null && opts.size == null) {
|
|
55
56
|
throw new UnsupportedArgumentError('page-without-size');
|
|
56
57
|
}
|
|
57
|
-
return applyQuery(records(), where, opts);
|
|
58
|
+
return recordQueryHelper.applyQuery(records(), where, opts);
|
|
58
59
|
},
|
|
59
|
-
count: async (where) => filterRecords(records(), where).length,
|
|
60
|
+
count: async (where) => recordQueryHelper.filterRecords(records(), where).length,
|
|
60
61
|
create: async (record, opts) => {
|
|
62
|
+
/**
|
|
63
|
+
* A supplied id is honored (many callers key by a natural id, Redis-style) — but a missing
|
|
64
|
+
* one is minted here rather than rejected, the same as a real Mongo/Postgres `create()`
|
|
65
|
+
* auto-generates its own id when the caller supplies none. Only a supplied id that already
|
|
66
|
+
* exists is `RecordExists`.
|
|
67
|
+
*/
|
|
61
68
|
if (record.id == null) {
|
|
62
|
-
|
|
69
|
+
record = { ...record, id: randomUUID() };
|
|
63
70
|
}
|
|
64
71
|
if (getStore().has(record.id)) {
|
|
65
72
|
throw new RecordExists(record.id);
|
|
@@ -99,7 +106,7 @@ export const createStaticResource = (alias = DEFAULT_ALIAS, key) => {
|
|
|
99
106
|
throw new UnsupportedArgumentError('purge:empty-criteria');
|
|
100
107
|
}
|
|
101
108
|
const store = getStore();
|
|
102
|
-
const matched = filterRecords(records(), where);
|
|
109
|
+
const matched = recordQueryHelper.filterRecords(records(), where);
|
|
103
110
|
matched.forEach(record => record.id != null && store.delete(record.id));
|
|
104
111
|
return matched.length;
|
|
105
112
|
}
|
package/build/resource.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAI3C,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAI3C,OAAO,EACL,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,wBAAwB,EAC/F,MAAM,oBAAoB,CAAA;AAG3B,MAAM,MAAM,GAAg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,GAAW,aAAa,EAAE,GAAY,EACzB,EAAE;IAC5B,MAAM,QAAQ,GAAG,oBAAoB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAEjD,MAAM,IAAI,GAAG,GAA+B,CAAA;IAE5C,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IAC/B,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAA;IACzE,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/static-resource",
|
|
3
|
-
"version": "0.1.18
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@owlmeans/context": "^0.1.18
|
|
25
|
-
"@owlmeans/error": "^0.1.18
|
|
26
|
-
"@owlmeans/resource": "^0.1.18
|
|
24
|
+
"@owlmeans/context": "^0.1.18",
|
|
25
|
+
"@owlmeans/error": "^0.1.18",
|
|
26
|
+
"@owlmeans/resource": "^0.1.18"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@owlmeans/dep-config": "
|
|
29
|
+
"@owlmeans/dep-config": "^0.1.18",
|
|
30
30
|
"nodemon": "^3.1.14",
|
|
31
31
|
"typescript": "^7.0.2"
|
|
32
32
|
},
|
package/src/resource.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto'
|
|
1
2
|
import { appendContextual } from '@owlmeans/context'
|
|
2
3
|
import { DEFAULT_ALIAS } from './consts.js'
|
|
3
4
|
import type {
|
|
4
5
|
Criteria, FirstOptions, ListOptions, Resource, ResourceRecord, Ttl, WriteOptions
|
|
5
6
|
} from '@owlmeans/resource'
|
|
6
7
|
import {
|
|
7
|
-
|
|
8
|
-
UnsupportedArgumentError
|
|
8
|
+
MisshapedRecord, RecordExists, recordQueryHelper, UnknownRecordError, UnsupportedArgumentError
|
|
9
9
|
} from '@owlmeans/resource'
|
|
10
10
|
import type { Config, Context, StaticResourceAppend } from './types.js'
|
|
11
11
|
|
|
@@ -46,7 +46,7 @@ export const createStaticResource = <T extends ResourceRecord = ResourceRecord>(
|
|
|
46
46
|
const first = (idOrWhere: string | Criteria<T>, opts?: FirstOptions<T>): T | null =>
|
|
47
47
|
typeof idOrWhere === 'string'
|
|
48
48
|
? getStore().get(idOrWhere) ?? null
|
|
49
|
-
: firstMatch(records(), idOrWhere, opts)
|
|
49
|
+
: recordQueryHelper.firstMatch(records(), idOrWhere, opts)
|
|
50
50
|
|
|
51
51
|
const write = (record: Partial<T>, opts?: WriteOptions): T => {
|
|
52
52
|
if (record.id == null) {
|
|
@@ -81,17 +81,23 @@ export const createStaticResource = <T extends ResourceRecord = ResourceRecord>(
|
|
|
81
81
|
throw new UnsupportedArgumentError('page-without-size')
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
return applyQuery(records(), where, opts)
|
|
84
|
+
return recordQueryHelper.applyQuery(records(), where, opts)
|
|
85
85
|
},
|
|
86
86
|
|
|
87
|
-
count: async (where?: Criteria<T>) => filterRecords(records(), where).length,
|
|
87
|
+
count: async (where?: Criteria<T>) => recordQueryHelper.filterRecords(records(), where).length,
|
|
88
88
|
|
|
89
89
|
create: async (record: Partial<T>, opts?: WriteOptions) => {
|
|
90
|
+
/**
|
|
91
|
+
* A supplied id is honored (many callers key by a natural id, Redis-style) — but a missing
|
|
92
|
+
* one is minted here rather than rejected, the same as a real Mongo/Postgres `create()`
|
|
93
|
+
* auto-generates its own id when the caller supplies none. Only a supplied id that already
|
|
94
|
+
* exists is `RecordExists`.
|
|
95
|
+
*/
|
|
90
96
|
if (record.id == null) {
|
|
91
|
-
|
|
97
|
+
record = { ...record, id: randomUUID() }
|
|
92
98
|
}
|
|
93
|
-
if (getStore().has(record.id)) {
|
|
94
|
-
throw new RecordExists(record.id)
|
|
99
|
+
if (getStore().has(record.id as string)) {
|
|
100
|
+
throw new RecordExists(record.id as string)
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
return write(record, opts)
|
|
@@ -137,7 +143,7 @@ export const createStaticResource = <T extends ResourceRecord = ResourceRecord>(
|
|
|
137
143
|
throw new UnsupportedArgumentError('purge:empty-criteria')
|
|
138
144
|
}
|
|
139
145
|
const store = getStore()
|
|
140
|
-
const matched = filterRecords(records(), where)
|
|
146
|
+
const matched = recordQueryHelper.filterRecords(records(), where)
|
|
141
147
|
matched.forEach(record => record.id != null && store.delete(record.id))
|
|
142
148
|
|
|
143
149
|
return matched.length
|