@gitsheets/core-napi 0.5.0 → 0.6.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/binding.cjs +6 -0
- package/index.d.ts +115 -5
- package/index.js +7 -1
- package/package.json +8 -8
package/binding.cjs
CHANGED
|
@@ -152,6 +152,7 @@ module.exports = {
|
|
|
152
152
|
treeReadBlob: wrap(addon.treeReadBlob),
|
|
153
153
|
treeEntryHash: wrap(addon.treeEntryHash),
|
|
154
154
|
blobRead: wrap(addon.blobRead),
|
|
155
|
+
blobHeader: wrap(addon.blobHeader),
|
|
155
156
|
templateFieldNames: wrap(addon.templateFieldNames),
|
|
156
157
|
// Secondary indexing (lazy, in-memory). A unique conflict surfaces as a typed
|
|
157
158
|
// IndexError(index_unique_conflict).
|
|
@@ -169,7 +170,12 @@ module.exports = {
|
|
|
169
170
|
// `mapCoreError` where a typed instance is wanted.
|
|
170
171
|
CoreTransaction: addon.CoreTransaction,
|
|
171
172
|
coreDiscoverSheets: wrap(addon.coreDiscoverSheets),
|
|
173
|
+
syncBranch: wrap(addon.syncBranch),
|
|
174
|
+
isAncestor: wrap(addon.isAncestor),
|
|
175
|
+
mergeSheets: wrap(addon.mergeSheets),
|
|
176
|
+
mergeRecordTexts: wrap(addon.mergeRecordTexts),
|
|
172
177
|
coreCheckValidators: wrap(addon.coreCheckValidators),
|
|
178
|
+
sheetConfigCheck: wrap(addon.sheetConfigCheck),
|
|
173
179
|
// Consumer-side contract verification — the two-rung ladder behind
|
|
174
180
|
// `openSheet(name, { contract })` (specs/behaviors/contracts.md "Consumer
|
|
175
181
|
// verification"). A verification failure raises a typed
|
package/index.d.ts
CHANGED
|
@@ -265,6 +265,20 @@ export declare function treeEntryHash(gitDir: string, treeRef: string, path: str
|
|
|
265
265
|
* attachment content reads and diff-side record reads.
|
|
266
266
|
*/
|
|
267
267
|
export declare function blobRead(gitDir: string, hash: string): Buffer | null
|
|
268
|
+
/**
|
|
269
|
+
* An object header: `kind` (`blob` / `tree` / `commit` / `tag`) and `size` in
|
|
270
|
+
* bytes, read without inflating the object.
|
|
271
|
+
*/
|
|
272
|
+
export interface JsBlobHeader {
|
|
273
|
+
kind: string
|
|
274
|
+
size: number
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* The object header for `hash`, or `null` when no object has that id. The
|
|
278
|
+
* metadata behind a host `BlobHandle`'s `size` (specs/behaviors/attachments.md
|
|
279
|
+
* "Blob metadata and bounded buffering").
|
|
280
|
+
*/
|
|
281
|
+
export declare function blobHeader(gitDir: string, hash: string): JsBlobHeader | null
|
|
268
282
|
/** A blob read by `treeRef:path`: its object id and bytes. */
|
|
269
283
|
export interface JsBlobEntry {
|
|
270
284
|
hash: string
|
|
@@ -345,6 +359,12 @@ export interface JsTrailer {
|
|
|
345
359
|
*/
|
|
346
360
|
export interface JsTransactionOptions {
|
|
347
361
|
parent?: string
|
|
362
|
+
/**
|
|
363
|
+
* `transact({ parent: null })`: an orphan root commit — empty starting
|
|
364
|
+
* tree, no parents, always commits; `branch` is created (and must not
|
|
365
|
+
* already exist). `parent` is ignored when set.
|
|
366
|
+
*/
|
|
367
|
+
orphan?: boolean
|
|
348
368
|
branch?: string
|
|
349
369
|
author?: JsAuthor
|
|
350
370
|
committer?: JsAuthor
|
|
@@ -376,11 +396,100 @@ export interface JsAttachmentEntry {
|
|
|
376
396
|
name: string
|
|
377
397
|
hash: string
|
|
378
398
|
}
|
|
399
|
+
/** Options for [`sync_branch`]. */
|
|
400
|
+
export interface JsSyncOptions {
|
|
401
|
+
/** Local branch (bare name or qualified ref). */
|
|
402
|
+
branch: string
|
|
403
|
+
/** Remote-tracking ref (or any commit-ish), e.g. `refs/remotes/origin/main`. */
|
|
404
|
+
remoteRef: string
|
|
405
|
+
/** `'fail'` (default) or `'preserve-branch'`. */
|
|
406
|
+
onConflict?: string
|
|
407
|
+
/** Prefix for the preserved branch; default `conflicts/`. */
|
|
408
|
+
conflictBranchPrefix?: string
|
|
409
|
+
/** Committer for replayed commits; default: the repository's identity. */
|
|
410
|
+
committer?: JsAuthor
|
|
411
|
+
timeSeconds: number
|
|
412
|
+
offsetMinutes: number
|
|
413
|
+
}
|
|
414
|
+
/** The result of [`sync_branch`]. */
|
|
415
|
+
export interface JsSyncResult {
|
|
416
|
+
outcome: string
|
|
417
|
+
oldCommit: string
|
|
418
|
+
newCommit: string
|
|
419
|
+
ahead: number
|
|
420
|
+
behind: number
|
|
421
|
+
conflictCommit?: string
|
|
422
|
+
conflictBranch?: string
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Classify the local branch against the remote-tracking tip and move it
|
|
426
|
+
* (fast-forward, replay, or preserve-on-conflict). The host fetches first
|
|
427
|
+
* and holds the write lock. See specs/behaviors/push-sync.md "Sync".
|
|
428
|
+
*/
|
|
429
|
+
export declare function syncBranch(gitDir: string, opts: JsSyncOptions): JsSyncResult
|
|
430
|
+
/** Whether commit `a` is reachable from commit `b` (or equal). */
|
|
431
|
+
export declare function isAncestor(gitDir: string, a: string, b: string): boolean
|
|
432
|
+
export interface JsMergeOptions {
|
|
433
|
+
ours: string
|
|
434
|
+
theirs: string
|
|
435
|
+
openRoot?: string
|
|
436
|
+
/** `fail` (default) | `ours` | `theirs`. */
|
|
437
|
+
prefer?: string
|
|
438
|
+
/** Default true; false writes the tree and moves nothing. */
|
|
439
|
+
commit?: boolean
|
|
440
|
+
message?: string
|
|
441
|
+
author?: JsAuthor
|
|
442
|
+
committer?: JsAuthor
|
|
443
|
+
timeSeconds: number
|
|
444
|
+
offsetMinutes: number
|
|
445
|
+
}
|
|
446
|
+
export interface JsMergeConflict {
|
|
447
|
+
path: string
|
|
448
|
+
kind: string
|
|
449
|
+
field?: string
|
|
450
|
+
ours?: string
|
|
451
|
+
theirs?: string
|
|
452
|
+
}
|
|
453
|
+
export interface JsMergeResult {
|
|
454
|
+
outcome: string
|
|
455
|
+
oursCommit: string
|
|
456
|
+
theirsCommit: string
|
|
457
|
+
base?: string
|
|
458
|
+
tree?: string
|
|
459
|
+
commit?: string
|
|
460
|
+
mergedRecords: Array<string>
|
|
461
|
+
conflicts: Array<JsMergeConflict>
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Sheet-aware merge of `theirs` into `ours` — record files changed on both
|
|
465
|
+
* sides are field-merged and written canonically; conflicts follow `prefer`
|
|
466
|
+
* or are reported. The host holds the write lock.
|
|
467
|
+
*/
|
|
468
|
+
export declare function mergeSheets(gitDir: string, opts: JsMergeOptions): JsMergeResult
|
|
469
|
+
export interface JsRecordMergeOutcome {
|
|
470
|
+
text?: string
|
|
471
|
+
conflicts: Array<string>
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Field-merge one record's base / ours / theirs texts through the sheet at
|
|
475
|
+
* `treeRef` (the merge-driver primitive): canonical text, or the conflicting
|
|
476
|
+
* field paths.
|
|
477
|
+
*/
|
|
478
|
+
export declare function mergeRecordTexts(gitDir: string, treeRef: string, sheetName: string, configPath: string, openRoot: string, base: string | undefined | null, ours: string, theirs: string, prefer?: string | undefined | null): JsRecordMergeOutcome
|
|
379
479
|
/**
|
|
380
480
|
* Discover every sheet declared in `<openRoot>/.gitsheets/*.toml` in the tree
|
|
381
481
|
* `treeRef`. Sorted bare names. The `Store` discovery half (`openStore`).
|
|
382
482
|
*/
|
|
383
483
|
export declare function coreDiscoverSheets(gitDir: string, treeRef: string, openRoot: string): Array<string>
|
|
484
|
+
/**
|
|
485
|
+
* Open the sheet whose config blob lives at `configPath` in the tree `treeRef`
|
|
486
|
+
* and discard it — the full open-time validation the core performs
|
|
487
|
+
* (config parse, contract load/compile, template coherence per
|
|
488
|
+
* specs/behaviors/path-templates.md "Template fields must be
|
|
489
|
+
* schema-required") surfaced to the host as typed errors. The host calls it
|
|
490
|
+
* once per distinct config blob from `repo.openSheet`.
|
|
491
|
+
*/
|
|
492
|
+
export declare function sheetConfigCheck(gitDir: string, treeRef: string, sheetName: string, configPath: string, openRoot: string): void
|
|
384
493
|
/**
|
|
385
494
|
* The `openStore` `config_missing` check: every validator must name a declared
|
|
386
495
|
* sheet. Throws `ConfigError(config_missing)` otherwise.
|
|
@@ -502,12 +611,13 @@ export declare class CoreTransaction {
|
|
|
502
611
|
/** Stage a single attachment *(mutating)* — sugar over [`Self::set_attachments`]. */
|
|
503
612
|
setAttachment(name: string, recordPath: string, attachmentName: string, blobHash: string): void
|
|
504
613
|
/**
|
|
505
|
-
* Stage a raw
|
|
506
|
-
* *(mutating)* — the
|
|
507
|
-
*
|
|
508
|
-
*
|
|
614
|
+
* Stage a raw file at `path` in this transaction's private tree
|
|
615
|
+
* *(mutating)* — the public `tx.writeFile` (specs/api/transaction.md
|
|
616
|
+
* "Raw files"): a sheet config, a contract, a fixture, committed with the
|
|
617
|
+
* record changes it belongs with. `path` is repo-root-relative; `content`
|
|
618
|
+
* is UTF-8 text or raw bytes. Returns the written blob hash.
|
|
509
619
|
*/
|
|
510
|
-
writeFile(path: string, content: string): string
|
|
620
|
+
writeFile(path: string, content: string | Buffer): string
|
|
511
621
|
/**
|
|
512
622
|
* Delete a raw file at `path` (repo-root-relative) in this transaction's
|
|
513
623
|
* private tree *(mutating)* — `write_file`'s inverse. Returns whether a
|
package/index.js
CHANGED
|
@@ -310,7 +310,7 @@ if (!nativeBinding) {
|
|
|
310
310
|
throw new Error(`Failed to load native binding`)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
const { roundtrip, parseRecords, serializeRecords, renderPathsBatch, validateBatch, canonicalContractHash, validateContractName, contractPath, checkContractDocument, contractLoad, verifySheetContract, runComparator, collatorSort, CompiledDefinition, recordRead, recordWrite, recordDelete, recordList, writeBlob, substrateStats, substrateReset, recordQuery, treeReadBlob, treeEntryHash, blobRead, recordQueryCandidates, templateFieldNames, recordIndexUnique, recordIndexMulti, createPatch, applyMergePatch, diffRecords, simulateCoreError, CoreTransaction, coreDiscoverSheets, coreCheckValidators, markdownSerialize, markdownNormalizeBody, markdownParse, markdownParseHeaderOnly, markdownExtractH1, markdownRewriteH1 } = nativeBinding
|
|
313
|
+
const { roundtrip, parseRecords, serializeRecords, renderPathsBatch, validateBatch, canonicalContractHash, validateContractName, contractPath, checkContractDocument, contractLoad, verifySheetContract, runComparator, collatorSort, CompiledDefinition, recordRead, recordWrite, recordDelete, recordList, writeBlob, substrateStats, substrateReset, recordQuery, treeReadBlob, treeEntryHash, blobRead, blobHeader, recordQueryCandidates, templateFieldNames, recordIndexUnique, recordIndexMulti, createPatch, applyMergePatch, diffRecords, simulateCoreError, CoreTransaction, syncBranch, isAncestor, mergeSheets, mergeRecordTexts, coreDiscoverSheets, sheetConfigCheck, coreCheckValidators, markdownSerialize, markdownNormalizeBody, markdownParse, markdownParseHeaderOnly, markdownExtractH1, markdownRewriteH1 } = nativeBinding
|
|
314
314
|
|
|
315
315
|
module.exports.roundtrip = roundtrip
|
|
316
316
|
module.exports.parseRecords = parseRecords
|
|
@@ -337,6 +337,7 @@ module.exports.recordQuery = recordQuery
|
|
|
337
337
|
module.exports.treeReadBlob = treeReadBlob
|
|
338
338
|
module.exports.treeEntryHash = treeEntryHash
|
|
339
339
|
module.exports.blobRead = blobRead
|
|
340
|
+
module.exports.blobHeader = blobHeader
|
|
340
341
|
module.exports.recordQueryCandidates = recordQueryCandidates
|
|
341
342
|
module.exports.templateFieldNames = templateFieldNames
|
|
342
343
|
module.exports.recordIndexUnique = recordIndexUnique
|
|
@@ -346,7 +347,12 @@ module.exports.applyMergePatch = applyMergePatch
|
|
|
346
347
|
module.exports.diffRecords = diffRecords
|
|
347
348
|
module.exports.simulateCoreError = simulateCoreError
|
|
348
349
|
module.exports.CoreTransaction = CoreTransaction
|
|
350
|
+
module.exports.syncBranch = syncBranch
|
|
351
|
+
module.exports.isAncestor = isAncestor
|
|
352
|
+
module.exports.mergeSheets = mergeSheets
|
|
353
|
+
module.exports.mergeRecordTexts = mergeRecordTexts
|
|
349
354
|
module.exports.coreDiscoverSheets = coreDiscoverSheets
|
|
355
|
+
module.exports.sheetConfigCheck = sheetConfigCheck
|
|
350
356
|
module.exports.coreCheckValidators = coreCheckValidators
|
|
351
357
|
module.exports.markdownSerialize = markdownSerialize
|
|
352
358
|
module.exports.markdownNormalizeBody = markdownNormalizeBody
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitsheets/core-napi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Node.js native binding for gitsheets-core — the FFI marshalling boundary.",
|
|
5
5
|
"main": "binding.cjs",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
"index.d.ts"
|
|
34
34
|
],
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@gitsheets/core-napi-linux-x64-gnu": "0.
|
|
37
|
-
"@gitsheets/core-napi-linux-arm64-gnu": "0.
|
|
38
|
-
"@gitsheets/core-napi-linux-x64-musl": "0.
|
|
39
|
-
"@gitsheets/core-napi-darwin-arm64": "0.
|
|
40
|
-
"@gitsheets/core-napi-darwin-x64": "0.
|
|
41
|
-
"@gitsheets/core-napi-win32-x64-msvc": "0.
|
|
36
|
+
"@gitsheets/core-napi-linux-x64-gnu": "0.6.0",
|
|
37
|
+
"@gitsheets/core-napi-linux-arm64-gnu": "0.6.0",
|
|
38
|
+
"@gitsheets/core-napi-linux-x64-musl": "0.6.0",
|
|
39
|
+
"@gitsheets/core-napi-darwin-arm64": "0.6.0",
|
|
40
|
+
"@gitsheets/core-napi-darwin-x64": "0.6.0",
|
|
41
|
+
"@gitsheets/core-napi-win32-x64-msvc": "0.6.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"artifacts": "napi artifacts",
|
|
45
45
|
"build": "napi build --platform --release",
|
|
46
46
|
"build:debug": "napi build --platform",
|
|
47
47
|
"prepublishOnly": "napi prepublish -t npm --skip-gh-release",
|
|
48
|
-
"test": "node --test test/roundtrip.mjs test/errors.mjs test/canonical.mjs test/path-template.mjs test/validation-parity.mjs test/engine-parity.mjs test/collator-parity.mjs test/record-crud.mjs test/record-query.mjs test/record-index.mjs test/sheet-store.mjs test/sheet-markdown.mjs test/sheet-attachments.mjs test/contracts.mjs",
|
|
48
|
+
"test": "node --test test/roundtrip.mjs test/errors.mjs test/canonical.mjs test/path-template.mjs test/validation-parity.mjs test/engine-parity.mjs test/collator-parity.mjs test/record-crud.mjs test/record-query.mjs test/record-index.mjs test/sheet-store.mjs test/sheet-markdown.mjs test/sheet-attachments.mjs test/contracts.mjs test/sheet-config-check.mjs test/orphan-and-files.mjs",
|
|
49
49
|
"bench": "node bench/query-bench.mjs",
|
|
50
50
|
"version": "napi version"
|
|
51
51
|
},
|