@@ -2335,13 +2335,21 @@ function notifyWithheldMentions(
23352335 * present only when at least one entry parsed: an answer without the key —
23362336 * including one from a runtime that predates it — leaves the event exactly as
23372337 * it was.
2338+ *
2339+ * `notice` is the same answer's `notice` (objectstack-ai/objectstack#28000):
2340+ * the one message a hook on the write set for the person who made it, info
2341+ * severity, the server's text as written. It rides this event like `warnings`
2342+ * does, so the record save surface that claims its write's answer feedback
2343+ * shows it on that write's one toast (objectstack-ai/objectstack#28252). It
2344+ * is present only when the answer carried a non-empty string.
23382345 */
23392346export interface WriteWarningEvent {
23402347 operation : 'create' | 'update' ;
23412348 resource : string ;
23422349 id ?: string | number ;
23432350 droppedFields : DroppedFieldsNotice [ ] ;
23442351 warnings ?: ValidateDataIssue [ ] ;
2352+ notice ?: string ;
23452353}
23462354
23472355/** Event listener type for write-warning (dropped-fields) events. */
@@ -2810,6 +2818,17 @@ function readWriteWarnings(result: unknown): ValidateDataIssue[] {
28102818 return out ;
28112819}
28122820
2821+ /**
2822+ * Read a single-record write answer's `notice` — the message a hook set for
2823+ * the requester (objectstack-ai/objectstack#28000). The spec declares it a
2824+ * non-empty string; anything else, the key's absence included, answers
2825+ * `undefined`, so an answer from a runtime that predates it adds nothing.
2826+ */
2827+ function readWriteNotice ( result : unknown ) : string | undefined {
2828+ const raw = ( result as { notice ?: unknown } | null | undefined ) ?. notice ;
2829+ return typeof raw === 'string' && raw !== '' ? raw : undefined ;
2830+ }
2831+
28132832/**
28142833 * Drop the fields whose strip changed nothing — the caller supplied exactly
28152834 * the value the record already holds (objectui#3484).
@@ -4092,9 +4111,11 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
40924111 * `object` healed from `resource` — never asserted into the union, and the
40934112 * entry itself never dropped for them (objectui#4934, `f75810e7c`).
40944113 *
4095- * The same answer's `warnings` (objectui#12107) rides this one event: it is
4096- * emitted when either list is non-empty, so a write whose only news is an
4097- * advisory rule hit still reaches the subscriber, with `droppedFields: []`.
4114+ * The same answer's `warnings` (objectui#12107) and `notice`
4115+ * (objectstack-ai/objectstack#28000) ride this one event: it is emitted when
4116+ * any of the three is present, so a write whose only news is an advisory rule
4117+ * hit or a hook's notice still reaches the subscriber, with
4118+ * `droppedFields: []`.
40984119 */
40994120 private notifyDroppedFields (
41004121 operation : 'create' | 'update' ,
@@ -4114,13 +4135,15 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
41144135 droppedFields = withoutNoOpDrops ( valid , sent , stored ) ;
41154136 }
41164137 const warnings = readWriteWarnings ( result ) ;
4117- if ( droppedFields . length === 0 && warnings . length === 0 ) return ;
4138+ const notice = readWriteNotice ( result ) ;
4139+ if ( droppedFields . length === 0 && warnings . length === 0 && notice === undefined ) return ;
41184140 this . emitWriteWarning ( {
41194141 operation,
41204142 resource,
41214143 ...( id !== undefined ? { id } : { } ) ,
41224144 droppedFields,
41234145 ...( warnings . length > 0 ? { warnings } : { } ) ,
4146+ ...( notice !== undefined ? { notice } : { } ) ,
41244147 } ) ;
41254148 }
41264149
0 commit comments