@x12i/static-memorix 2.0.0
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/LICENSE +21 -0
- package/README.md +431 -0
- package/dist/cli.d.ts +17 -0
- package/dist/cli.js +278 -0
- package/dist/config.d.ts +39 -0
- package/dist/config.js +109 -0
- package/dist/engine/aliases.d.ts +32 -0
- package/dist/engine/aliases.js +74 -0
- package/dist/engine/associations.d.ts +26 -0
- package/dist/engine/associations.js +60 -0
- package/dist/engine/identity.d.ts +22 -0
- package/dist/engine/identity.js +50 -0
- package/dist/engine/inventory.d.ts +29 -0
- package/dist/engine/inventory.js +133 -0
- package/dist/engine/lists.d.ts +18 -0
- package/dist/engine/lists.js +62 -0
- package/dist/engine/narratives.d.ts +16 -0
- package/dist/engine/narratives.js +67 -0
- package/dist/engine/objectTypes.d.ts +11 -0
- package/dist/engine/objectTypes.js +71 -0
- package/dist/engine/query.d.ts +38 -0
- package/dist/engine/query.js +191 -0
- package/dist/engine/records.d.ts +23 -0
- package/dist/engine/records.js +152 -0
- package/dist/engine/snapshots.d.ts +17 -0
- package/dist/engine/snapshots.js +110 -0
- package/dist/engine/write.d.ts +30 -0
- package/dist/engine/write.js +163 -0
- package/dist/routes/helpers.d.ts +4 -0
- package/dist/routes/helpers.js +29 -0
- package/dist/routes/index.d.ts +2 -0
- package/dist/routes/index.js +402 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.js +130 -0
- package/dist/storage/InMemoryStore.d.ts +31 -0
- package/dist/storage/InMemoryStore.js +242 -0
- package/dist/storage/fs.d.ts +6 -0
- package/dist/storage/fs.js +54 -0
- package/dist/types.d.ts +88 -0
- package/dist/types.js +37 -0
- package/guides/demo-app.md +527 -0
- package/guides/managing-json-files.md +384 -0
- package/guides/running-the-service.md +269 -0
- package/guides/using-the-api.md +265 -0
- package/mocks/data/admin/snapshots.json +52 -0
- package/mocks/data/assets/analysis.json +14 -0
- package/mocks/data/assets/decisions.json +14 -0
- package/mocks/data/assets/events.json +4 -0
- package/mocks/data/assets/snapshots.json +49 -0
- package/mocks/data/findings/analysis.json +4 -0
- package/mocks/data/findings/decisions.json +4 -0
- package/mocks/data/findings/events.json +3 -0
- package/mocks/data/findings/snapshots.json +21 -0
- package/mocks/data/marketing/snapshots.json +75 -0
- package/mocks/data/memory/memory.json +31 -0
- package/mocks/data/product/snapshots.json +84 -0
- package/mocks/data/system/inventory.json +8 -0
- package/mocks/data/users/snapshots.json +5 -0
- package/mocks/demo.html +828 -0
- package/mocks/metadata/agents.json +7 -0
- package/mocks/metadata/lists/assets-default.json +22 -0
- package/mocks/metadata/lists/backlog.json +10 -0
- package/mocks/metadata/lists/findings-default.json +9 -0
- package/mocks/metadata/lists/my-plate.json +10 -0
- package/mocks/metadata/lists/this-week.json +10 -0
- package/mocks/metadata/narratives/admin.json +7 -0
- package/mocks/metadata/narratives/assets.json +17 -0
- package/mocks/metadata/narratives/findings.json +7 -0
- package/mocks/metadata/narratives/marketing.json +17 -0
- package/mocks/metadata/narratives/product.json +12 -0
- package/mocks/metadata/object-types/admin.json +6 -0
- package/mocks/metadata/object-types/assets.json +9 -0
- package/mocks/metadata/object-types/findings.json +8 -0
- package/mocks/metadata/object-types/marketing.json +6 -0
- package/mocks/metadata/object-types/memory.json +6 -0
- package/mocks/metadata/object-types/product.json +6 -0
- package/mocks/metadata/object-types/users.json +13 -0
- package/mocks/metadata/write-descriptors/admin-task-write.json +20 -0
- package/mocks/metadata/write-descriptors/assets-analysis-write.json +14 -0
- package/mocks/metadata/write-descriptors/marketing-task-write.json +20 -0
- package/mocks/metadata/write-descriptors/memory-write.json +14 -0
- package/mocks/metadata/write-descriptors/product-task-write.json +20 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 x12i
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
# @x12i/static-memorix
|
|
2
|
+
|
|
3
|
+
Static mock server that provides **full API parity** for the Memorix Explorer
|
|
4
|
+
Fastify API. No MongoDB, Catalox, or Redis required — state lives in
|
|
5
|
+
`./mocks/**/*.json` and is flushed to disk (debounced) on mutation.
|
|
6
|
+
|
|
7
|
+
Ships with a **complete reference demo app** (FlowState — a small task
|
|
8
|
+
manager) at `GET /demo` that exercises every read/write path in the API.
|
|
9
|
+
See [guides/demo-app.md](./guides/demo-app.md) for the full walkthrough.
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
Install once, then run one command:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install --global @x12i/static-memorix
|
|
17
|
+
static-memorix
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Then open **http://localhost:5030/demo**. The command prints the Demo, API,
|
|
21
|
+
Health, and JSON paths when it starts. No database or additional configuration
|
|
22
|
+
is required.
|
|
23
|
+
|
|
24
|
+
To create an editable demo in your own directory instead of using the bundled
|
|
25
|
+
read-only seeds:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
static-memorix create-demo
|
|
29
|
+
static-memorix --mocks-dir ./memorix-demo
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The first command creates `./memorix-demo` with `demo.html`, seed data,
|
|
33
|
+
metadata, write descriptors, and its own README. It refuses to overwrite an
|
|
34
|
+
existing path. The second command serves that folder, and all UI create/edit/
|
|
35
|
+
delete operations persist their routed JSON files inside it.
|
|
36
|
+
|
|
37
|
+
Choose a different destination or port if needed:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
static-memorix create-demo --dir ./my-project-fixtures
|
|
41
|
+
static-memorix --mocks-dir ./my-project-fixtures --port 8080
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Useful options:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
static-memorix --port 8080
|
|
48
|
+
static-memorix --help
|
|
49
|
+
static-memorix --version
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Stop a server started by the CLI:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
static-memorix stop # port 5030
|
|
56
|
+
static-memorix stop --port 8080
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If a requested port is occupied, the CLI explains these stop and alternate-port
|
|
60
|
+
options instead of returning only `EADDRINUSE`.
|
|
61
|
+
|
|
62
|
+
> `memorix-explorer` remains available as a short alias for the `static-memorix`
|
|
63
|
+
> command — both point at the same binary.
|
|
64
|
+
|
|
65
|
+
### Run from this repository
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install
|
|
69
|
+
npm run build
|
|
70
|
+
npm start # listens on :5030 (PORT / HOST / MOCKS_DIR env-overridable)
|
|
71
|
+
# dev (no build): npm run dev
|
|
72
|
+
|
|
73
|
+
# open the demo UI in your browser
|
|
74
|
+
open http://localhost:5030/demo
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Health:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
curl localhost:5030/health
|
|
81
|
+
curl "localhost:5030/api/explorer/health?includeInventory=1"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Run from CLI or code
|
|
85
|
+
|
|
86
|
+
Installed CLI, using the default port `5030`:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npx @x12i/static-memorix
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Or, after a global install:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
static-memorix
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Override the port from the shell:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
PORT=8080 npx @x12i/static-memorix
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Start it programmatically (explicit options take precedence over environment
|
|
105
|
+
defaults):
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
import { startServer } from "@x12i/static-memorix";
|
|
109
|
+
|
|
110
|
+
const app = await startServer({ port: 5030, host: "127.0.0.1" });
|
|
111
|
+
// await app.close();
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
For code-level tests without binding a port:
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
import { buildServer } from "@x12i/static-memorix";
|
|
118
|
+
|
|
119
|
+
const app = await buildServer();
|
|
120
|
+
const response = await app.inject({ method: "GET", url: "/health" });
|
|
121
|
+
await app.close();
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
See [guides/running-the-service.md](./guides/running-the-service.md) for all
|
|
125
|
+
CLI, environment, lifecycle, and programmatic examples.
|
|
126
|
+
|
|
127
|
+
## Architecture
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
Fastify Router (/api/explorer/* + /health + Authix/M2M shim + /demo)
|
|
131
|
+
│
|
|
132
|
+
Query & Interceptor Engine (mingo + narrative virtual filters)
|
|
133
|
+
┌────────────┬──────────────────┬──────────────┐
|
|
134
|
+
Inventory/Lenses Snapshots/Aliases Records Writer
|
|
135
|
+
└────────────┴──────────────────┴──────────────┘
|
|
136
|
+
InMemoryStore (state matrix)
|
|
137
|
+
│ debounced disk flush
|
|
138
|
+
./mocks/metadata & ./mocks/data
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Routes
|
|
142
|
+
|
|
143
|
+
| Group | Endpoints |
|
|
144
|
+
|------|-----------|
|
|
145
|
+
| Health | `GET /health`, `GET /api/explorer/health?includeInventory=1` |
|
|
146
|
+
| Inventory | `/inventory/collections`, `/summary`, `/issues`, `/graph` (query `sourceLens=db-first\|catalox-first`) |
|
|
147
|
+
| Snapshots | `/snapshots/:objectType/:recordId[.../associated[/:propertyName]]`, `/snapshots/:objectType/associated-properties`, `/associations/plan\|apply\|verify` |
|
|
148
|
+
| Records | `/records/collection`, `/full`, `/item`, `/content`, `/raw-collection`, `/raw-item`, `/workspace`, `POST /records/write`, `DELETE /records/item` |
|
|
149
|
+
| Lists | `/lists`, `/lists/:listId`, `/lists/:listId/records`, `/lists/suggest`, mutations `POST/PATCH/PUT/DELETE` |
|
|
150
|
+
| Narratives | `/narratives`, `/:entity`, `/:entity/raw`, `/:entity/:key`, `/:entity/:key/records`, mutations `POST/PATCH/DELETE` |
|
|
151
|
+
| Object Types | `/object-types`, `/:name`, `/:name/root-property-catalog`, `POST .../compute` |
|
|
152
|
+
| Write | `POST /records/write` (validate / dryRun / add / upsert / patch / replace / **delete**) |
|
|
153
|
+
| Agents | `GET /agents` |
|
|
154
|
+
| Auth shim | `POST /api/explorer/auth/token` |
|
|
155
|
+
| Demo | `GET /demo` — serves `mocks/demo.html` |
|
|
156
|
+
|
|
157
|
+
## Query conventions
|
|
158
|
+
|
|
159
|
+
- `filter=prop:op:val` — op ∈ `eq,ne,gt,gte,lt,lte,in,nin,exists,regex`
|
|
160
|
+
(`in`/`nin` use `|` separators). Repeatable / `;`-separated.
|
|
161
|
+
- Virtual narrative filter: `filter=narrativeId:eq:has-vulns` rewrites the
|
|
162
|
+
query to evaluate `doc.narratives['has-vulns']`.
|
|
163
|
+
- `sort=severity:desc&sort=entityId:asc` (mingo sort).
|
|
164
|
+
- `searchText=` / `q=` full-text substring match.
|
|
165
|
+
- `limit` (max 500), `offset`/`skip`, `includeTotal=1`.
|
|
166
|
+
- `target=memory` to query the memory tier (fourth data tier alongside entities/events/knowledge).
|
|
167
|
+
|
|
168
|
+
## Identity keys
|
|
169
|
+
|
|
170
|
+
The mock server accepts the following identity keys across fetch/write engines:
|
|
171
|
+
- `recordId` — entities
|
|
172
|
+
- `entityId` — entities
|
|
173
|
+
- `eventId` — events
|
|
174
|
+
- `knowledgeId` — knowledge
|
|
175
|
+
- `memoryId` — memory
|
|
176
|
+
|
|
177
|
+
Endpoints like `/records/full` and `/records/content` require exactly one identity key
|
|
178
|
+
per request. Memory collections are keyed by `memoryId`; the unprefixed
|
|
179
|
+
`./mocks/data/memory/memory.json` is the seed and routed writes use the active
|
|
180
|
+
Catalox-prefixed filename.
|
|
181
|
+
|
|
182
|
+
## Snapshot alias translation
|
|
183
|
+
|
|
184
|
+
Client `associated.data|discovery|analysis|{custom}` maps to storage
|
|
185
|
+
`associatedData | associatedInferred/associatedDiscovery | associatedAnalysis |
|
|
186
|
+
associated{Custom}`. Raw `associated*` fields are stripped from the returned
|
|
187
|
+
document and recomposed into a normalized `associated` bucket.
|
|
188
|
+
|
|
189
|
+
## Write engine
|
|
190
|
+
|
|
191
|
+
`POST /api/explorer/records/write` accepts an `operation` and routes the
|
|
192
|
+
payload through the write descriptor's JSON schema.
|
|
193
|
+
|
|
194
|
+
### Operations
|
|
195
|
+
|
|
196
|
+
| Operation | Behavior |
|
|
197
|
+
|-----------|----------|
|
|
198
|
+
| `add` | Append. Auto-generates an identity if missing. |
|
|
199
|
+
| `upsert` | Update existing by identity key, or append. |
|
|
200
|
+
| `patch` | Update existing by identity key. No-op if missing. |
|
|
201
|
+
| `replace` | Replace the entire collection (use with caution). |
|
|
202
|
+
| `delete` | Remove every record matching the supplied identity keys. Returns the removed records. |
|
|
203
|
+
|
|
204
|
+
### Required-field semantics
|
|
205
|
+
|
|
206
|
+
The `schema.required` array is enforced **fully** for `add` and `replace`.
|
|
207
|
+
For `upsert`, `patch`, and `delete`, only the identity field (`recordId`,
|
|
208
|
+
or `memoryId` on the memory tier) is required. This allows partial updates
|
|
209
|
+
like `{recordId, status}` without resupplying every required field — the
|
|
210
|
+
pattern the demo UI uses for every inline edit.
|
|
211
|
+
|
|
212
|
+
### REST-style delete
|
|
213
|
+
|
|
214
|
+
For ergonomics, you can also delete a single record with:
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
DELETE /api/explorer/records/item?entityName=product&recordId=t1&writeDescriptorId=product-task-write
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Returns `{ ok: true, count: <n>, removed: [<record>…] }` and flushes immediately.
|
|
221
|
+
|
|
222
|
+
## Demo app
|
|
223
|
+
|
|
224
|
+
The `mocks/demo.html` reference UI (served at `GET /demo`) is a complete task
|
|
225
|
+
manager that uses the Explorer API for every read and mutation. It demonstrates:
|
|
226
|
+
|
|
227
|
+
- Multi-collection reads (3 parallel `records/collection` calls + a `users` collection)
|
|
228
|
+
- Filter / search / sort via query params
|
|
229
|
+
- **Create** via modal → `POST /records/write op=add`
|
|
230
|
+
- **Edit** via inline pills/dropdowns → `POST /records/write op=upsert` (partial updates)
|
|
231
|
+
- **Delete** via button → `DELETE /records/item`
|
|
232
|
+
- Cross-collection **move** (delete on old area + add on new area)
|
|
233
|
+
- Optimistic UI with rollback on failure
|
|
234
|
+
|
|
235
|
+
Full implementation walkthrough: [guides/demo-app.md](./guides/demo-app.md).
|
|
236
|
+
|
|
237
|
+
## Environment
|
|
238
|
+
|
|
239
|
+
| Var | Default | Notes |
|
|
240
|
+
|-----|---------|-------|
|
|
241
|
+
| `PORT` | `5030` | Listen port |
|
|
242
|
+
| `HOST` | `0.0.0.0` | Listen host |
|
|
243
|
+
| `MOCKS_DIR` | bundled `<package>/mocks` | Fixture root |
|
|
244
|
+
| `DISK_FLUSH_DEBOUNCE_MS` | `300` | Debounce before disk flush |
|
|
245
|
+
| `MEMORIX_ORG_ID` | `memorix` | Organization prefix for DB routing |
|
|
246
|
+
| `MEMORIX_AGENT_ID` | `default-agent` | Agent prefix for catalox DB routing |
|
|
247
|
+
| `MEMORIX_DEPLOYMENT_PROFILE` | `default` | Deployment profile; `ebook` forces org/agent to `ebooks` |
|
|
248
|
+
| `MEMORIX_EXPLORER_ENABLE_METADATA_WRITES` | `false` | Allow list & narrative mutations |
|
|
249
|
+
| `MEMORIX_EXPLORER_ENABLE_PIPELINE_WRITES` | `false` | Allow pipeline writes |
|
|
250
|
+
| `MEMORIX_EXPLORER_ENABLE_REGISTRY_WRITES` | `false` | Allow registry writes |
|
|
251
|
+
|
|
252
|
+
For mutation-capable installed deployments, set `MOCKS_DIR` to a writable,
|
|
253
|
+
persistent directory. Routing configuration is process-scoped and resolved on
|
|
254
|
+
first import; use one process per organization/agent context and one writer per
|
|
255
|
+
prefix.
|
|
256
|
+
|
|
257
|
+
## DB Router Simulation
|
|
258
|
+
|
|
259
|
+
The mock server does not connect to MongoDB, but it **tricks the frontend** into
|
|
260
|
+
thinking it is talking to the routed tenant databases.
|
|
261
|
+
|
|
262
|
+
- The `GET /api/explorer/health` response includes a dynamic `memorixDb`
|
|
263
|
+
field constructed as `<orgId>-memorix-entities + <orgId>-memorix-events`.
|
|
264
|
+
- The agent-scoped catalox DB is reflected in the `cataloxDb` field as
|
|
265
|
+
`<agentId>-memorix-catalox`.
|
|
266
|
+
|
|
267
|
+
These strings are derived from `MEMORIX_ORG_ID`, `MEMORIX_AGENT_ID`, and the
|
|
268
|
+
`MEMORIX_DEPLOYMENT_PROFILE` (which, when set to `ebook`, forces both IDs to
|
|
269
|
+
`ebooks`).
|
|
270
|
+
|
|
271
|
+
### File-backed routing
|
|
272
|
+
|
|
273
|
+
Those routed database names also select JSON files. The separator is `--`:
|
|
274
|
+
|
|
275
|
+
```text
|
|
276
|
+
mocks/data/product/neo-memorix-entities--snapshots.json
|
|
277
|
+
mocks/data/product/neo-memorix-events--events.json
|
|
278
|
+
mocks/data/memory/neo-agent-memorix-catalox--memory.json
|
|
279
|
+
mocks/metadata/lists/neo-agent-memorix-catalox--my-plate.json
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
For `MEMORIX_ORG_ID=neo` and `MEMORIX_AGENT_ID=neo-agent`, entity-like
|
|
283
|
+
collections use the first prefix, events use the second, and memory plus
|
|
284
|
+
metadata use the Catalox prefix. If a routed file does not exist, the server
|
|
285
|
+
loads its unprefixed counterpart as seed data, but all mutations are written
|
|
286
|
+
to the routed filename. This provides database-style isolation without a
|
|
287
|
+
database and preserves existing fixtures.
|
|
288
|
+
|
|
289
|
+
The health response exposes the resolved values under `fileRouting`.
|
|
290
|
+
See [guides/managing-json-files.md](./guides/managing-json-files.md) for the
|
|
291
|
+
complete precedence and migration rules.
|
|
292
|
+
|
|
293
|
+
## Feature Flag Enforcement
|
|
294
|
+
|
|
295
|
+
The mock server enforces the following feature-flag gates with error responses:
|
|
296
|
+
- List/narrative mutations (`POST/PATCH/PUT/DELETE /lists`, `/narratives`) require
|
|
297
|
+
`MEMORIX_EXPLORER_ENABLE_METADATA_WRITES=true`.
|
|
298
|
+
- Pipeline writes (if implemented) require
|
|
299
|
+
`MEMORIX_EXPLORER_ENABLE_PIPELINE_WRITES=true`.
|
|
300
|
+
- Registry writes (if implemented) require
|
|
301
|
+
`MEMORIX_EXPLORER_ENABLE_REGISTRY_WRITES=true`.
|
|
302
|
+
|
|
303
|
+
Record writes (`POST /records/write`, `DELETE /records/item`) are **not**
|
|
304
|
+
feature-flagged — they're always on, gated only by the write descriptor contract.
|
|
305
|
+
|
|
306
|
+
When a flag is disabled or unset, the mock returns `{ ok: false, error: "..." }`
|
|
307
|
+
matching the production Fastify error shape (typically 403/404).
|
|
308
|
+
|
|
309
|
+
## The "memory" Target
|
|
310
|
+
|
|
311
|
+
The API has expanded its domain model to include a fourth tier of data: `memory`.
|
|
312
|
+
The mock's querying and writing engines now support `target=memory` and
|
|
313
|
+
`memoryId` as a valid primary key alongside `recordId`, `entityId`, `eventId`,
|
|
314
|
+
and `knowledgeId`.
|
|
315
|
+
|
|
316
|
+
- Folder structure: `./mocks/data/memory/memory.json` (seeded with example memories).
|
|
317
|
+
- Runtime memory writes persist to the active
|
|
318
|
+
`<agent>-memorix-catalox--memory.json` route.
|
|
319
|
+
- Inventory engine accepts `target=memory` and includes memory collections in
|
|
320
|
+
the simulated `inventorySummary`.
|
|
321
|
+
- Records engine accepts `target=memory` and supports `memoryId` for fetching.
|
|
322
|
+
- Write engine validates and persists `memoryId` on memory-tier records.
|
|
323
|
+
- Startup validation (`MemorixRecordArraySchema` mock) allows `memoryId` without
|
|
324
|
+
throwing schema errors.
|
|
325
|
+
|
|
326
|
+
## Documentation
|
|
327
|
+
|
|
328
|
+
- [guides/running-the-service.md](./guides/running-the-service.md) — installation, configuration, env vars
|
|
329
|
+
- [guides/using-the-api.md](./guides/using-the-api.md) — endpoint reference, query language, write operations
|
|
330
|
+
- [guides/managing-json-files.md](./guides/managing-json-files.md) — fixture structure, schemas, how the store works
|
|
331
|
+
- [guides/demo-app.md](./guides/demo-app.md) — FlowState reference UI walkthrough
|
|
332
|
+
|
|
333
|
+
## Release history
|
|
334
|
+
|
|
335
|
+
### v2.0.0
|
|
336
|
+
- **Renamed** the package from `@x12i/static-memorix-explorer-api` to
|
|
337
|
+
`@x12i/static-memorix`. Install and import under the new name going
|
|
338
|
+
forward; see [Install → Renamed package](./site/install.html#uninstall).
|
|
339
|
+
- Added the `static-memorix` CLI command, matching the new package name.
|
|
340
|
+
`memorix-explorer` remains available as a short alias; the old
|
|
341
|
+
`static-memorix-explorer-api` and `mock-memorix-explorer-api` aliases were
|
|
342
|
+
retired as part of the rename.
|
|
343
|
+
- Updated repository, homepage, and issue-tracker URLs to
|
|
344
|
+
`github.com/x12i/static-memorix`.
|
|
345
|
+
- No functional, API, or behavior changes — this is a naming-only release.
|
|
346
|
+
|
|
347
|
+
### v1.5.1
|
|
348
|
+
- Replaced personal names in the bundled demo users with generic sample names.
|
|
349
|
+
- Added regression coverage to keep personal identifiers out of generated demos.
|
|
350
|
+
|
|
351
|
+
### v1.5.0
|
|
352
|
+
- Added `memorix-explorer stop [--port <number>]` with safe managed-process
|
|
353
|
+
tracking and stale-PID cleanup.
|
|
354
|
+
- Added actionable port-conflict output with stop and alternate-port commands.
|
|
355
|
+
- Changed `create-demo` instructions to relative, user-owned paths such as
|
|
356
|
+
`./memorix-demo`; package or maintainer filesystem paths are never exposed.
|
|
357
|
+
- Added lifecycle and occupied-port integration coverage.
|
|
358
|
+
|
|
359
|
+
### v1.4.0
|
|
360
|
+
- Added `memorix-explorer create-demo` to create a user-owned, writable demo.
|
|
361
|
+
- Added `--dir` for the generated demo destination and `--mocks-dir` for
|
|
362
|
+
serving any fixture directory directly from the CLI.
|
|
363
|
+
- Generated demos include UI, metadata, seed data, write descriptors, and a
|
|
364
|
+
local usage README.
|
|
365
|
+
- Demo creation is atomic, refuses overwrites, and excludes routed state that
|
|
366
|
+
may have been generated inside a previously used global installation.
|
|
367
|
+
- Installed CLI aliases now use a configuration-first launcher so fixture paths
|
|
368
|
+
are resolved before the server loads.
|
|
369
|
+
|
|
370
|
+
### v1.3.2
|
|
371
|
+
- Added the short `memorix-explorer` CLI command.
|
|
372
|
+
- Added `--help`/`-h` and `--version`/`-v` commands.
|
|
373
|
+
- Startup now prints clickable Demo, API, Health, and JSON locations.
|
|
374
|
+
- Reworked Quick Start documentation around install-once, run-one-command use.
|
|
375
|
+
|
|
376
|
+
### v1.3.1
|
|
377
|
+
- Rejected unsafe routing IDs, object types, and metadata keys before path use.
|
|
378
|
+
- Changed malformed and empty JSON handling from silent fallback to explicit
|
|
379
|
+
startup failure, preventing accidental data loss.
|
|
380
|
+
- Made JSON persistence atomic through same-directory temporary-file renames.
|
|
381
|
+
- Made list deletion restart-safe with routed tombstones.
|
|
382
|
+
- Fixed installed npm CLI execution through symlink-aware entry detection.
|
|
383
|
+
- Added packed-install, restart, traversal, corruption, and atomic-write checks.
|
|
384
|
+
- Documented writable `MOCKS_DIR`, process isolation, and single-writer limits.
|
|
385
|
+
|
|
386
|
+
### v1.3.0
|
|
387
|
+
- Added database-routing parity through deterministic JSON filename prefixes.
|
|
388
|
+
- Added separate entity, event, and Catalox/metadata prefix resolution.
|
|
389
|
+
- Added migration-safe fallback from missing routed files to unprefixed seeds;
|
|
390
|
+
writes always persist to the selected routed file.
|
|
391
|
+
- Added resolved `fileRouting` prefixes to the health response.
|
|
392
|
+
- Updated metadata discovery to ignore other routed tenants.
|
|
393
|
+
- Added routed persistence and prefix regression coverage.
|
|
394
|
+
|
|
395
|
+
### v1.2.0
|
|
396
|
+
- Added native `--port` and `--host` CLI options.
|
|
397
|
+
- Added the canonical `static-memorix-explorer-api` executable while retaining
|
|
398
|
+
`mock-memorix-explorer-api` as a compatibility alias.
|
|
399
|
+
- Published TypeScript declarations for `buildServer()`, `startServer()`,
|
|
400
|
+
configuration exports, and server options.
|
|
401
|
+
- Corrected the supported Node.js runtime to Node 20 or newer for Fastify 5.
|
|
402
|
+
- Expanded CLI, programmatic, test, precedence, and lifecycle documentation.
|
|
403
|
+
|
|
404
|
+
### v1.1.1
|
|
405
|
+
- Changed the default listen port from `4300` to `5030`.
|
|
406
|
+
- Added safe programmatic APIs: `buildServer()` and `startServer(options)`.
|
|
407
|
+
- Importing the package no longer starts a listener as a side effect.
|
|
408
|
+
- Added CLI, environment override, programmatic startup, and injected-test examples.
|
|
409
|
+
|
|
410
|
+
### v1.1.0
|
|
411
|
+
- **Added**: `delete` operation to the write engine
|
|
412
|
+
(`POST /records/write` body `operation:"delete"`).
|
|
413
|
+
- **Added**: REST-style `DELETE /api/explorer/records/item` endpoint.
|
|
414
|
+
- **Added**: Operation-aware schema validation — `upsert`/`patch`/`delete`
|
|
415
|
+
only require the identity field, not every `required` field.
|
|
416
|
+
- **Added**: Complete demo application (`mocks/demo.html`) wired entirely
|
|
417
|
+
through the Explorer API — Create/Edit/Delete/Move with optimistic UI.
|
|
418
|
+
- **Added**: `users` object type + collection.
|
|
419
|
+
- **Added**: Per-area task write descriptors
|
|
420
|
+
(`product/marketing/admin-task-write`).
|
|
421
|
+
- **Added**: Per-area narratives and enriched task snapshots
|
|
422
|
+
(`notes`, `chat`, `assigneeId`).
|
|
423
|
+
- **Removed**: obsolete `/api/state` flow and `mocks/db.json`
|
|
424
|
+
(replaced by Explorer API writes).
|
|
425
|
+
- **Docs**: full demo walkthrough (`guides/demo-app.md`) and refreshed
|
|
426
|
+
endpoint tables.
|
|
427
|
+
|
|
428
|
+
### v1.0.0
|
|
429
|
+
- Initial implementation of mock Memorix Explorer API.
|
|
430
|
+
- Health, inventory, snapshots, records, lists, narratives, object types,
|
|
431
|
+
write engine (add/upsert/patch/replace), agents, auth shim.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export interface CliServerOptions {
|
|
3
|
+
port?: number;
|
|
4
|
+
host?: string;
|
|
5
|
+
mocksDir?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const CLI_HELP = "Memorix Explorer static server\n\nUsage:\n static-memorix create-demo [--dir <path>]\n static-memorix stop [--port <number>]\n static-memorix [options]\n\nCommands:\n create-demo Create a writable demo folder (default: ./memorix-demo)\n stop Stop a managed server (default port: 5030)\n\nServer options:\n --port <number> Port to listen on (default: 5030)\n --host <address> Host to bind (default: 0.0.0.0)\n --mocks-dir <path> JSON fixture directory\n -h, --help Show this help\n -v, --version Show the installed version\n\nQuick start:\n static-memorix create-demo\n static-memorix --mocks-dir ./memorix-demo\n\n(\"memorix-explorer\" remains available as a short alias for this command.)\n";
|
|
8
|
+
export declare function getPackageVersion(): string;
|
|
9
|
+
export declare function parseServerArgs(args: string[]): CliServerOptions;
|
|
10
|
+
export declare function parseCreateDemoArgs(args: string[]): {
|
|
11
|
+
targetDir: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function createDemo(targetDir: string): string;
|
|
14
|
+
export declare function pidFileForPort(port: number): string;
|
|
15
|
+
export declare function registerManagedServer(port: number): void;
|
|
16
|
+
export declare function stopManagedServer(port: number): Promise<boolean>;
|
|
17
|
+
export declare function runCli(args: string[]): Promise<void>;
|