@estiva-app/conversation 0.18.0 → 0.19.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 CHANGED
@@ -6,6 +6,19 @@ none. A change to how an event is read is a MINOR in `0.x` even when no
6
6
  signature moved, because two apps on different versions would then disagree
7
7
  about a conversation.
8
8
 
9
+ ## 0.19.0 — 2026-10-27
10
+
11
+ **An edit with no files takes every file off** (SPEC §6.8 as amended in
12
+ estiva-docs#334; record *an-edit-is-the-whole-new-message*; 8de3e4b4). A
13
+ message's files are the `imeta` of its latest edit, and an edit listing none
14
+ leaves it with none; before, an edit with no `imeta` meant "unchanged" and the
15
+ latest edit carrying any won. `foldAttachments` drops a message whose latest
16
+ edit lists nothing, and `EditFold.attachments` is now always present — the
17
+ latest edit's set, empty for none. Cards (`embed`) keep their fold. Every
18
+ writer has listed a message's files on every edit since 27 Oct (Peek, Ship,
19
+ Leaf, estiva-agent), and the messages whose files this would have hidden were
20
+ re-saved first, so nothing on production changes but the ability to empty.
21
+
9
22
  ## 0.18.0 — 2026-10-20
10
23
 
11
24
  **An edit opens a nested list nested** (SPEC §13.2; PEE-57; Miky,
package/dist/edits.d.ts CHANGED
@@ -8,9 +8,9 @@
8
8
  * edits up by id.
9
9
  *
10
10
  * An edit changes the body, the attachments and the cards, and nothing else.
11
- * Attachments fold separately: the set is the `imeta` of the latest edit
12
- * carrying at least one, and a set replaces rather than appends. Cards
13
- * (`embed`, §13.6.2) fold the same way ({@link foldEmbeds}). The "edited" mark is about the
11
+ * An edit is the whole new message: the files are the `imeta` of the latest
12
+ * edit, and an edit with none takes every file off. Cards (`embed`, §13.6.2)
13
+ * keep the older fold, the latest edit carrying any ({@link foldEmbeds}). The "edited" mark is about the
14
14
  * **body**: an edit byte-identical to the body it replaces, judged against the
15
15
  * body as it then stood, does not mark the message edited.
16
16
  *
@@ -46,11 +46,12 @@ export interface EditFold {
46
46
  /** Who wrote the edit that last changed the body. Absent unless `edited`. */
47
47
  editedBy?: string;
48
48
  /**
49
- * The `imeta` set of the latest edit carrying at least one. Absent when no
50
- * edit carries one: the message's own attachments stand, because an edit
51
- * with no `imeta` means "unchanged", never "none".
49
+ * The `imeta` set of the latest edit, which replaces the message's own;
50
+ * empty when that edit lists none, and then the message has no files.
51
+ *
52
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/an-edit-is-the-whole-new-message.md
52
53
  */
53
- attachments?: Imeta[];
54
+ attachments: Imeta[];
54
55
  }
55
56
  /**
56
57
  * Every `kind:40003` in `events`, grouped by {@link editTargetOf}, oldest first
@@ -71,13 +72,16 @@ export declare function foldEdits(events: readonly SignedEvent[], targets?: read
71
72
  }[]): Record<string, EditFold>;
72
73
  /**
73
74
  * Every message's current attachment set: its own `imeta`, replaced by the
74
- * latest edit carrying any (§6.8, C15). Messages with none are absent.
75
+ * latest edit's, an edit with none taking every file off (§6.8, C15).
76
+ * Messages with none are absent.
77
+ *
78
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/an-edit-is-the-whole-new-message.md
75
79
  */
76
80
  export declare function foldAttachments(events: readonly SignedEvent[]): Record<string, Imeta[]>;
77
81
  /**
78
82
  * Every message's current card set: its own `embed` tags, replaced by the
79
- * latest edit carrying any (§6.8, §13.6.2, C20) — the same fold as
80
- * {@link foldAttachments}. An edit with none leaves the set; `none` is how an
83
+ * latest edit carrying any (§6.8, §13.6.2, C20) — the fold attachments
84
+ * had before an edit became the whole new message. An edit with none leaves the set; `none` is how an
81
85
  * edit removes a card. Which of these the body still names is
82
86
  * `cardsIn`'s question, asked of the folded body. Messages with none are absent.
83
87
  *
@@ -1 +1 @@
1
- {"version":3,"file":"edits.d.ts","sourceRoot":"","sources":["../src/edits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAqB,KAAK,KAAK,EAAE,KAAK,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAI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;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAGjF;AAED,mCAAmC;AACnC,MAAM,WAAW,QAAQ;IACvB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAA;IACf,kGAAkG;IAClG,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,WAAW,EAAE,KAAK,EAAE,CAAA;CACrB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAcxF;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,OAAO,GAAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAO,GACpD,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAsB1B;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAavF;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAgBlF"}
package/dist/edits.js CHANGED
@@ -8,9 +8,9 @@
8
8
  * edits up by id.
9
9
  *
10
10
  * An edit changes the body, the attachments and the cards, and nothing else.
11
- * Attachments fold separately: the set is the `imeta` of the latest edit
12
- * carrying at least one, and a set replaces rather than appends. Cards
13
- * (`embed`, §13.6.2) fold the same way ({@link foldEmbeds}). The "edited" mark is about the
11
+ * An edit is the whole new message: the files are the `imeta` of the latest
12
+ * edit, and an edit with none takes every file off. Cards (`embed`, §13.6.2)
13
+ * keep the older fold, the latest edit carrying any ({@link foldEmbeds}). The "edited" mark is about the
14
14
  * **body**: an edit byte-identical to the body it replaces, judged against the
15
15
  * body as it then stood, does not mark the message edited.
16
16
  *
@@ -79,27 +79,27 @@ export function foldEdits(events, targets = []) {
79
79
  for (const [target, list] of editsByTarget(events)) {
80
80
  let body = bodies.get(target);
81
81
  let changed;
82
- let attachments;
83
82
  for (const edit of list) {
84
83
  if (body === undefined || edit.content !== body)
85
84
  changed = edit;
86
85
  body = edit.content;
87
- const files = imetaOf(edit);
88
- if (files.length > 0)
89
- attachments = files;
90
86
  }
87
+ const latest = list[list.length - 1];
91
88
  out[target] = {
92
- body: list[list.length - 1].content,
89
+ body: latest.content,
93
90
  edited: changed !== undefined,
94
91
  ...(changed ? { editedAt: orderingMs(changed), editedBy: changed.pubkey } : {}),
95
- ...(attachments ? { attachments } : {}),
92
+ attachments: imetaOf(latest),
96
93
  };
97
94
  }
98
95
  return out;
99
96
  }
100
97
  /**
101
98
  * Every message's current attachment set: its own `imeta`, replaced by the
102
- * latest edit carrying any (§6.8, C15). Messages with none are absent.
99
+ * latest edit's, an edit with none taking every file off (§6.8, C15).
100
+ * Messages with none are absent.
101
+ *
102
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/an-edit-is-the-whole-new-message.md
103
103
  */
104
104
  export function foldAttachments(events) {
105
105
  const out = {};
@@ -111,20 +111,18 @@ export function foldAttachments(events) {
111
111
  out[event.id.toLowerCase()] = files;
112
112
  }
113
113
  for (const [target, list] of editsByTarget(events)) {
114
- for (let i = list.length - 1; i >= 0; i--) {
115
- const files = imetaOf(list[i]);
116
- if (files.length === 0)
117
- continue;
114
+ const files = imetaOf(list[list.length - 1]);
115
+ if (files.length > 0)
118
116
  out[target] = files;
119
- break;
120
- }
117
+ else
118
+ delete out[target];
121
119
  }
122
120
  return out;
123
121
  }
124
122
  /**
125
123
  * Every message's current card set: its own `embed` tags, replaced by the
126
- * latest edit carrying any (§6.8, §13.6.2, C20) — the same fold as
127
- * {@link foldAttachments}. An edit with none leaves the set; `none` is how an
124
+ * latest edit carrying any (§6.8, §13.6.2, C20) — the fold attachments
125
+ * had before an edit became the whole new message. An edit with none leaves the set; `none` is how an
128
126
  * edit removes a card. Which of these the body still names is
129
127
  * `cardsIn`'s question, asked of the folded body. Messages with none are absent.
130
128
  *
package/dist/edits.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"edits.js","sourceRoot":"","sources":["../src/edits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAA4C,MAAM,sBAAsB,CAAA;AAClG,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEhD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,KAAgC;IAC3D,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACnE,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;AAC/B,CAAC;AAwBD;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAA8B;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,EAAyB,CAAA;IAC5C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,C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AM,EAAE,CAAC;QAC3B,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,SAAQ;QAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;QAC9B,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,GAAG,MAAM,CAAA;IAC7D,CAAC;IACD,KAAK,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;YAChC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;gBAAE,SAAQ;YACjC,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;YACpB,MAAK;QACP,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  * apps: it imports no app's data layer, opens no socket, and takes every
13
13
  * environment touch — the relay read, the clock, storage — as a parameter.
14
14
  */
15
- export declare const CONVERSATION_VERSION = "0.18.0";
15
+ export declare const CONVERSATION_VERSION = "0.19.0";
16
16
  export { KIND_MESSAGE, KIND_COMMENT, KIND_EDIT, KIND_REACTION, KIND_DELETION, KIND_ASSERTION, isConversationKind, isEventId, } from './kinds.js';
17
17
  export { trustedTs, orderingMs, byOrder } from './order.js';
18
18
  export { namedInBody, isReply, anchorsOf, isCommentOn, referencesAddress, strengthOn, threadStrength, referenceTagsFor, mentionTagsFor, peopleNamedInBody, MAX_MENTIONED_PEOPLE, type Strength, } from './strength.js';
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@
12
12
  * apps: it imports no app's data layer, opens no socket, and takes every
13
13
  * environment touch — the relay read, the clock, storage — as a parameter.
14
14
  */
15
- export const CONVERSATION_VERSION = '0.18.0';
15
+ export const CONVERSATION_VERSION = '0.19.0';
16
16
  export { KIND_MESSAGE, KIND_COMMENT, KIND_EDIT, KIND_REACTION, KIND_DELETION, KIND_ASSERTION, isConversationKind, isEventId, } from './kinds.js';
17
17
  export { trustedTs, orderingMs, byOrder } from './order.js';
18
18
  export { namedInBody, isReply, anchorsOf, isCommentOn, referencesAddress, strengthOn, threadStrength, referenceTagsFor, mentionTagsFor, peopleNamedInBody, MAX_MENTIONED_PEOPLE, } from './strength.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/conversation",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "The conversation rules of the Estiva SPEC (§6.2–§6.8, §11): comment and mention strengths, threading, the edit, reaction and attachment folds, NIP-22 comment and reply builders, drafts, NIP-RS read state, membership and unread. A convenience an app adopts, never a requirement.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/edits.ts CHANGED
@@ -8,9 +8,9 @@
8
8
  * edits up by id.
9
9
  *
10
10
  * An edit changes the body, the attachments and the cards, and nothing else.
11
- * Attachments fold separately: the set is the `imeta` of the latest edit
12
- * carrying at least one, and a set replaces rather than appends. Cards
13
- * (`embed`, §13.6.2) fold the same way ({@link foldEmbeds}). The "edited" mark is about the
11
+ * An edit is the whole new message: the files are the `imeta` of the latest
12
+ * edit, and an edit with none takes every file off. Cards (`embed`, §13.6.2)
13
+ * keep the older fold, the latest edit carrying any ({@link foldEmbeds}). The "edited" mark is about the
14
14
  * **body**: an edit byte-identical to the body it replaces, judged against the
15
15
  * body as it then stood, does not mark the message edited.
16
16
  *
@@ -53,11 +53,12 @@ export interface EditFold {
53
53
  /** Who wrote the edit that last changed the body. Absent unless `edited`. */
54
54
  editedBy?: string
55
55
  /**
56
- * The `imeta` set of the latest edit carrying at least one. Absent when no
57
- * edit carries one: the message's own attachments stand, because an edit
58
- * with no `imeta` means "unchanged", never "none".
56
+ * The `imeta` set of the latest edit, which replaces the message's own;
57
+ * empty when that edit lists none, and then the message has no files.
58
+ *
59
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/an-edit-is-the-whole-new-message.md
59
60
  */
60
- attachments?: Imeta[]
61
+ attachments: Imeta[]
61
62
  }
62
63
 
63
64
  /**
@@ -100,18 +101,16 @@ export function foldEdits(
100
101
  for (const [target, list] of editsByTarget(events)) {
101
102
  let body = bodies.get(target)
102
103
  let changed: SignedEvent | undefined
103
- let attachments: Imeta[] | undefined
104
104
  for (const edit of list) {
105
105
  if (body === undefined || edit.content !== body) changed = edit
106
106
  body = edit.content
107
- const files = imetaOf(edit)
108
- if (files.length > 0) attachments = files
109
107
  }
108
+ const latest = list[list.length - 1]
110
109
  out[target] = {
111
- body: list[list.length - 1].content,
110
+ body: latest.content,
112
111
  edited: changed !== undefined,
113
112
  ...(changed ? { editedAt: orderingMs(changed), editedBy: changed.pubkey } : {}),
114
- ...(attachments ? { attachments } : {}),
113
+ attachments: imetaOf(latest),
115
114
  }
116
115
  }
117
116
  return out
@@ -119,7 +118,10 @@ export function foldEdits(
119
118
 
120
119
  /**
121
120
  * Every message's current attachment set: its own `imeta`, replaced by the
122
- * latest edit carrying any (§6.8, C15). Messages with none are absent.
121
+ * latest edit's, an edit with none taking every file off (§6.8, C15).
122
+ * Messages with none are absent.
123
+ *
124
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/an-edit-is-the-whole-new-message.md
123
125
  */
124
126
  export function foldAttachments(events: readonly SignedEvent[]): Record<string, Imeta[]> {
125
127
  const out: Record<string, Imeta[]> = {}
@@ -129,20 +131,17 @@ export function foldAttachments(events: readonly SignedEvent[]): Record<string,
129
131
  if (files.length > 0) out[event.id.toLowerCase()] = files
130
132
  }
131
133
  for (const [target, list] of editsByTarget(events)) {
132
- for (let i = list.length - 1; i >= 0; i--) {
133
- const files = imetaOf(list[i])
134
- if (files.length === 0) continue
135
- out[target] = files
136
- break
137
- }
134
+ const files = imetaOf(list[list.length - 1])
135
+ if (files.length > 0) out[target] = files
136
+ else delete out[target]
138
137
  }
139
138
  return out
140
139
  }
141
140
 
142
141
  /**
143
142
  * Every message's current card set: its own `embed` tags, replaced by the
144
- * latest edit carrying any (§6.8, §13.6.2, C20) — the same fold as
145
- * {@link foldAttachments}. An edit with none leaves the set; `none` is how an
143
+ * latest edit carrying any (§6.8, §13.6.2, C20) — the fold attachments
144
+ * had before an edit became the whole new message. An edit with none leaves the set; `none` is how an
146
145
  * edit removes a card. Which of these the body still names is
147
146
  * `cardsIn`'s question, asked of the folded body. Messages with none are absent.
148
147
  *
package/src/index.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  * apps: it imports no app's data layer, opens no socket, and takes every
13
13
  * environment touch — the relay read, the clock, storage — as a parameter.
14
14
  */
15
- export const CONVERSATION_VERSION = '0.18.0'
15
+ export const CONVERSATION_VERSION = '0.19.0'
16
16
 
17
17
  export {
18
18
  KIND_MESSAGE,