@mulmoclaude/core 0.24.0 → 0.25.1
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/assets/helps/collection-skills.md +51 -0
- package/assets/helps/custom-view.md +37 -3
- package/assets/helps/error-recovery.md +30 -0
- package/assets/helps/google-calendar-collection.md +79 -0
- package/assets/helps/index.md +1 -0
- package/dist/collection/core/project.d.ts +3 -0
- package/dist/collection/core/schema.d.ts +13 -1
- package/dist/collection/core/schemaZ.d.ts +45 -0
- package/dist/collection/index.cjs +18 -14
- package/dist/collection/index.cjs.map +1 -1
- package/dist/collection/index.d.ts +1 -0
- package/dist/collection/index.js +4 -2
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/paths.cjs +5 -55
- package/dist/collection/paths.js +1 -51
- package/dist/collection/registry/server/index.cjs +20 -19
- package/dist/collection/registry/server/index.cjs.map +1 -1
- package/dist/collection/registry/server/index.js +3 -2
- package/dist/collection/registry/server/index.js.map +1 -1
- package/dist/collection/server/csvStore.d.ts +8 -1
- package/dist/collection/server/discoveredCollection.d.ts +4 -0
- package/dist/collection/server/discovery.d.ts +1 -0
- package/dist/collection/server/index.cjs +58 -54
- package/dist/collection/server/index.d.ts +1 -0
- package/dist/collection/server/index.js +5 -4
- package/dist/collection/server/queryRunner.d.ts +4 -0
- package/dist/collection/server/spawn.d.ts +2 -1
- package/dist/collection/server/sqliteStore.d.ts +14 -0
- package/dist/collection/server/store.d.ts +43 -8
- package/dist/collection/server/storePage.d.ts +32 -0
- package/dist/collection-watchers/index.cjs +131 -44
- package/dist/collection-watchers/index.cjs.map +1 -1
- package/dist/collection-watchers/index.d.ts +1 -1
- package/dist/collection-watchers/index.js +125 -39
- package/dist/collection-watchers/index.js.map +1 -1
- package/dist/collection-watchers/reconciler.d.ts +13 -11
- package/dist/collection-watchers/watcher.d.ts +4 -3
- package/dist/{server-BpEo0FOd.js → discovery-QUi_7aNG.js} +414 -1495
- package/dist/discovery-QUi_7aNG.js.map +1 -0
- package/dist/{server-CkysfLh4.cjs → discovery-cwtfyDxl.cjs} +463 -1658
- package/dist/discovery-cwtfyDxl.cjs.map +1 -0
- package/dist/feeds/index.cjs +4 -4
- package/dist/feeds/index.js +2 -2
- package/dist/feeds/server/index.cjs +35 -22
- package/dist/feeds/server/index.cjs.map +1 -1
- package/dist/feeds/server/index.js +26 -13
- package/dist/feeds/server/index.js.map +1 -1
- package/dist/google/apiClient.d.ts +8 -1
- package/dist/google/calendar.d.ts +35 -0
- package/dist/google/calendarSyncStore.d.ts +7 -0
- package/dist/google/collectionSync.d.ts +70 -0
- package/dist/google/index.cjs +294 -4
- package/dist/google/index.cjs.map +1 -1
- package/dist/google/index.d.ts +4 -2
- package/dist/google/index.js +279 -5
- package/dist/google/index.js.map +1 -1
- package/dist/ids-Dl9Ij63K.cjs +163 -0
- package/dist/ids-Dl9Ij63K.cjs.map +1 -0
- package/dist/ids-P2T89Gou.js +92 -0
- package/dist/ids-P2T89Gou.js.map +1 -0
- package/dist/{ingestTypes-CFEgTItj.js → ingestTypes-C-IQB4nw.js} +2 -2
- package/dist/{ingestTypes-CFEgTItj.js.map → ingestTypes-C-IQB4nw.js.map} +1 -1
- package/dist/{ingestTypes-Stc7iQyA.cjs → ingestTypes-DZpAC3N_.cjs} +3 -3
- package/dist/{ingestTypes-Stc7iQyA.cjs.map → ingestTypes-DZpAC3N_.cjs.map} +1 -1
- package/dist/project-BWI5w_BT.cjs +17 -0
- package/dist/project-BWI5w_BT.cjs.map +1 -0
- package/dist/project-bU98ycsy.js +12 -0
- package/dist/project-bU98ycsy.js.map +1 -0
- package/dist/{promptSafety-BLUcImzd.js → promptSafety-Boz5qOs-.js} +2 -84
- package/dist/promptSafety-Boz5qOs-.js.map +1 -0
- package/dist/{promptSafety-DI_1Rvhk.cjs → promptSafety-Co4cYQ_Z.cjs} +1 -149
- package/dist/promptSafety-Co4cYQ_Z.cjs.map +1 -0
- package/dist/remote-host/server/index.cjs +6 -4
- package/dist/remote-host/server/index.cjs.map +1 -1
- package/dist/remote-host/server/index.js +6 -4
- package/dist/remote-host/server/index.js.map +1 -1
- package/dist/remote-view/index.cjs +5 -3
- package/dist/remote-view/index.cjs.map +1 -1
- package/dist/remote-view/index.d.ts +3 -1
- package/dist/remote-view/index.js +5 -3
- package/dist/remote-view/index.js.map +1 -1
- package/dist/scheduler/index.cjs +3 -1
- package/dist/scheduler/index.cjs.map +1 -1
- package/dist/scheduler/index.js +3 -1
- package/dist/scheduler/index.js.map +1 -1
- package/dist/server-BI3wnTwl.js +1529 -0
- package/dist/server-BI3wnTwl.js.map +1 -0
- package/dist/server-CKdWENZ-.cjs +1704 -0
- package/dist/server-CKdWENZ-.cjs.map +1 -0
- package/dist/skill-bridge/index.cjs +2 -2
- package/dist/skill-bridge/index.cjs.map +1 -1
- package/dist/skill-bridge/index.js +1 -1
- package/dist/templatePath-27vUZowm.cjs +75 -0
- package/dist/templatePath-27vUZowm.cjs.map +1 -0
- package/dist/templatePath-k_WNbL_Q.js +52 -0
- package/dist/templatePath-k_WNbL_Q.js.map +1 -0
- package/package.json +1 -1
- package/dist/collection/paths.cjs.map +0 -1
- package/dist/collection/paths.js.map +0 -1
- package/dist/promptSafety-BLUcImzd.js.map +0 -1
- package/dist/promptSafety-DI_1Rvhk.cjs.map +0 -1
- package/dist/server-BpEo0FOd.js.map +0 -1
- package/dist/server-CkysfLh4.cjs.map +0 -1
|
@@ -1,81 +1,85 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
2
|
+
const require_ids = require("../../ids-Dl9Ij63K.cjs");
|
|
3
|
+
const require_discovery = require("../../discovery-cwtfyDxl.cjs");
|
|
4
|
+
const require_templatePath = require("../../templatePath-27vUZowm.cjs");
|
|
5
|
+
const require_server = require("../../server-CKdWENZ-.cjs");
|
|
6
|
+
exports.COMPUTED_TYPES = require_ids.COMPUTED_TYPES;
|
|
7
|
+
exports.CollectionQueryZ = require_discovery.CollectionQueryZ;
|
|
8
|
+
exports.CollectionSchemaZ = require_discovery.CollectionSchemaZ;
|
|
9
|
+
exports.DEFAULT_QUERY_ROWS = require_discovery.DEFAULT_QUERY_ROWS;
|
|
10
|
+
exports.MAX_CSV_ROWS = require_discovery.MAX_CSV_ROWS;
|
|
11
|
+
exports.MAX_QUERY_ROWS = require_discovery.MAX_QUERY_ROWS;
|
|
11
12
|
exports.MAX_SCHEMA_ISSUES = require_server.MAX_SCHEMA_ISSUES;
|
|
12
13
|
exports.MAX_UNSELECTIVE_ITEMS = require_server.MAX_UNSELECTIVE_ITEMS;
|
|
13
|
-
exports.SCHEMA_FILE =
|
|
14
|
-
exports.acceptParsedSchema =
|
|
14
|
+
exports.SCHEMA_FILE = require_discovery.SCHEMA_FILE;
|
|
15
|
+
exports.acceptParsedSchema = require_discovery.acceptParsedSchema;
|
|
15
16
|
exports.advanceTriggerDate = require_server.advanceTriggerDate;
|
|
16
17
|
exports.applyMutateAction = require_server.applyMutateAction;
|
|
17
|
-
exports.buildActionSeedPrompt =
|
|
18
|
-
exports.buildCollectionActionSeedPrompt =
|
|
18
|
+
exports.buildActionSeedPrompt = require_discovery.buildActionSeedPrompt;
|
|
19
|
+
exports.buildCollectionActionSeedPrompt = require_discovery.buildCollectionActionSeedPrompt;
|
|
19
20
|
exports.buildWorkspaceOntology = require_server.buildWorkspaceOntology;
|
|
20
|
-
exports.collectionWritable =
|
|
21
|
-
exports.compileCsvQuery =
|
|
22
|
-
exports.compileJsonlQuery =
|
|
21
|
+
exports.collectionWritable = require_discovery.collectionWritable;
|
|
22
|
+
exports.compileCsvQuery = require_discovery.compileCsvQuery;
|
|
23
|
+
exports.compileJsonlQuery = require_discovery.compileJsonlQuery;
|
|
23
24
|
exports.compileRecordZ = require_server.compileRecordZ;
|
|
24
25
|
exports.computeCollectionIcon = require_server.computeCollectionIcon;
|
|
25
26
|
exports.computeSuccessor = require_server.computeSuccessor;
|
|
26
|
-
exports.configureCollectionHost =
|
|
27
|
-
exports.csvRowToItem =
|
|
27
|
+
exports.configureCollectionHost = require_discovery.configureCollectionHost;
|
|
28
|
+
exports.csvRowToItem = require_discovery.csvRowToItem;
|
|
28
29
|
exports.daysInMonth = require_server.daysInMonth;
|
|
29
|
-
exports.decodeCsvRecordId =
|
|
30
|
-
exports.dedupeByRecordId =
|
|
30
|
+
exports.decodeCsvRecordId = require_discovery.decodeCsvRecordId;
|
|
31
|
+
exports.dedupeByRecordId = require_discovery.dedupeByRecordId;
|
|
31
32
|
exports.deleteCollection = require_server.deleteCollection;
|
|
32
33
|
exports.deleteCollectionRefusalMessage = require_server.deleteCollectionRefusalMessage;
|
|
33
34
|
exports.deleteCustomView = require_server.deleteCustomView;
|
|
34
|
-
exports.deleteItem =
|
|
35
|
-
exports.discoverCollections =
|
|
36
|
-
exports.encodeCsvRecordId =
|
|
35
|
+
exports.deleteItem = require_discovery.deleteItem;
|
|
36
|
+
exports.discoverCollections = require_discovery.discoverCollections;
|
|
37
|
+
exports.encodeCsvRecordId = require_discovery.encodeCsvRecordId;
|
|
37
38
|
exports.enrichItems = require_server.enrichItems;
|
|
38
39
|
exports.firstMutateParamProblem = require_server.firstMutateParamProblem;
|
|
39
40
|
exports.formatCivil = require_server.formatCivil;
|
|
40
|
-
exports.generateItemId =
|
|
41
|
-
exports.getWorkspaceRoot =
|
|
42
|
-
exports.isContainedInRoot =
|
|
43
|
-
exports.isContainedInWorkspace =
|
|
44
|
-
exports.isRegularFile =
|
|
45
|
-
exports.isSafeActionTemplatePath =
|
|
46
|
-
exports.isSafeCustomViewI18nPath =
|
|
47
|
-
exports.isSafeCustomViewPath =
|
|
48
|
-
exports.isSafeTemplatePath =
|
|
41
|
+
exports.generateItemId = require_discovery.generateItemId;
|
|
42
|
+
exports.getWorkspaceRoot = require_discovery.getWorkspaceRoot;
|
|
43
|
+
exports.isContainedInRoot = require_discovery.isContainedInRoot;
|
|
44
|
+
exports.isContainedInWorkspace = require_discovery.isContainedInWorkspace;
|
|
45
|
+
exports.isRegularFile = require_discovery.isRegularFile;
|
|
46
|
+
exports.isSafeActionTemplatePath = require_templatePath.isSafeActionTemplatePath;
|
|
47
|
+
exports.isSafeCustomViewI18nPath = require_templatePath.isSafeCustomViewI18nPath;
|
|
48
|
+
exports.isSafeCustomViewPath = require_templatePath.isSafeCustomViewPath;
|
|
49
|
+
exports.isSafeTemplatePath = require_templatePath.isSafeTemplatePath;
|
|
49
50
|
exports.isTriggerDue = require_server.isTriggerDue;
|
|
50
|
-
exports.itemFilePath =
|
|
51
|
-
exports.listItems =
|
|
52
|
-
exports.loadCollection =
|
|
53
|
-
exports.log =
|
|
51
|
+
exports.itemFilePath = require_discovery.itemFilePath;
|
|
52
|
+
exports.listItems = require_discovery.listItems;
|
|
53
|
+
exports.loadCollection = require_discovery.loadCollection;
|
|
54
|
+
exports.log = require_discovery.log;
|
|
54
55
|
exports.makeManageCollectionTool = require_server.makeManageCollectionTool;
|
|
55
56
|
exports.maybeSpawnSuccessor = require_server.maybeSpawnSuccessor;
|
|
56
|
-
exports.normalizeCsvValue =
|
|
57
|
+
exports.normalizeCsvValue = require_discovery.normalizeCsvValue;
|
|
58
|
+
exports.pageFromFullRead = require_discovery.pageFromFullRead;
|
|
57
59
|
exports.parseCivil = require_server.parseCivil;
|
|
58
|
-
exports.
|
|
59
|
-
exports.
|
|
60
|
-
exports.
|
|
61
|
-
exports.
|
|
62
|
-
exports.
|
|
63
|
-
exports.
|
|
64
|
-
exports.
|
|
60
|
+
exports.projectItemFields = require_discovery.projectItemFields;
|
|
61
|
+
exports.promptPathsFor = require_discovery.promptPathsFor;
|
|
62
|
+
exports.publishCollectionChange = require_discovery.publishCollectionChange;
|
|
63
|
+
exports.readCustomViewHtml = require_discovery.readCustomViewHtml;
|
|
64
|
+
exports.readCustomViewI18n = require_discovery.readCustomViewI18n;
|
|
65
|
+
exports.readItem = require_discovery.readItem;
|
|
66
|
+
exports.readOnlyRefusal = require_discovery.readOnlyRefusal;
|
|
67
|
+
exports.readSkillTemplate = require_discovery.readSkillTemplate;
|
|
65
68
|
exports.recordFieldProblem = require_server.recordFieldProblem;
|
|
66
|
-
exports.resolveCreateItemId =
|
|
67
|
-
exports.resolveDataDir =
|
|
69
|
+
exports.resolveCreateItemId = require_discovery.resolveCreateItemId;
|
|
70
|
+
exports.resolveDataDir = require_discovery.resolveDataDir;
|
|
68
71
|
exports.resolveEvery = require_server.resolveEvery;
|
|
69
|
-
exports.resolveTemplatePath =
|
|
72
|
+
exports.resolveTemplatePath = require_discovery.resolveTemplatePath;
|
|
73
|
+
exports.runCollectionQuery = require_server.runCollectionQuery;
|
|
70
74
|
exports.runQueryOverRows = require_server.runQueryOverRows;
|
|
71
|
-
exports.safeRecordId =
|
|
72
|
-
exports.safeSlugName =
|
|
75
|
+
exports.safeRecordId = require_discovery.safeRecordId;
|
|
76
|
+
exports.safeSlugName = require_discovery.safeSlugName;
|
|
73
77
|
exports.schemaRelations = require_server.schemaRelations;
|
|
74
|
-
exports.setCollectionChangePublisher =
|
|
75
|
-
exports.storeFor =
|
|
78
|
+
exports.setCollectionChangePublisher = require_discovery.setCollectionChangePublisher;
|
|
79
|
+
exports.storeFor = require_discovery.storeFor;
|
|
76
80
|
exports.successorId = require_server.successorId;
|
|
77
|
-
exports.toDetail =
|
|
78
|
-
exports.toSummary =
|
|
81
|
+
exports.toDetail = require_discovery.toDetail;
|
|
82
|
+
exports.toSummary = require_discovery.toSummary;
|
|
79
83
|
exports.validateCollectionRecords = require_server.validateCollectionRecords;
|
|
80
84
|
exports.validateRecordObject = require_server.validateRecordObject;
|
|
81
|
-
exports.writeItem =
|
|
85
|
+
exports.writeItem = require_discovery.writeItem;
|
|
@@ -7,6 +7,7 @@ export * from './store';
|
|
|
7
7
|
export { MAX_CSV_ROWS, encodeCsvRecordId, decodeCsvRecordId, normalizeCsvValue, csvRowToItem, dedupeByRecordId } from './csvStore';
|
|
8
8
|
export { compileCsvQuery, compileJsonlQuery } from './csvQuery';
|
|
9
9
|
export { runQueryOverRows } from './jsonlQuery';
|
|
10
|
+
export { runCollectionQuery } from './queryRunner';
|
|
10
11
|
export { CollectionQueryZ, MAX_QUERY_ROWS, DEFAULT_QUERY_ROWS } from '../core/queryZ';
|
|
11
12
|
export type { CollectionQuery, CollectionQueryAggregate, CollectionQueryOrder, CollectionQueryWhere } from '../core/queryZ';
|
|
12
13
|
export * from './validate';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { o as COMPUTED_TYPES } from "../../ids-P2T89Gou.js";
|
|
2
|
+
import { A as generateItemId, C as compileJsonlQuery, D as buildActionSeedPrompt, E as MAX_QUERY_ROWS, F as readCustomViewI18n, G as resolveDataDir, H as isContainedInRoot, I as readItem, J as safeSlugName, K as resolveTemplatePath, L as readSkillTemplate, M as listItems, N as promptPathsFor, O as buildCollectionActionSeedPrompt, P as readCustomViewHtml, Q as getWorkspaceRoot, R as resolveCreateItemId, S as compileCsvQuery, T as DEFAULT_QUERY_ROWS, U as isContainedInWorkspace, V as SCHEMA_FILE, W as itemFilePath, Z as configureCollectionHost, _ as decodeCsvRecordId, a as toSummary, b as normalizeCsvValue, c as collectionWritable, et as log, f as pageFromFullRead, g as csvRowToItem, i as toDetail, j as isRegularFile, k as deleteItem, l as readOnlyRefusal, m as MAX_CSV_ROWS, n as discoverCollections, nt as setCollectionChangePublisher, o as CollectionSchemaZ, p as projectItemFields, q as safeRecordId, r as loadCollection, t as acceptParsedSchema, tt as publishCollectionChange, u as storeFor, v as dedupeByRecordId, w as CollectionQueryZ, y as encodeCsvRecordId, z as writeItem } from "../../discovery-QUi_7aNG.js";
|
|
3
|
+
import { i as isSafeTemplatePath, n as isSafeCustomViewI18nPath, r as isSafeCustomViewPath, t as isSafeActionTemplatePath } from "../../templatePath-k_WNbL_Q.js";
|
|
4
|
+
import { C as validateCollectionRecords, D as runCollectionQuery, E as recordFieldProblem, O as enrichItems, S as firstMutateParamProblem, T as compileRecordZ, a as deleteCollection, b as schemaRelations, c as computeSuccessor, d as isTriggerDue, f as maybeSpawnSuccessor, h as successorId, i as deleteCustomView, k as runQueryOverRows, l as daysInMonth, m as resolveEvery, n as MAX_UNSELECTIVE_ITEMS, o as deleteCollectionRefusalMessage, p as parseCivil, r as makeManageCollectionTool, s as advanceTriggerDate, t as MAX_SCHEMA_ISSUES, u as formatCivil, v as computeCollectionIcon, w as validateRecordObject, x as applyMutateAction, y as buildWorkspaceOntology } from "../../server-BI3wnTwl.js";
|
|
5
|
+
export { COMPUTED_TYPES, CollectionQueryZ, CollectionSchemaZ, DEFAULT_QUERY_ROWS, MAX_CSV_ROWS, MAX_QUERY_ROWS, MAX_SCHEMA_ISSUES, MAX_UNSELECTIVE_ITEMS, SCHEMA_FILE, acceptParsedSchema, advanceTriggerDate, applyMutateAction, buildActionSeedPrompt, buildCollectionActionSeedPrompt, buildWorkspaceOntology, collectionWritable, compileCsvQuery, compileJsonlQuery, compileRecordZ, computeCollectionIcon, computeSuccessor, configureCollectionHost, csvRowToItem, daysInMonth, decodeCsvRecordId, dedupeByRecordId, deleteCollection, deleteCollectionRefusalMessage, deleteCustomView, deleteItem, discoverCollections, encodeCsvRecordId, enrichItems, firstMutateParamProblem, formatCivil, generateItemId, getWorkspaceRoot, isContainedInRoot, isContainedInWorkspace, isRegularFile, isSafeActionTemplatePath, isSafeCustomViewI18nPath, isSafeCustomViewPath, isSafeTemplatePath, isTriggerDue, itemFilePath, listItems, loadCollection, log, makeManageCollectionTool, maybeSpawnSuccessor, normalizeCsvValue, pageFromFullRead, parseCivil, projectItemFields, promptPathsFor, publishCollectionChange, readCustomViewHtml, readCustomViewI18n, readItem, readOnlyRefusal, readSkillTemplate, recordFieldProblem, resolveCreateItemId, resolveDataDir, resolveEvery, resolveTemplatePath, runCollectionQuery, runQueryOverRows, safeRecordId, safeSlugName, schemaRelations, setCollectionChangePublisher, storeFor, successorId, toDetail, toSummary, validateCollectionRecords, validateRecordObject, writeItem };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CollectionQuery } from '../core/queryZ';
|
|
2
|
+
import { LoadedCollection } from './discoveredCollection';
|
|
3
|
+
import { DiscoveryOptions } from './discovery';
|
|
4
|
+
export declare function runCollectionQuery(collection: LoadedCollection, query: CollectionQuery, opts?: DiscoveryOptions): Promise<Record<string, unknown>[]>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IoOptions } from './io';
|
|
2
|
+
import { LoadedCollection } from './discoveredCollection';
|
|
2
3
|
import { CollectionEvery, CollectionItem, CollectionSchema, CollectionSpawnEvery } from '../core/schema';
|
|
3
4
|
/** A timezone-free calendar date. `m` is 1-12. */
|
|
4
5
|
export interface CivilDate {
|
|
@@ -52,4 +53,4 @@ export declare function computeSuccessor(schema: CollectionSchema, sourceItem: C
|
|
|
52
53
|
* predicate doesn't match, the trigger date is unparseable, or the
|
|
53
54
|
* successor already exists (create-if-absent). Never overwrites an
|
|
54
55
|
* existing successor — protects any edits the user made to it. */
|
|
55
|
-
export declare function maybeSpawnSuccessor(
|
|
56
|
+
export declare function maybeSpawnSuccessor(collection: LoadedCollection, sourceItem: CollectionItem, sourceId: string, ioOpts?: IoOptions): Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LoadedCollection } from './discoveredCollection';
|
|
2
|
+
import { IoOptions } from './io';
|
|
3
|
+
import { CollectionStore } from './store';
|
|
4
|
+
/** Best-effort full WAL checkpoint so the MAIN db file alone is a
|
|
5
|
+
* complete snapshot (committed pages in `<db>-wal` are folded in and the
|
|
6
|
+
* WAL truncated). Used by `deleteCollection` before archiving. Returns
|
|
7
|
+
* false on any failure (runtime without node:sqlite, locked db, missing
|
|
8
|
+
* file) — the caller then archives the sidecar files alongside the db so
|
|
9
|
+
* no committed data is lost either way. */
|
|
10
|
+
export declare function checkpointSqliteDatabase(absPath: string): Promise<boolean>;
|
|
11
|
+
/** A `storage: sqlite` store over `collection.storageFile`. A schema whose
|
|
12
|
+
* `storageFile` failed to resolve yields a read-only EMPTY store rather
|
|
13
|
+
* than a writable one — same fail-closed rule as the CSV store. */
|
|
14
|
+
export declare function sqliteStoreFor(collection: LoadedCollection, opts: IoOptions): CollectionStore;
|
|
@@ -1,21 +1,55 @@
|
|
|
1
1
|
import { CollectionItem } from '../core/schema';
|
|
2
2
|
import { CollectionQuery } from '../core/queryZ';
|
|
3
3
|
import { LoadedCollection } from './discoveredCollection';
|
|
4
|
-
import { IoOptions } from './io';
|
|
4
|
+
import { DeleteItemResult, IoOptions, WriteItemResult } from './io';
|
|
5
|
+
import { ListOptions, ListPage, WriteOptions } from './storePage';
|
|
6
|
+
export { pageFromFullRead, projectItemFields, type ListOptions, type ListPage, type WriteOptions } from './storePage';
|
|
5
7
|
export interface CollectionStoreCapabilities {
|
|
6
8
|
readonly writable: boolean;
|
|
9
|
+
/** Native aggregation engine for the structured DSL (`core/queryZ.ts`).
|
|
10
|
+
* False ⇒ `query` is absent; the engine-level fallback (enrich →
|
|
11
|
+
* JSONL → DuckDB, `queryRunner.ts`) answers aggregations instead. */
|
|
12
|
+
readonly nativeQuery: boolean;
|
|
13
|
+
/** True when `page` resolves offset/limit inside the backend. False ⇒
|
|
14
|
+
* `page` is emulated (full read, then slice) — same result, no saving. */
|
|
15
|
+
readonly nativePaging: boolean;
|
|
7
16
|
}
|
|
17
|
+
/** The storage contract every backend must satisfy (verified by the shared
|
|
18
|
+
* contract test suite, `test/workspace/collections/test_storeContract.ts`):
|
|
19
|
+
*
|
|
20
|
+
* 1. STABLE ORDER — `page` walks a documented deterministic order (file
|
|
21
|
+
* store: lexicographic by record id; CSV store: file row order; SQLite
|
|
22
|
+
* store: `ORDER BY id`), so `offset`-paging never skips or repeats
|
|
23
|
+
* records between calls. Sorting by arbitrary fields is NOT the
|
|
24
|
+
* store's job.
|
|
25
|
+
* 2. IDS — minting/resolving record ids is the store's job (the CSV
|
|
26
|
+
* store's `id0x…` encoding stays inside it); `read` resolves every id
|
|
27
|
+
* `list`/`page` returned.
|
|
28
|
+
* 3. CONTAINMENT — a store never serves data from outside the workspace;
|
|
29
|
+
* symlink/realpath defenses are each implementation's obligation
|
|
30
|
+
* (io.ts is the reference).
|
|
31
|
+
* 4. HONEST AGGREGATION — `query`, when present, is computed over the
|
|
32
|
+
* WHOLE data set, never from a capped read. */
|
|
8
33
|
export interface CollectionStore {
|
|
9
34
|
readonly capabilities: CollectionStoreCapabilities;
|
|
10
|
-
/** Every record. CSV store: capped at
|
|
35
|
+
/** Every record, in the store's stable order. CSV store: capped at
|
|
36
|
+
* `MAX_CSV_ROWS` (see csvStore.ts). Prefer `page` in new code. */
|
|
11
37
|
list: () => Promise<CollectionItem[]>;
|
|
38
|
+
/** One page of records — offset/limit/projection over the stable order. */
|
|
39
|
+
page: (opts?: ListOptions) => Promise<ListPage>;
|
|
12
40
|
/** One record by id, or null when missing/invalid. */
|
|
13
41
|
read: (itemId: string) => Promise<CollectionItem | null>;
|
|
14
42
|
/** Aggregation over the WHOLE data set (the structured DSL,
|
|
15
43
|
* `core/queryZ.ts`) — present only on stores with a native query
|
|
16
|
-
* engine (the CSV store). Absent ⇒ the
|
|
17
|
-
*
|
|
44
|
+
* engine (the CSV store). Absent ⇒ use the engine-level fallback
|
|
45
|
+
* (`runCollectionQuery`), never emulate ad hoc. */
|
|
18
46
|
query?: (query: CollectionQuery) => Promise<Record<string, unknown>[]>;
|
|
47
|
+
/** Present ONLY when `capabilities.writable` — absence IS the read-only
|
|
48
|
+
* refusal (surface it with `readOnlyRefusal`). A successful write/delete
|
|
49
|
+
* publishes a collection-change event: the store always threads the
|
|
50
|
+
* collection's slug into the publish hook, so no writer can forget it. */
|
|
51
|
+
write?: (itemId: string, item: CollectionItem, opts?: WriteOptions) => Promise<WriteItemResult>;
|
|
52
|
+
delete?: (itemId: string) => Promise<DeleteItemResult>;
|
|
19
53
|
}
|
|
20
54
|
/** True when the collection accepts UI/tool writes. A `dataSource`
|
|
21
55
|
* collection is read-only: updates happen by editing/replacing the
|
|
@@ -24,8 +58,9 @@ export interface CollectionStore {
|
|
|
24
58
|
export declare function collectionWritable(collection: Pick<LoadedCollection, "schema">): boolean;
|
|
25
59
|
/** The one-line refusal write paths surface (HTTP 405 / MCP error text). */
|
|
26
60
|
export declare function readOnlyRefusal(slug: string): string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
*
|
|
61
|
+
export type CollectionStoreFactory = (collection: LoadedCollection, opts: IoOptions) => CollectionStore;
|
|
62
|
+
/** Pick the store implementation for a discovered collection via the
|
|
63
|
+
* factory registry. An unknown kind cannot normally reach here (the
|
|
64
|
+
* schema's `StorageZ` union gates it), so the throw is a loud invariant
|
|
65
|
+
* breach, not a user-facing path. */
|
|
31
66
|
export declare function storeFor(collection: LoadedCollection, opts?: IoOptions): CollectionStore;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CollectionItem } from '../core/schema';
|
|
2
|
+
/** Options for `page`. STORED fields only — computed fields (`derived` /
|
|
3
|
+
* `toggle` / `embed` / rollups) never reach the store; project them at the
|
|
4
|
+
* engine level after enrichment. */
|
|
5
|
+
export interface ListOptions {
|
|
6
|
+
/** 0-based offset into the store's stable order (see the contract). */
|
|
7
|
+
offset?: number;
|
|
8
|
+
/** Max records returned. Absent = all remaining (subject to store caps). */
|
|
9
|
+
limit?: number;
|
|
10
|
+
/** Keep only these fields per record (the primary key is always kept). */
|
|
11
|
+
fields?: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export interface ListPage {
|
|
14
|
+
items: CollectionItem[];
|
|
15
|
+
/** Records in the collection before offset/limit — a lower bound when
|
|
16
|
+
* `truncated` (the store capped its scan, e.g. `MAX_CSV_ROWS`). */
|
|
17
|
+
total: number;
|
|
18
|
+
truncated: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface WriteOptions {
|
|
21
|
+
/** Create semantics: fail with `kind: "conflict"` when the record
|
|
22
|
+
* already exists (an O_EXCL open in the file store — race-safe). */
|
|
23
|
+
refuseOverwrite?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Project `fields` (+ the primary key, always) out of each record. Thin
|
|
26
|
+
* server-typed alias over the shared isomorphic `projectRecordFields`
|
|
27
|
+
* (../core/project.ts) — kept as the store layer's exported name. */
|
|
28
|
+
export declare function projectItemFields(items: CollectionItem[], fields: readonly string[] | undefined, primaryKey: string): CollectionItem[];
|
|
29
|
+
/** Slice + project an already-ordered full read into a `ListPage` — the
|
|
30
|
+
* shared emulation for stores without native paging. Pure, exported for
|
|
31
|
+
* tests. `limit: 0` is a valid "count only" page. */
|
|
32
|
+
export declare function pageFromFullRead(items: CollectionItem[], opts: ListOptions, primaryKey: string, truncated: boolean): ListPage;
|