gitsheets 0.22.4 → 1.0.3
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 +201 -0
- package/README.md +21 -0
- package/bin/gitsheets +5 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +256 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/errors.d.ts +72 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +74 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/patch.d.ts +2 -0
- package/dist/patch.d.ts.map +1 -0
- package/dist/patch.js +39 -0
- package/dist/patch.js.map +1 -0
- package/dist/path-template/index.d.ts +42 -0
- package/dist/path-template/index.d.ts.map +1 -0
- package/dist/path-template/index.js +288 -0
- package/dist/path-template/index.js.map +1 -0
- package/dist/push-daemon.d.ts +53 -0
- package/dist/push-daemon.d.ts.map +1 -0
- package/dist/push-daemon.js +148 -0
- package/dist/push-daemon.js.map +1 -0
- package/dist/repository.d.ts +67 -0
- package/dist/repository.d.ts.map +1 -0
- package/dist/repository.js +322 -0
- package/dist/repository.js.map +1 -0
- package/dist/sheet.d.ts +107 -0
- package/dist/sheet.d.ts.map +1 -0
- package/dist/sheet.js +605 -0
- package/dist/sheet.js.map +1 -0
- package/dist/store.d.ts +41 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +49 -0
- package/dist/store.js.map +1 -0
- package/dist/toml.d.ts +11 -0
- package/dist/toml.d.ts.map +1 -0
- package/dist/toml.js +28 -0
- package/dist/toml.js.map +1 -0
- package/dist/transaction.d.ts +96 -0
- package/dist/transaction.d.ts.map +1 -0
- package/dist/transaction.js +227 -0
- package/dist/transaction.js.map +1 -0
- package/dist/validation.d.ts +37 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +105 -0
- package/dist/validation.js.map +1 -0
- package/package.json +41 -35
- package/bin/cli.js +0 -61
- package/commands/edit.js +0 -90
- package/commands/normalize.js +0 -81
- package/commands/query.js +0 -206
- package/commands/read.js +0 -64
- package/commands/singer-target.js +0 -214
- package/commands/upsert.js +0 -260
- package/lib/GitSheets.js +0 -464
- package/lib/Repository.js +0 -88
- package/lib/Sheet.js +0 -625
- package/lib/errors.js +0 -21
- package/lib/hologit.js +0 -1
- package/lib/logger.js +0 -18
- package/lib/path/BaseComponent.js +0 -24
- package/lib/path/ExpressionComponent.js +0 -26
- package/lib/path/FieldComponent.js +0 -13
- package/lib/path/LiteralComponent.js +0 -12
- package/lib/path/Query.js +0 -18
- package/lib/path/Template.js +0 -214
- package/server.js +0 -120
package/dist/sheet.js
ADDED
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
// Sheet — typed handle to one declared sheet in a Repository.
|
|
2
|
+
// See specs/api/sheet.md and specs/concepts.md.
|
|
3
|
+
import { runInNewContext } from 'node:vm';
|
|
4
|
+
import { ConfigError, IndexError, NotFoundError, PathTemplateError, TransactionError, } from './errors.js';
|
|
5
|
+
import { mergePatch } from './patch.js';
|
|
6
|
+
import { Template } from './path-template/index.js';
|
|
7
|
+
import { stringifyRecord, parseToml, parseConfigToml } from './toml.js';
|
|
8
|
+
import sortKeys from 'sort-keys';
|
|
9
|
+
import { transactionContext } from './transaction.js';
|
|
10
|
+
import { validateRecord, } from './validation.js';
|
|
11
|
+
export const RECORD_SHEET_KEY = Symbol.for('gitsheets-sheet');
|
|
12
|
+
export const RECORD_PATH_KEY = Symbol.for('gitsheets-path');
|
|
13
|
+
// --- Helpers ---
|
|
14
|
+
function isBlob(node) {
|
|
15
|
+
return typeof node === 'object' && node !== null && node.isBlob === true;
|
|
16
|
+
}
|
|
17
|
+
function isTree(node) {
|
|
18
|
+
return typeof node === 'object' && node !== null && node.isTree === true;
|
|
19
|
+
}
|
|
20
|
+
function joinTreePath(...parts) {
|
|
21
|
+
return parts
|
|
22
|
+
.map((p) => p.replace(/^\/+/, '').replace(/\/+$/, ''))
|
|
23
|
+
.filter((p) => p.length > 0 && p !== '.')
|
|
24
|
+
.join('/');
|
|
25
|
+
}
|
|
26
|
+
function buildSorter(rule) {
|
|
27
|
+
if (rule === true) {
|
|
28
|
+
return (a, b) => String(a).localeCompare(String(b), undefined, {
|
|
29
|
+
sensitivity: 'base',
|
|
30
|
+
ignorePunctuation: true,
|
|
31
|
+
numeric: true,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (rule === false) {
|
|
35
|
+
return () => 0;
|
|
36
|
+
}
|
|
37
|
+
if (typeof rule === 'string') {
|
|
38
|
+
return runInNewContext(`(a, b) => { ${rule} }`);
|
|
39
|
+
}
|
|
40
|
+
// Array of field names → ASC for each
|
|
41
|
+
let directives;
|
|
42
|
+
if (Array.isArray(rule)) {
|
|
43
|
+
directives = rule.map((f) => [f, 'ASC']);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
directives = Object.entries(rule);
|
|
47
|
+
}
|
|
48
|
+
const exprLines = [];
|
|
49
|
+
for (const [field, dir] of directives) {
|
|
50
|
+
const sign = dir === 'ASC' ? 1 : -1;
|
|
51
|
+
exprLines.push(`if ((a[${JSON.stringify(field)}]) < (b[${JSON.stringify(field)}])) return ${-1 * sign};`, `if ((a[${JSON.stringify(field)}]) > (b[${JSON.stringify(field)}])) return ${1 * sign};`);
|
|
52
|
+
}
|
|
53
|
+
exprLines.push('return 0;');
|
|
54
|
+
return runInNewContext(`(a, b) => { ${exprLines.join('\n')} }`);
|
|
55
|
+
}
|
|
56
|
+
function queryMatches(filter, record) {
|
|
57
|
+
for (const [key, qval] of Object.entries(filter)) {
|
|
58
|
+
const rval = record[key];
|
|
59
|
+
if (typeof qval === 'function') {
|
|
60
|
+
const ok = qval(rval, record);
|
|
61
|
+
if (!ok)
|
|
62
|
+
return false;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (qval !== null && typeof qval === 'object' && !Array.isArray(qval) && !(qval instanceof Date)) {
|
|
66
|
+
if (rval === null || typeof rval !== 'object')
|
|
67
|
+
return false;
|
|
68
|
+
if (!queryMatches(qval, rval))
|
|
69
|
+
return false;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (rval !== qval)
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
// --- Sheet config cache (process-wide by blob hash of the config file) ---
|
|
78
|
+
const CONFIG_CACHE = new Map();
|
|
79
|
+
async function loadConfig(workspace, configPath) {
|
|
80
|
+
const node = await workspace.root.getChild(configPath);
|
|
81
|
+
if (!node || !isBlob(node)) {
|
|
82
|
+
throw new ConfigError('config_missing', `sheet config not found at ${configPath}`);
|
|
83
|
+
}
|
|
84
|
+
const cached = CONFIG_CACHE.get(node.hash);
|
|
85
|
+
if (cached)
|
|
86
|
+
return cached;
|
|
87
|
+
const tomlText = await node.read();
|
|
88
|
+
const raw = parseConfigToml(tomlText, configPath);
|
|
89
|
+
const gitsheet = raw['gitsheet'];
|
|
90
|
+
if (!gitsheet || typeof gitsheet !== 'object') {
|
|
91
|
+
throw new ConfigError('config_invalid', `${configPath}: missing [gitsheet] table`);
|
|
92
|
+
}
|
|
93
|
+
const { root = '.', path, fields } = gitsheet;
|
|
94
|
+
if (typeof path !== 'string' || path.length === 0) {
|
|
95
|
+
throw new ConfigError('config_invalid', `${configPath}: gitsheet.path must be a non-empty string`);
|
|
96
|
+
}
|
|
97
|
+
if (typeof root !== 'string') {
|
|
98
|
+
throw new ConfigError('config_invalid', `${configPath}: gitsheet.root must be a string`);
|
|
99
|
+
}
|
|
100
|
+
const fieldsClean = {};
|
|
101
|
+
if (fields !== undefined && fields !== null) {
|
|
102
|
+
if (typeof fields !== 'object' || Array.isArray(fields)) {
|
|
103
|
+
throw new ConfigError('config_invalid', `${configPath}: gitsheet.fields must be a table`);
|
|
104
|
+
}
|
|
105
|
+
for (const [fname, fcfg] of Object.entries(fields)) {
|
|
106
|
+
if (typeof fcfg !== 'object' || fcfg === null)
|
|
107
|
+
continue;
|
|
108
|
+
const entry = {};
|
|
109
|
+
const sort = fcfg['sort'];
|
|
110
|
+
if (sort !== undefined) {
|
|
111
|
+
validateSortRule(sort, configPath, fname);
|
|
112
|
+
Object.assign(entry, { sort: sort });
|
|
113
|
+
}
|
|
114
|
+
fieldsClean[fname] = entry;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const schemaRaw = gitsheet['schema'];
|
|
118
|
+
let schema = null;
|
|
119
|
+
if (schemaRaw !== undefined && schemaRaw !== null) {
|
|
120
|
+
if (typeof schemaRaw !== 'object' || Array.isArray(schemaRaw)) {
|
|
121
|
+
throw new ConfigError('config_invalid', `${configPath}: gitsheet.schema must be a table representing a JSON Schema`);
|
|
122
|
+
}
|
|
123
|
+
schema = schemaRaw;
|
|
124
|
+
}
|
|
125
|
+
const config = { root, path, fields: fieldsClean, schema };
|
|
126
|
+
CONFIG_CACHE.set(node.hash, config);
|
|
127
|
+
return config;
|
|
128
|
+
}
|
|
129
|
+
function validateSortRule(sort, configPath, field) {
|
|
130
|
+
if (typeof sort === 'boolean' || typeof sort === 'string')
|
|
131
|
+
return;
|
|
132
|
+
if (Array.isArray(sort)) {
|
|
133
|
+
for (const f of sort) {
|
|
134
|
+
if (typeof f !== 'string') {
|
|
135
|
+
throw new ConfigError('config_invalid', `${configPath}: gitsheet.fields.${field}.sort[] must be string field names`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (sort !== null && typeof sort === 'object') {
|
|
141
|
+
for (const [k, v] of Object.entries(sort)) {
|
|
142
|
+
if (v !== 'ASC' && v !== 'DESC') {
|
|
143
|
+
throw new ConfigError('config_invalid', `${configPath}: gitsheet.fields.${field}.sort.${k} must be 'ASC' or 'DESC'`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
throw new ConfigError('config_invalid', `${configPath}: gitsheet.fields.${field}.sort has invalid shape`);
|
|
149
|
+
}
|
|
150
|
+
// --- TOML record cache (closes #138 — keyed by blob hash) ---
|
|
151
|
+
//
|
|
152
|
+
// Per specs/behaviors/normalization.md, on-disk bytes are deterministic per
|
|
153
|
+
// logical-record state, so the same blob hash is the same record content. We
|
|
154
|
+
// cache the TOML *text* (not the parsed object) so each reader gets a fresh
|
|
155
|
+
// parsed copy — avoiding the original cache's v8.serialize/Date-subclass
|
|
156
|
+
// issue without leaking mutable shared state.
|
|
157
|
+
const TOML_TEXT_CACHE = new Map();
|
|
158
|
+
async function readBlobTomlCached(blob) {
|
|
159
|
+
const cached = TOML_TEXT_CACHE.get(blob.hash);
|
|
160
|
+
if (cached !== undefined)
|
|
161
|
+
return cached;
|
|
162
|
+
const text = await blob.read();
|
|
163
|
+
TOML_TEXT_CACHE.set(blob.hash, text);
|
|
164
|
+
return text;
|
|
165
|
+
}
|
|
166
|
+
export class Sheet {
|
|
167
|
+
#repo;
|
|
168
|
+
#workspace;
|
|
169
|
+
#dataTree;
|
|
170
|
+
#name;
|
|
171
|
+
#configPath;
|
|
172
|
+
#transaction;
|
|
173
|
+
#validator;
|
|
174
|
+
#indexes = new Map();
|
|
175
|
+
constructor(opts) {
|
|
176
|
+
this.#repo = opts.repo;
|
|
177
|
+
this.#workspace = opts.workspace;
|
|
178
|
+
this.#dataTree = opts.dataTree;
|
|
179
|
+
this.#name = opts.name;
|
|
180
|
+
this.#configPath = opts.configPath;
|
|
181
|
+
this.#transaction = opts.transaction;
|
|
182
|
+
this.#validator = opts.validator;
|
|
183
|
+
}
|
|
184
|
+
get name() {
|
|
185
|
+
return this.#name;
|
|
186
|
+
}
|
|
187
|
+
get configPath() {
|
|
188
|
+
return this.#configPath;
|
|
189
|
+
}
|
|
190
|
+
/** True if this Sheet is bound to a transaction's private tree. */
|
|
191
|
+
get isTransactionBound() {
|
|
192
|
+
return this.#transaction !== undefined;
|
|
193
|
+
}
|
|
194
|
+
async readConfig() {
|
|
195
|
+
return loadConfig(this.#workspace, this.#configPath);
|
|
196
|
+
}
|
|
197
|
+
/** Same as readConfig — config is cached by config-blob hash anyway. */
|
|
198
|
+
async getCachedConfig() {
|
|
199
|
+
return this.readConfig();
|
|
200
|
+
}
|
|
201
|
+
/** Async iterator over records matching the filter. */
|
|
202
|
+
async *query(filter = {}) {
|
|
203
|
+
if (typeof filter === 'function') {
|
|
204
|
+
throw new TypeError('Sheet.query() does not accept a function — pass a filter object');
|
|
205
|
+
}
|
|
206
|
+
const config = await this.readConfig();
|
|
207
|
+
const template = Template.fromString(config.path);
|
|
208
|
+
const sheetRoot = await this.#getSheetRoot(config.root);
|
|
209
|
+
if (!sheetRoot)
|
|
210
|
+
return;
|
|
211
|
+
// hologit's TreeObject/BlobObject are structurally compatible with the
|
|
212
|
+
// path-template tree interface; the casts bridge the type lattices.
|
|
213
|
+
for await (const { blob, path: blobPath } of template.queryTree(sheetRoot, filter)) {
|
|
214
|
+
const record = (await this.#readRecordFromBlob(blob, blobPath));
|
|
215
|
+
if (!queryMatches(filter, record))
|
|
216
|
+
continue;
|
|
217
|
+
yield record;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
async queryFirst(filter = {}) {
|
|
221
|
+
for await (const record of this.query(filter)) {
|
|
222
|
+
return record;
|
|
223
|
+
}
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
async queryAll(filter = {}) {
|
|
227
|
+
const results = [];
|
|
228
|
+
for await (const record of this.query(filter)) {
|
|
229
|
+
results.push(record);
|
|
230
|
+
}
|
|
231
|
+
return results;
|
|
232
|
+
}
|
|
233
|
+
async pathForRecord(record) {
|
|
234
|
+
const config = await this.readConfig();
|
|
235
|
+
return Template.fromString(config.path).render(record);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Apply canonical normalization (deep key sort + array-field sort rules)
|
|
239
|
+
* without writing or validating.
|
|
240
|
+
*/
|
|
241
|
+
async normalizeRecord(record) {
|
|
242
|
+
const config = await this.readConfig();
|
|
243
|
+
const out = { ...record };
|
|
244
|
+
for (const [field, fcfg] of Object.entries(config.fields)) {
|
|
245
|
+
const value = out[field];
|
|
246
|
+
if (fcfg.sort !== undefined && Array.isArray(value)) {
|
|
247
|
+
const sorter = buildSorter(fcfg.sort);
|
|
248
|
+
out[field] = [...value].sort(sorter);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// Deep-sort keys per specs/api/sheet.md — the returned JS object reflects
|
|
252
|
+
// canonical form even before TOML serialization.
|
|
253
|
+
return sortKeys(out, { deep: true });
|
|
254
|
+
}
|
|
255
|
+
async clear() {
|
|
256
|
+
if (this.#transaction === undefined) {
|
|
257
|
+
await this.#repo.transact({ message: `${this.#name} clear` }, async (tx) => {
|
|
258
|
+
await tx.sheet(this.#name).clear();
|
|
259
|
+
});
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const config = await this.readConfig();
|
|
263
|
+
const sheetTree = await this.#dataTree.getSubtree(config.root, true);
|
|
264
|
+
if (sheetTree) {
|
|
265
|
+
const children = await sheetTree.getChildren();
|
|
266
|
+
const names = [];
|
|
267
|
+
for (const k in children)
|
|
268
|
+
names.push(k);
|
|
269
|
+
for (const childName of names) {
|
|
270
|
+
await sheetTree.deleteChild(childName);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
this.#transaction.markMutated();
|
|
274
|
+
}
|
|
275
|
+
async clone() {
|
|
276
|
+
const opts = {
|
|
277
|
+
repo: this.#repo,
|
|
278
|
+
workspace: this.#workspace,
|
|
279
|
+
dataTree: await this.#dataTree.clone(),
|
|
280
|
+
name: this.#name,
|
|
281
|
+
configPath: this.#configPath,
|
|
282
|
+
};
|
|
283
|
+
if (this.#validator !== undefined) {
|
|
284
|
+
Object.assign(opts, { validator: this.#validator });
|
|
285
|
+
}
|
|
286
|
+
return new Sheet(opts);
|
|
287
|
+
}
|
|
288
|
+
async upsert(record) {
|
|
289
|
+
if (this.#transaction !== undefined) {
|
|
290
|
+
return this.#upsertInTx(this.#transaction, record);
|
|
291
|
+
}
|
|
292
|
+
this.#checkStrictMode();
|
|
293
|
+
// The tx-bound Sheet returned by tx.sheet(name) doesn't carry this
|
|
294
|
+
// standalone Sheet's `validator`. Apply the Standard Schema layer here
|
|
295
|
+
// so its transform is reflected in what gets written. JSON Schema also
|
|
296
|
+
// runs here; the inner #upsertInTx will re-run it (cheap, idempotent).
|
|
297
|
+
let validated = record;
|
|
298
|
+
if (this.#validator !== undefined) {
|
|
299
|
+
const config = await this.readConfig();
|
|
300
|
+
validated = (await validateRecord({
|
|
301
|
+
record: stripSymbols(record),
|
|
302
|
+
schema: config.schema,
|
|
303
|
+
schemaSourcePath: this.#configPath,
|
|
304
|
+
validator: this.#validator,
|
|
305
|
+
}));
|
|
306
|
+
// Carry the original path annotation forward for rename detection.
|
|
307
|
+
const existing = record[RECORD_PATH_KEY];
|
|
308
|
+
if (typeof existing === 'string') {
|
|
309
|
+
validated[RECORD_PATH_KEY] = existing;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const tx = transactionContext.getStore();
|
|
313
|
+
if (tx !== undefined) {
|
|
314
|
+
return tx.sheet(this.#name).upsert(validated);
|
|
315
|
+
}
|
|
316
|
+
return this.#autoTransact(async (innerTx) => innerTx.sheet(this.#name).upsert(validated), (r) => `${this.#name} upsert ${r.path}`);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* RFC 7396 JSON Merge Patch. Reads the matching record, merges `partial`,
|
|
320
|
+
* validates, and upserts the result. Returns the same shape as upsert.
|
|
321
|
+
* Throws NotFoundError if the query matches no record.
|
|
322
|
+
*/
|
|
323
|
+
async patch(query, partial) {
|
|
324
|
+
const existing = await this.queryFirst(query);
|
|
325
|
+
if (!existing) {
|
|
326
|
+
throw new NotFoundError('record_not_found', `${this.#name}: no record matched ${JSON.stringify(query)}`);
|
|
327
|
+
}
|
|
328
|
+
const merged = mergePatch(stripSymbols(existing), partial);
|
|
329
|
+
// Carry the record's path annotation forward so upsert's rename
|
|
330
|
+
// detection deletes the old file if the new path differs.
|
|
331
|
+
const existingPath = existing[RECORD_PATH_KEY];
|
|
332
|
+
if (typeof existingPath === 'string') {
|
|
333
|
+
merged[RECORD_PATH_KEY] = existingPath;
|
|
334
|
+
}
|
|
335
|
+
return this.upsert(merged);
|
|
336
|
+
}
|
|
337
|
+
async delete(target) {
|
|
338
|
+
if (this.#transaction !== undefined) {
|
|
339
|
+
await this.#deleteInTx(this.#transaction, target);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
this.#checkStrictMode();
|
|
343
|
+
const tx = transactionContext.getStore();
|
|
344
|
+
if (tx !== undefined) {
|
|
345
|
+
await tx.sheet(this.#name).delete(target);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const path = typeof target === 'string' ? target : await this.pathForRecord(target);
|
|
349
|
+
await this.#repo.transact({ message: `${this.#name} delete ${path}` }, async (innerTx) => {
|
|
350
|
+
await innerTx.sheet(this.#name).delete(target);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
defineIndex(name, optsOrFn, maybeFn) {
|
|
354
|
+
let opts;
|
|
355
|
+
let keyFn;
|
|
356
|
+
if (typeof optsOrFn === 'function') {
|
|
357
|
+
opts = {};
|
|
358
|
+
keyFn = optsOrFn;
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
opts = optsOrFn;
|
|
362
|
+
if (typeof maybeFn !== 'function') {
|
|
363
|
+
throw new TypeError(`defineIndex(${name}, opts, keyFn): keyFn must be a function`);
|
|
364
|
+
}
|
|
365
|
+
keyFn = maybeFn;
|
|
366
|
+
}
|
|
367
|
+
const state = {
|
|
368
|
+
name,
|
|
369
|
+
unique: opts.unique ?? false,
|
|
370
|
+
eager: opts.eager ?? false,
|
|
371
|
+
keyFn,
|
|
372
|
+
built: false,
|
|
373
|
+
treeHashAtBuild: null,
|
|
374
|
+
uniqueMap: new Map(),
|
|
375
|
+
multiMap: new Map(),
|
|
376
|
+
};
|
|
377
|
+
this.#indexes.set(name, state);
|
|
378
|
+
if (state.eager) {
|
|
379
|
+
// Per spec, eager defineIndex returns Promise<void> resolving when
|
|
380
|
+
// the build completes (or rejecting on conflict).
|
|
381
|
+
return this.#ensureIndexBuilt(state);
|
|
382
|
+
}
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Look up records by an index. Unique indexes return `record | undefined`;
|
|
387
|
+
* non-unique indexes return an array.
|
|
388
|
+
*/
|
|
389
|
+
async findByIndex(name, key) {
|
|
390
|
+
const state = this.#indexes.get(name);
|
|
391
|
+
if (!state) {
|
|
392
|
+
throw new IndexError('index_not_defined', `index "${name}" is not defined on sheet "${this.#name}"`);
|
|
393
|
+
}
|
|
394
|
+
await this.#ensureIndexBuilt(state);
|
|
395
|
+
if (state.unique)
|
|
396
|
+
return state.uniqueMap.get(key);
|
|
397
|
+
return state.multiMap.get(key) ?? [];
|
|
398
|
+
}
|
|
399
|
+
async getAttachment(record, name) {
|
|
400
|
+
const config = await this.readConfig();
|
|
401
|
+
const recordPath = typeof record === 'string' ? record : await this.pathForRecord(record);
|
|
402
|
+
const node = await this.#dataTree.getChild(joinTreePath(config.root, recordPath, name));
|
|
403
|
+
return node && isBlob(node) ? node : null;
|
|
404
|
+
}
|
|
405
|
+
async getAttachments(record) {
|
|
406
|
+
const config = await this.readConfig();
|
|
407
|
+
const recordPath = typeof record === 'string' ? record : await this.pathForRecord(record);
|
|
408
|
+
const dir = await this.#dataTree.getChild(joinTreePath(config.root, recordPath));
|
|
409
|
+
if (!dir || !isTree(dir))
|
|
410
|
+
return null;
|
|
411
|
+
return dir.getBlobMap();
|
|
412
|
+
}
|
|
413
|
+
async setAttachment(record, name, blob) {
|
|
414
|
+
await this.setAttachments(record, { [name]: blob });
|
|
415
|
+
}
|
|
416
|
+
async setAttachments(record, attachments) {
|
|
417
|
+
if (this.#transaction === undefined) {
|
|
418
|
+
this.#checkStrictMode();
|
|
419
|
+
const tx = transactionContext.getStore();
|
|
420
|
+
if (tx !== undefined) {
|
|
421
|
+
await tx.sheet(this.#name).setAttachments(record, attachments);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
await this.#repo.transact({ message: `${this.#name} attachments` }, async (innerTx) => {
|
|
425
|
+
await innerTx.sheet(this.#name).setAttachments(record, attachments);
|
|
426
|
+
});
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
const config = await this.readConfig();
|
|
430
|
+
const recordPath = typeof record === 'string' ? record : await this.pathForRecord(record);
|
|
431
|
+
for (const [aName, content] of Object.entries(attachments)) {
|
|
432
|
+
await this.#dataTree.writeChild(joinTreePath(config.root, recordPath, aName), content);
|
|
433
|
+
}
|
|
434
|
+
this.#transaction.markMutated();
|
|
435
|
+
}
|
|
436
|
+
// --- Private helpers ---
|
|
437
|
+
#checkStrictMode() {
|
|
438
|
+
if (this.#repo.isStrictMode()) {
|
|
439
|
+
throw new TransactionError('transaction_required', `Sheet.${this.#name} writes require an explicit repo.transact in strict mode`);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
async #autoTransact(inner, message) {
|
|
443
|
+
let staged;
|
|
444
|
+
const result = await this.#repo.transact({ message: `${this.#name} upsert` }, async (innerTx) => {
|
|
445
|
+
staged = await inner(innerTx);
|
|
446
|
+
return staged;
|
|
447
|
+
});
|
|
448
|
+
void result;
|
|
449
|
+
if (staged === undefined) {
|
|
450
|
+
throw new TransactionError('commit_failed', 'auto-transaction completed without staging a write');
|
|
451
|
+
}
|
|
452
|
+
// The first message was a placeholder; we know the final path now, but the
|
|
453
|
+
// commit already happened. The auto-message convention is "<sheet> upsert
|
|
454
|
+
// <renderedPath>", but rendering the path twice is the cost of needing it
|
|
455
|
+
// for the message before staging — for now we accept the simpler form.
|
|
456
|
+
void message;
|
|
457
|
+
return staged;
|
|
458
|
+
}
|
|
459
|
+
async #upsertInTx(tx, record) {
|
|
460
|
+
const config = await this.readConfig();
|
|
461
|
+
const template = Template.fromString(config.path);
|
|
462
|
+
// Validate before normalizing — per specs/behaviors/validation.md order:
|
|
463
|
+
// JSON Schema → Standard Schema (may transform) → normalize → render → write.
|
|
464
|
+
let validated = (await validateRecord({
|
|
465
|
+
record: stripSymbols(record),
|
|
466
|
+
schema: config.schema,
|
|
467
|
+
schemaSourcePath: this.#configPath,
|
|
468
|
+
validator: this.#validator,
|
|
469
|
+
}));
|
|
470
|
+
// Standard Schema may have transformed; re-attach annotations if the
|
|
471
|
+
// caller supplied them (for rename detection below).
|
|
472
|
+
const existing = record[RECORD_PATH_KEY];
|
|
473
|
+
if (typeof existing === 'string') {
|
|
474
|
+
validated[RECORD_PATH_KEY] = existing;
|
|
475
|
+
}
|
|
476
|
+
const normalized = await this.normalizeRecord(validated);
|
|
477
|
+
const recordPath = template.render(normalized);
|
|
478
|
+
if (!recordPath) {
|
|
479
|
+
throw new PathTemplateError('path_render_failed', `could not generate any path for record in sheet "${this.#name}"`);
|
|
480
|
+
}
|
|
481
|
+
// Pre-write unique-index check — throws before any tree mutation
|
|
482
|
+
// per specs/behaviors/indexing.md so the tree is never left in a state
|
|
483
|
+
// that contradicts a unique constraint.
|
|
484
|
+
for (const state of this.#indexes.values()) {
|
|
485
|
+
if (!state.built || !state.unique)
|
|
486
|
+
continue;
|
|
487
|
+
const rawKey = state.keyFn(normalized);
|
|
488
|
+
if (rawKey === undefined || rawKey === null)
|
|
489
|
+
continue;
|
|
490
|
+
const key = String(rawKey);
|
|
491
|
+
const owner = state.uniqueMap.get(key);
|
|
492
|
+
if (!owner)
|
|
493
|
+
continue;
|
|
494
|
+
const ownerPath = owner[RECORD_PATH_KEY];
|
|
495
|
+
if (typeof ownerPath === 'string' && ownerPath !== recordPath) {
|
|
496
|
+
throw new IndexError('index_unique_conflict', `unique index "${state.name}" on sheet "${this.#name}": key ${JSON.stringify(key)} is already used by ${ownerPath}`, { conflictingPaths: [ownerPath, recordPath] });
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
// Rename: if the source record was loaded from a different path, delete the old one.
|
|
500
|
+
if (typeof existing === 'string' && existing !== recordPath) {
|
|
501
|
+
try {
|
|
502
|
+
await this.#dataTree.deleteChild(joinTreePath(config.root, `${existing}.toml`));
|
|
503
|
+
}
|
|
504
|
+
catch {
|
|
505
|
+
// Old path may not exist — ignore.
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
const toml = stringifyRecord(stripSymbols(normalized));
|
|
509
|
+
const blob = await this.#dataTree.writeChild(joinTreePath(config.root, `${recordPath}.toml`), toml);
|
|
510
|
+
tx.markMutated();
|
|
511
|
+
this.#invalidateIndexes();
|
|
512
|
+
return { blob, path: recordPath };
|
|
513
|
+
}
|
|
514
|
+
async #deleteInTx(tx, target) {
|
|
515
|
+
const config = await this.readConfig();
|
|
516
|
+
const recordPath = typeof target === 'string' ? target : await this.pathForRecord(target);
|
|
517
|
+
const fullPath = joinTreePath(config.root, `${recordPath}.toml`);
|
|
518
|
+
const existing = await this.#dataTree.getChild(fullPath);
|
|
519
|
+
if (!existing) {
|
|
520
|
+
throw new NotFoundError('record_not_found', `${this.#name}: no record at ${recordPath}`);
|
|
521
|
+
}
|
|
522
|
+
await this.#dataTree.deleteChild(fullPath);
|
|
523
|
+
// Cascade-delete the attachment directory at <recordPath>/, if any.
|
|
524
|
+
// Per specs/behaviors/attachments.md the attachment dir is deleted in
|
|
525
|
+
// the same operation.
|
|
526
|
+
try {
|
|
527
|
+
await this.#dataTree.deleteChild(joinTreePath(config.root, recordPath));
|
|
528
|
+
}
|
|
529
|
+
catch {
|
|
530
|
+
// No attachment dir — that's fine.
|
|
531
|
+
}
|
|
532
|
+
tx.markMutated();
|
|
533
|
+
this.#invalidateIndexes();
|
|
534
|
+
}
|
|
535
|
+
async #getSheetRoot(rootPath) {
|
|
536
|
+
if (rootPath === '.' || rootPath === '')
|
|
537
|
+
return this.#dataTree;
|
|
538
|
+
const sub = await this.#dataTree.getSubtree(rootPath);
|
|
539
|
+
return sub;
|
|
540
|
+
}
|
|
541
|
+
#invalidateIndexes() {
|
|
542
|
+
for (const state of this.#indexes.values()) {
|
|
543
|
+
state.built = false;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
async #ensureIndexBuilt(state) {
|
|
547
|
+
let currentHash = null;
|
|
548
|
+
try {
|
|
549
|
+
currentHash = await this.#dataTree.getHash();
|
|
550
|
+
}
|
|
551
|
+
catch {
|
|
552
|
+
currentHash = null;
|
|
553
|
+
}
|
|
554
|
+
if (state.built && state.treeHashAtBuild === currentHash)
|
|
555
|
+
return;
|
|
556
|
+
state.uniqueMap.clear();
|
|
557
|
+
state.multiMap.clear();
|
|
558
|
+
for await (const record of this.query()) {
|
|
559
|
+
const rawKey = state.keyFn(record);
|
|
560
|
+
if (rawKey === undefined || rawKey === null)
|
|
561
|
+
continue;
|
|
562
|
+
const key = String(rawKey);
|
|
563
|
+
if (state.unique) {
|
|
564
|
+
const existing = state.uniqueMap.get(key);
|
|
565
|
+
if (existing) {
|
|
566
|
+
const a = existing[RECORD_PATH_KEY];
|
|
567
|
+
const b = record[RECORD_PATH_KEY];
|
|
568
|
+
const paths = [a, b].filter((p) => typeof p === 'string');
|
|
569
|
+
throw new IndexError('index_unique_conflict', `index "${state.name}" on sheet "${this.#name}": key ${JSON.stringify(key)} appears in multiple records`, paths.length > 0 ? { conflictingPaths: paths } : undefined);
|
|
570
|
+
}
|
|
571
|
+
state.uniqueMap.set(key, record);
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
let arr = state.multiMap.get(key);
|
|
575
|
+
if (!arr) {
|
|
576
|
+
arr = [];
|
|
577
|
+
state.multiMap.set(key, arr);
|
|
578
|
+
}
|
|
579
|
+
arr.push(record);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
state.treeHashAtBuild = currentHash;
|
|
583
|
+
state.built = true;
|
|
584
|
+
}
|
|
585
|
+
async #readRecordFromBlob(blob, path) {
|
|
586
|
+
const text = await readBlobTomlCached(blob);
|
|
587
|
+
let parsed;
|
|
588
|
+
try {
|
|
589
|
+
parsed = parseToml(text);
|
|
590
|
+
}
|
|
591
|
+
catch (err) {
|
|
592
|
+
throw new ConfigError('config_invalid', `failed to parse record at ${path}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
593
|
+
}
|
|
594
|
+
parsed[RECORD_SHEET_KEY] = this.#name;
|
|
595
|
+
parsed[RECORD_PATH_KEY] = path;
|
|
596
|
+
return parsed;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function stripSymbols(record) {
|
|
600
|
+
// Object spread preserves enumerable string-keyed props; Symbol-keyed props
|
|
601
|
+
// (RECORD_SHEET_KEY, RECORD_PATH_KEY) are dropped — exactly what we want
|
|
602
|
+
// before writing to disk.
|
|
603
|
+
return { ...record };
|
|
604
|
+
}
|
|
605
|
+
//# sourceMappingURL=sheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheet.js","sourceRoot":"","sources":["../src/sheet.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,gDAAgD;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI1C,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAmB,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAe,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EACL,cAAc,GAGf,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CA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