@estiva-app/interop 0.48.0 → 0.50.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/CHANGELOG.md +38 -0
- package/README.md +17 -1
- package/dist/folders.d.ts +66 -0
- package/dist/folders.d.ts.map +1 -1
- package/dist/folders.js +70 -0
- package/dist/folders.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/projection.d.ts +3 -1
- package/dist/projection.d.ts.map +1 -1
- package/dist/projection.js.map +1 -1
- package/dist/references.d.ts +8 -7
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +25 -13
- package/dist/references.js.map +1 -1
- package/package.json +3 -3
- package/src/folders.ts +94 -0
- package/src/index.ts +2 -0
- package/src/projection.ts +3 -1
- package/src/references.ts +29 -12
package/dist/references.d.ts
CHANGED
|
@@ -38,14 +38,15 @@ export interface SearchFileReferencesOptions extends Omit<FileCandidatesOptions,
|
|
|
38
38
|
limit?: number;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* The files whose **current** title
|
|
41
|
+
* The files whose **current** title — or, for an issue, current ref (CON-33)
|
|
42
|
+
* — holds `text`, as the search tier.
|
|
42
43
|
*
|
|
43
|
-
* The relay indexes a root's `title` and a
|
|
44
|
-
*
|
|
45
|
-
* it was created with, and a rename found by an old word may since have
|
|
46
|
-
* renamed again. So a hit is only an address: each is read back as its
|
|
47
|
-
* and changes, folded through its app's manifest, and kept only when what
|
|
48
|
-
* is called now matches what was typed.
|
|
44
|
+
* The relay indexes a root's `title` and `ref` and a change's `value` for those
|
|
45
|
+
* fields (SPEC §5.2); none is the current one on its own — a root keeps the
|
|
46
|
+
* name it was created with, and a rename found by an old word may since have
|
|
47
|
+
* been renamed again. So a hit is only an address: each is read back as its
|
|
48
|
+
* root and changes, folded through its app's manifest, and kept only when what
|
|
49
|
+
* it is called now matches what was typed.
|
|
49
50
|
*
|
|
50
51
|
* Roots and renames are asked for separately, so a burst of renames cannot
|
|
51
52
|
* crowd every root out of the answer, and with buzz's prefix mode, so the word
|
package/dist/references.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,OAAO,EACb,MAAM,iBAAiB,CAAA;AAKxB,sEAAsE;AACtE,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAIxE,CAAA;AAqBD,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,0FAA0F;IAC1F,EAAE,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,SAAS,CAAC,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EACtD,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,EAAE,KAAK,EAAE,EAAE,EAAE,GAAE,qBAA0B,GACxC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA6B/B;AAED,MAAM,WAAW,2BAA4B,SAAQ,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC;IACpF,2FAA2F;IAC3F,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAWD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,EAAE,KAAU,EAAE,GAAG,OAAO,EAAE,GAAE,2BAAgC,GAC3D,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAqB/B"}
|
package/dist/references.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* never a row, so nothing unreadable is offered. An archived file is offered
|
|
13
13
|
* at the lowest priority, and so is an issue in an archived project.
|
|
14
14
|
*/
|
|
15
|
-
import { FILE_TIER, fileReference, KIND_CHANGE, referenceMatch, } from '@estiva-app/conversation';
|
|
15
|
+
import { FILE_TIER, fileReference, KIND_CHANGE, referenceMatch, refMatch, } from '@estiva-app/conversation';
|
|
16
16
|
import { isClosedStatus, KIND_BARE_FILE, resolveForeignRoots, } from './projection.js';
|
|
17
17
|
const KIND_PROJECT = 30850;
|
|
18
18
|
const KIND_ISSUE = 30851;
|
|
@@ -29,6 +29,11 @@ const offerable = (object) => !!object &&
|
|
|
29
29
|
!object.unreachable &&
|
|
30
30
|
typeOf(object.kind) !== undefined &&
|
|
31
31
|
!!object.slots.title?.value.trim();
|
|
32
|
+
/**
|
|
33
|
+
* An issue's current ref (`CON-33`, SPEC §6.1) — the manifest slot that folds
|
|
34
|
+
* the `ref` field — so typing it finds the issue. Only an issue has one.
|
|
35
|
+
*/
|
|
36
|
+
const refOf = (object) => object.kind === KIND_ISSUE ? object.meta.find((slot) => slot.field === 'ref')?.value.trim() || undefined : undefined;
|
|
32
37
|
/**
|
|
33
38
|
* Rows for resolved files, all in one tier.
|
|
34
39
|
*
|
|
@@ -57,14 +62,17 @@ export async function fileCandidates(objects, tier, query, { cache, at } = {}) {
|
|
|
57
62
|
}
|
|
58
63
|
return files.map((o) => {
|
|
59
64
|
const parent = o.kind === KIND_ISSUE && o.parentRef ? parents.get(o.parentRef) : undefined;
|
|
65
|
+
const ref = refOf(o);
|
|
60
66
|
return {
|
|
61
67
|
id: o.address,
|
|
62
68
|
uri: fileReference(o.address),
|
|
63
69
|
type: typeOf(o.kind),
|
|
64
70
|
kind: o.kind,
|
|
65
71
|
title: o.slots.title.value,
|
|
66
|
-
|
|
72
|
+
// An issue reads "CON-33 · Conversation standard": the ref first, so a hit by ref shows it (Miky, 2026-10-05).
|
|
73
|
+
caption: [ref, parent?.slots.title?.value].filter(Boolean).join(' · '),
|
|
67
74
|
tier,
|
|
75
|
+
...(ref ? { search: ref } : {}),
|
|
68
76
|
...(isClosedStatus(o.slots.status) ? { closed: true } : {}),
|
|
69
77
|
...(o.archived || parent?.archived ? { archived: true } : {}),
|
|
70
78
|
...(at?.has(o.address) ? { at: at.get(o.address) } : {}),
|
|
@@ -73,14 +81,20 @@ export async function fileCandidates(objects, tier, query, { cache, at } = {}) {
|
|
|
73
81
|
}
|
|
74
82
|
const tagOf = (event, name) => event.tags.find((t) => t[0] === name)?.[1];
|
|
75
83
|
/**
|
|
76
|
-
* The
|
|
84
|
+
* The file a `kind:1851` hit names, when it is one the relay indexes for `[`
|
|
85
|
+
* (SPEC §5.2): a title change on any file, a ref change only on an issue.
|
|
86
|
+
*/
|
|
87
|
+
const searchedChange = (field, address) => field === 'title' || (field === 'ref' && address?.startsWith(`${KIND_ISSUE}:`)) ? address : undefined;
|
|
88
|
+
/**
|
|
89
|
+
* The files whose **current** title — or, for an issue, current ref (CON-33)
|
|
90
|
+
* — holds `text`, as the search tier.
|
|
77
91
|
*
|
|
78
|
-
* The relay indexes a root's `title` and a
|
|
79
|
-
*
|
|
80
|
-
* it was created with, and a rename found by an old word may since have
|
|
81
|
-
* renamed again. So a hit is only an address: each is read back as its
|
|
82
|
-
* and changes, folded through its app's manifest, and kept only when what
|
|
83
|
-
* is called now matches what was typed.
|
|
92
|
+
* The relay indexes a root's `title` and `ref` and a change's `value` for those
|
|
93
|
+
* fields (SPEC §5.2); none is the current one on its own — a root keeps the
|
|
94
|
+
* name it was created with, and a rename found by an old word may since have
|
|
95
|
+
* been renamed again. So a hit is only an address: each is read back as its
|
|
96
|
+
* root and changes, folded through its app's manifest, and kept only when what
|
|
97
|
+
* it is called now matches what was typed.
|
|
84
98
|
*
|
|
85
99
|
* Roots and renames are asked for separately, so a burst of renames cannot
|
|
86
100
|
* crowd every root out of the answer, and with buzz's prefix mode, so the word
|
|
@@ -100,9 +114,7 @@ export async function searchFileReferences(text, query, { limit = 32, ...options
|
|
|
100
114
|
const at = new Map();
|
|
101
115
|
for (const hit of hits) {
|
|
102
116
|
const address = hit.kind === KIND_CHANGE
|
|
103
|
-
? tagOf(hit, 'field')
|
|
104
|
-
? tagOf(hit, 'a')
|
|
105
|
-
: undefined
|
|
117
|
+
? searchedChange(tagOf(hit, 'field'), tagOf(hit, 'a'))
|
|
106
118
|
: typeOf(hit.kind) && `${hit.kind}:${hit.pubkey}:${tagOf(hit, 'd') ?? ''}`;
|
|
107
119
|
if (!address || !typeOf(Number(address.split(':')[0])))
|
|
108
120
|
continue;
|
|
@@ -111,7 +123,7 @@ export async function searchFileReferences(text, query, { limit = 32, ...options
|
|
|
111
123
|
if (at.size === 0)
|
|
112
124
|
return [];
|
|
113
125
|
const objects = await resolveForeignRoots([...at.keys()], query, options.cache);
|
|
114
|
-
const matching = objects.filter((o) => o.slots.title && referenceMatch(o.slots.title.value, wanted) > 0);
|
|
126
|
+
const matching = objects.filter((o) => (o.slots.title && referenceMatch(o.slots.title.value, wanted) > 0) || refMatch(refOf(o), wanted) > 0);
|
|
115
127
|
return fileCandidates(matching, FILE_TIER.search, query, { ...options, at });
|
|
116
128
|
}
|
|
117
129
|
//# sourceMappingURL=references.js.map
|
package/dist/references.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EACL,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,
|
|
1
|
+
{"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;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I,GAAG,CAAC,MAAM,IAAI,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,CAAA;QAC9E,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAAE,SAAQ;QAChE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAA;IACjE,CAAC;IACD,IAAI,EAAE,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAC5B,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IAC/E,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IAC5I,OAAO,cAAc,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,CAAC,CAAA;AAC9E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@estiva-app/interop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "Render and act on another app's objects from its published NIP-89 manifest. The owner defines the projection; the consumer decides how it looks.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"prepublishOnly": "npm run build"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@estiva-app/conversation": ">=0.
|
|
50
|
+
"@estiva-app/conversation": ">=0.6.1",
|
|
51
51
|
"@estiva-app/protocol": ">=0.24.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@estiva-app/conversation": ">=0.
|
|
54
|
+
"@estiva-app/conversation": ">=0.6.1",
|
|
55
55
|
"@estiva-app/protocol": ">=0.24.0",
|
|
56
56
|
"typescript": "~5.9.3"
|
|
57
57
|
}
|
package/src/folders.ts
CHANGED
|
@@ -62,6 +62,12 @@ export interface FolderRef {
|
|
|
62
62
|
* `["private"]`. Only a move *into* the Folder reads it.
|
|
63
63
|
*/
|
|
64
64
|
private?: boolean
|
|
65
|
+
/**
|
|
66
|
+
* `FolderSummary.addresses`: what its state lists. Only
|
|
67
|
+
* {@link planMoveFromFolders} reads it, to know a source lists the moved
|
|
68
|
+
* file even when the file's row did not resolve.
|
|
69
|
+
*/
|
|
70
|
+
addresses?: readonly string[]
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
/**
|
|
@@ -336,3 +342,91 @@ export function planMoveFile(
|
|
|
336
342
|
moved,
|
|
337
343
|
}
|
|
338
344
|
}
|
|
345
|
+
|
|
346
|
+
export type MoveFromFoldersPlan =
|
|
347
|
+
| {
|
|
348
|
+
ok: true
|
|
349
|
+
/**
|
|
350
|
+
* The one `kind:1852 add` in the target, naming everything moved. Publish
|
|
351
|
+
* it first: refused, nothing has changed. Absent when there is nothing to send.
|
|
352
|
+
*/
|
|
353
|
+
add?: UnsignedEvent
|
|
354
|
+
/**
|
|
355
|
+
* A `remove` for each source that lists part of the set, naming what that
|
|
356
|
+
* source lists. Publish them once the add has landed; a refused one leaves
|
|
357
|
+
* its Folder listing the set as well, which moving again fixes.
|
|
358
|
+
*/
|
|
359
|
+
removes: { folder: string; event: UnsignedEvent }[]
|
|
360
|
+
/** Every address the add names. */
|
|
361
|
+
moved: string[]
|
|
362
|
+
}
|
|
363
|
+
| { ok: false; reason: MoveRefusal }
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Move a file out of every Folder that lists it, with everything listed
|
|
367
|
+
* beneath it in each: one `kind:1852 add` in the target naming the whole set,
|
|
368
|
+
* then a `remove` in each source — SPEC §3.3.
|
|
369
|
+
*
|
|
370
|
+
* {@link planMoveFile} for each source, and what every consumer did around it
|
|
371
|
+
* (Ship's "Move to Folder…", Peek's Move, the agent's `move-project`), so it is
|
|
372
|
+
* done once:
|
|
373
|
+
*
|
|
374
|
+
* - **One add, not one per source.** A file two Folders list can have a
|
|
375
|
+
* different set beneath it in each. One add naming the union lands whole or
|
|
376
|
+
* not at all, so a refusal never leaves part of the set in the target.
|
|
377
|
+
* - **The file is in a source whose state names it** (`from[i].addresses`),
|
|
378
|
+
* even when its row is missing from that source's listing. A row that did
|
|
379
|
+
* not resolve is still what is being moved.
|
|
380
|
+
* - **Placed, when no source lists any of it.** The file is listed nowhere, or
|
|
381
|
+
* only by containment in a Folder with state, so it is added to the target
|
|
382
|
+
* alone, as {@link planPlaceFile} does. Into a private Folder that is
|
|
383
|
+
* refused unless the file's `h` is that Folder. A project's root carries no
|
|
384
|
+
* `h`, so a project is always refused. A file no Folder should list itself (a
|
|
385
|
+
* Ship issue is listed by its project) is then added too, so only call this
|
|
386
|
+
* for one when something is listed beneath it.
|
|
387
|
+
*
|
|
388
|
+
* `from` is every Folder that lists the file now. The target is ignored if it
|
|
389
|
+
* is one of them, and a file that is already there and nowhere else plans
|
|
390
|
+
* nothing. `listings` holds each source's files (`FolderContents.files`). Read
|
|
391
|
+
* them with `includeArchived`, or an archived file beneath this one stays
|
|
392
|
+
* behind. A source with no entry moves the file alone.
|
|
393
|
+
*
|
|
394
|
+
* Refusals are {@link planMoveFile}'s, and nothing is planned if any source is
|
|
395
|
+
* refused.
|
|
396
|
+
*/
|
|
397
|
+
export function planMoveFromFolders(
|
|
398
|
+
pubkey: string,
|
|
399
|
+
createdAtMs: number,
|
|
400
|
+
args: { file: MovableFile; from: readonly FolderRef[]; to: FolderRef; listings: ReadonlyMap<string, readonly MovableFile[] | null> },
|
|
401
|
+
): MoveFromFoldersPlan {
|
|
402
|
+
const { file, to } = args
|
|
403
|
+
const sources = args.from.filter((folder) => folder.id !== to.id)
|
|
404
|
+
if (sources.length === 0 && args.from.length > 0) return { ok: true, removes: [], moved: [] }
|
|
405
|
+
const removes: { folder: string; event: UnsignedEvent }[] = []
|
|
406
|
+
const moved = new Set<string>()
|
|
407
|
+
for (const from of sources) {
|
|
408
|
+
const listing = args.listings.get(from.id) ?? null
|
|
409
|
+
const unresolved =
|
|
410
|
+
!!listing && !!file.address && !!from.addresses?.includes(file.address) && !listing.some((candidate) => candidate.address === file.address)
|
|
411
|
+
const plan = planMoveFile(pubkey, createdAtMs, {
|
|
412
|
+
file,
|
|
413
|
+
from,
|
|
414
|
+
to,
|
|
415
|
+
// By its address, so the walk finds what the listing draws beneath it.
|
|
416
|
+
listing: unresolved ? [{ ...file, ref: file.address! }, ...listing] : listing,
|
|
417
|
+
})
|
|
418
|
+
if (!plan.ok) return plan
|
|
419
|
+
for (const address of plan.moved) moved.add(address)
|
|
420
|
+
const remove = plan.events[1]
|
|
421
|
+
if (remove) removes.push({ folder: from.id, event: remove })
|
|
422
|
+
}
|
|
423
|
+
if (!to.hasState) return { ok: false, reason: 'target-has-no-state' }
|
|
424
|
+
if (moved.size === 0) {
|
|
425
|
+
if (to.private && file.folder !== to.id) return { ok: false, reason: 'target-is-private' }
|
|
426
|
+
if (!file.address) return { ok: true, removes: [], moved: [] }
|
|
427
|
+
const [add] = planPlaceFile(pubkey, createdAtMs, { folder: to.id, address: file.address, hasState: true })
|
|
428
|
+
return { ok: true, add, removes: [], moved: [file.address] }
|
|
429
|
+
}
|
|
430
|
+
const addresses = [...moved]
|
|
431
|
+
return { ok: true, add: buildFolderCommand(pubkey, createdAtMs, { folder: to.id, op: 'add', addresses }), removes, moved: addresses }
|
|
432
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -130,11 +130,13 @@ export {
|
|
|
130
130
|
planPlaceFile,
|
|
131
131
|
planUnlistFile,
|
|
132
132
|
planMoveFile,
|
|
133
|
+
planMoveFromFolders,
|
|
133
134
|
planArchiveFolder,
|
|
134
135
|
listedBeneath,
|
|
135
136
|
type FolderRef,
|
|
136
137
|
type MovableFile,
|
|
137
138
|
type MovePlan,
|
|
139
|
+
type MoveFromFoldersPlan,
|
|
138
140
|
type MoveRefusal,
|
|
139
141
|
} from './folders.js'
|
|
140
142
|
|
package/src/projection.ts
CHANGED
|
@@ -5940,7 +5940,9 @@ export async function resolveFolderContents(
|
|
|
5940
5940
|
/**
|
|
5941
5941
|
* Return archived files — and files hidden with an archived parent — each
|
|
5942
5942
|
* carrying its {@link Archive}, instead of leaving them out. For a view
|
|
5943
|
-
* that lists what was archived
|
|
5943
|
+
* that lists what was archived, and for the listings a move plans from
|
|
5944
|
+
* (`planMoveFromFolders`): what is archived beneath a file moves with it.
|
|
5945
|
+
* Every other list wants the default.
|
|
5944
5946
|
*/
|
|
5945
5947
|
includeArchived?: boolean
|
|
5946
5948
|
} = {},
|
package/src/references.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
fileReference,
|
|
18
18
|
KIND_CHANGE,
|
|
19
19
|
referenceMatch,
|
|
20
|
+
refMatch,
|
|
20
21
|
type ReferenceCandidate,
|
|
21
22
|
type ReferenceType,
|
|
22
23
|
} from '@estiva-app/conversation'
|
|
@@ -51,6 +52,13 @@ const offerable = (object: ForeignObject | null | undefined): object is Addresse
|
|
|
51
52
|
typeOf(object.kind) !== undefined &&
|
|
52
53
|
!!object.slots.title?.value.trim()
|
|
53
54
|
|
|
55
|
+
/**
|
|
56
|
+
* An issue's current ref (`CON-33`, SPEC §6.1) — the manifest slot that folds
|
|
57
|
+
* the `ref` field — so typing it finds the issue. Only an issue has one.
|
|
58
|
+
*/
|
|
59
|
+
const refOf = (object: ForeignObject): string | undefined =>
|
|
60
|
+
object.kind === KIND_ISSUE ? object.meta.find((slot) => slot.field === 'ref')?.value.trim() || undefined : undefined
|
|
61
|
+
|
|
54
62
|
export interface FileCandidatesOptions {
|
|
55
63
|
cache?: ProjectionCache
|
|
56
64
|
/** When each address was last written or read, in seconds — newer first within a tier. */
|
|
@@ -86,14 +94,17 @@ export async function fileCandidates(
|
|
|
86
94
|
}
|
|
87
95
|
return files.map((o) => {
|
|
88
96
|
const parent = o.kind === KIND_ISSUE && o.parentRef ? parents.get(o.parentRef) : undefined
|
|
97
|
+
const ref = refOf(o)
|
|
89
98
|
return {
|
|
90
99
|
id: o.address,
|
|
91
100
|
uri: fileReference(o.address),
|
|
92
101
|
type: typeOf(o.kind)!,
|
|
93
102
|
kind: o.kind,
|
|
94
103
|
title: o.slots.title!.value,
|
|
95
|
-
|
|
104
|
+
// An issue reads "CON-33 · Conversation standard": the ref first, so a hit by ref shows it (Miky, 2026-10-05).
|
|
105
|
+
caption: [ref, parent?.slots.title?.value].filter(Boolean).join(' · '),
|
|
96
106
|
tier,
|
|
107
|
+
...(ref ? { search: ref } : {}),
|
|
97
108
|
...(isClosedStatus(o.slots.status) ? { closed: true } : {}),
|
|
98
109
|
...(o.archived || parent?.archived ? { archived: true } : {}),
|
|
99
110
|
...(at?.has(o.address) ? { at: at.get(o.address) } : {}),
|
|
@@ -109,14 +120,22 @@ export interface SearchFileReferencesOptions extends Omit<FileCandidatesOptions,
|
|
|
109
120
|
const tagOf = (event: { tags: string[][] }, name: string) => event.tags.find((t) => t[0] === name)?.[1]
|
|
110
121
|
|
|
111
122
|
/**
|
|
112
|
-
* The
|
|
123
|
+
* The file a `kind:1851` hit names, when it is one the relay indexes for `[`
|
|
124
|
+
* (SPEC §5.2): a title change on any file, a ref change only on an issue.
|
|
125
|
+
*/
|
|
126
|
+
const searchedChange = (field: string | undefined, address: string | undefined) =>
|
|
127
|
+
field === 'title' || (field === 'ref' && address?.startsWith(`${KIND_ISSUE}:`)) ? address : undefined
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The files whose **current** title — or, for an issue, current ref (CON-33)
|
|
131
|
+
* — holds `text`, as the search tier.
|
|
113
132
|
*
|
|
114
|
-
* The relay indexes a root's `title` and a
|
|
115
|
-
*
|
|
116
|
-
* it was created with, and a rename found by an old word may since have
|
|
117
|
-
* renamed again. So a hit is only an address: each is read back as its
|
|
118
|
-
* and changes, folded through its app's manifest, and kept only when what
|
|
119
|
-
* is called now matches what was typed.
|
|
133
|
+
* The relay indexes a root's `title` and `ref` and a change's `value` for those
|
|
134
|
+
* fields (SPEC §5.2); none is the current one on its own — a root keeps the
|
|
135
|
+
* name it was created with, and a rename found by an old word may since have
|
|
136
|
+
* been renamed again. So a hit is only an address: each is read back as its
|
|
137
|
+
* root and changes, folded through its app's manifest, and kept only when what
|
|
138
|
+
* it is called now matches what was typed.
|
|
120
139
|
*
|
|
121
140
|
* Roots and renames are asked for separately, so a burst of renames cannot
|
|
122
141
|
* crowd every root out of the answer, and with buzz's prefix mode, so the word
|
|
@@ -140,15 +159,13 @@ export async function searchFileReferences(
|
|
|
140
159
|
for (const hit of hits) {
|
|
141
160
|
const address =
|
|
142
161
|
hit.kind === KIND_CHANGE
|
|
143
|
-
? tagOf(hit, 'field')
|
|
144
|
-
? tagOf(hit, 'a')
|
|
145
|
-
: undefined
|
|
162
|
+
? searchedChange(tagOf(hit, 'field'), tagOf(hit, 'a'))
|
|
146
163
|
: typeOf(hit.kind) && `${hit.kind}:${hit.pubkey}:${tagOf(hit, 'd') ?? ''}`
|
|
147
164
|
if (!address || !typeOf(Number(address.split(':')[0]))) continue
|
|
148
165
|
at.set(address, Math.max(at.get(address) ?? 0, hit.created_at))
|
|
149
166
|
}
|
|
150
167
|
if (at.size === 0) return []
|
|
151
168
|
const objects = await resolveForeignRoots([...at.keys()], query, options.cache)
|
|
152
|
-
const matching = objects.filter((o) => o.slots.title && referenceMatch(o.slots.title.value, wanted) > 0)
|
|
169
|
+
const matching = objects.filter((o) => (o.slots.title && referenceMatch(o.slots.title.value, wanted) > 0) || refMatch(refOf(o), wanted) > 0)
|
|
153
170
|
return fileCandidates(matching, FILE_TIER.search, query, { ...options, at })
|
|
154
171
|
}
|