@@ -200,21 +200,29 @@ async function boot(
200200 * template is closed, so every administrator write in this file is the one
201201 * that stays open: into the base's pair, `com.acme.mail.custom`, declaring
202202 * what it overrides. This wrapper names the pair on each save, publish and
203- * delete that names no package, and adds the declaration to a saved body —
203+ * delete that names no package, and adds the declaration to a saved body of a
204+ * member the package ships (one it does not ship is the pair's own item) —
204205 * the member semantics pinned below are the pair's, row for row, as they were
205206 * the package-less row's. A write that names a package (the drafts into
206207 * `PKG` below) is passed through untouched.
207208 */
208209const PAIR = 'com.acme.mail.custom' ;
209210const DECLARATION = { package : PKG , basedOn : '1.0.0' } ;
211+ /** Whether the package ships this body's `(name, locale)` member. */
212+ const shipsMember = ( item : any ) => ( ( mailManifest ( ) . emailTemplates as any [ ] ) ?? [ ] )
213+ . some ( ( shipped ) => shipped . name === ( item ?. name ?? NAME ) && shipped . locale === item ?. locale ) ;
210214function inPair ( protocol : ObjectStackProtocolImplementation ) : ObjectStackProtocolImplementation {
211215 const named = ( request : any ) => request ?. packageId !== undefined ;
212216 return new Proxy ( protocol , {
213217 get ( target , key , receiver ) {
214218 const value = Reflect . get ( target , key , receiver ) ;
215219 if ( key === 'saveMetaItem' ) {
216220 return ( request : any ) => ( named ( request ) ? value . call ( target , request ) : value . call ( target , {
217- ...request , packageId : PAIR , item : { ...request . item , overrides : DECLARATION } ,
221+ ...request ,
222+ packageId : PAIR ,
223+ // [#28746] A member the package does not ship is the pair's
224+ // own item, not an override: it declares none.
225+ item : request . type !== 'email_template' || shipsMember ( request . item ) ? { ...request . item , overrides : DECLARATION } : request . item ,
218226 } ) ) ;
219227 }
220228 if ( key === 'deleteMetaItem' || key === 'publishMetaItem' ) {
0 commit comments