@@ -59,7 +59,6 @@ import { ITEM_KEY_DISCRIMINATORS, itemDiscriminator } from '@objectstack/metadat
5959 */
6060export interface PackagedBaseRefusalHost {
6161 isSealedManagedItem : ObjectStackProtocolImplementation [ 'isSealedManagedItem' ] ;
62- overlayBaseShippers : ObjectStackProtocolImplementation [ 'overlayBaseShippers' ] ;
6362 isWritablePackage : ObjectStackProtocolImplementation [ 'isWritablePackage' ] ;
6463 packagedBaseRefusal : ObjectStackProtocolImplementation [ 'packagedBaseRefusal' ] ;
6564 packagedArtifactOwner : ObjectStackProtocolImplementation [ 'packagedArtifactOwner' ] ;
@@ -217,66 +216,44 @@ function sealedDeclareOrRenameClause(type: string, basePackageId: unknown, write
217216export type PackagelessWriteOperation = 'save' | 'publish' | 'delete' | 'rollback' ;
218217
219218/**
220- * The body of `ObjectStackProtocolImplementation#packagelessOverlayWriteRefusal`;
221- * the method's docblock there is its contract.
219+ * The refusal `ObjectStackProtocolImplementation#packagelessOverlayWriteRefusal`
220+ * throws; the method's docblock there is its contract.
222221 *
223- * [ADR-0146 D11] The closure of the package-less write onto a packaged item:
224- * a write naming no package (`packageId` absent, `null` or empty) onto an item
225- * of one of the five overlay types that a read-only code package ships
226- * ({@link PackagedBaseRefusalHost.overlayBaseShippers}, the reading
227- * `os migrate packageless-overlays` classifies by), is refused
228- * `403 NOT_OVERRIDABLE` — the code and status the sealed write already
229- * answers, so no door gains a code. Every other type's packaged item is
230- * sealed already ({@link refusePackagedBaseOverride}).
231- *
232- * The sentence names the fix the writer has: the base's paired `.custom`
222+ * [ADR-0146 D11] A write naming no package (`packageId` absent, `null` or
223+ * empty) onto an item of one of the five overlay types that one read-only code
224+ * package ships, whose row `os migrate packageless-overlays` would move into
225+ * the base's pair (`packagelessCloseSubject`, the ceremony's own reading), is
226+ * refused `403 NOT_OVERRIDABLE` — the code and status the sealed write already
227+ * answers, so no door gains a code. Every row the ceremony leaves keeps its
228+ * package-less write, so the sentence's two doors are always open: the pair
233229 * (`?package=<base>.custom`), where the customization is a declared override,
234- * and `os migrate packageless-overlays`, the ceremony that moves a
235- * package-less row stored before the close there. A row that ceremony has not
236- * moved yet is still served (the read path is not this function's); only its
237- * package-less write is refused, by this same sentence.
230+ * and the ceremony, which moves a row stored before the close there. Such a
231+ * row is still served until it is moved (the read path is not this
232+ * function's); only its package-less write is refused.
238233 *
239- * `null` when the write names a package; when no read-only code package ships
240- * the name (environment metadata keeps its package-less write, ADR-0146 D11
241- * "is not touched"); and when no base that ships it has a pair at all
242- * (`customizationPackageId` refuses every one of their ids): the ceremony
243- * lists such a row `no_pair` and cannot move it, and D11 closes only what it
244- * has migrated — closing it would leave that customization no write door.
234+ * The fix first, then the rule and the ceremony: the REST door bounds a
235+ * refusal's text (`CLIENT_MESSAGE_MAX`, 500 characters, `@objectstack/types`),
236+ * and the metadata item page shows that text as sent.
245237 */
246238export function packagelessOverlayWriteRefusal (
247- this : Pick < PackagedBaseRefusalHost , 'overlayBaseShippers' > ,
248- request : { type : string ; name : string ; packageId ?: string | null } ,
239+ request : { type : string ; name : string } ,
240+ closed : { base : string ; pair : string } ,
249241 operation : PackagelessWriteOperation ,
250- ) : Error | null {
251- if ( typeof request . packageId === 'string' && request . packageId . length > 0 ) return null ;
252- const shippers = this . overlayBaseShippers ( request . type , request . name ) ;
253- const pairs = shippers . flatMap ( ( base ) => {
254- const derived = customizationPackageId ( base ) ;
255- return derived . ok ? [ { base, pair : derived . value } ] : [ ] ;
256- } ) ;
257- if ( pairs . length === 0 ) return null ;
242+ ) : Error {
258243 const type = PLURAL_TO_SINGULAR [ request . type ] ?? request . type ;
259244 const item = `'${ type } /${ request . name } '` ;
260- const shipped = `ships in ${ shippers . map ( ( id ) => `'${ id } '` ) . join ( ' and ' ) } ` ;
261- const sole = pairs . length === 1 ? pairs [ 0 ] ! : undefined ;
262- // One base: its pair, by name. Several: the pair of the base the writer
263- // customizes, each named — never guessed (the ceremony lists such a row).
264- const pair = sole ? `'${ sole . pair } ' (?package=${ sole . pair } )` : `the pair of the package it customizes (${ pairs . map ( ( p ) => `'${ p . pair } '` ) . join ( ' or ' ) } )` ;
265- const declared = sole ? `overrides: { package: '${ sole . base } ', basedOn }` : 'overrides: { package: <that base>, basedOn }' ;
266- // The fix first, then the rule and the ceremony: the REST door bounds a
267- // refusal's text (`CLIENT_MESSAGE_MAX`, 500 characters, `@objectstack/types`),
268- // and Setup shows that text as sent.
269- const ceremony = sole
270- ? `\`os migrate packageless-overlays\` moves it into '${ sole . pair } '`
271- : '`os migrate packageless-overlays` lists it for you to place' ;
272- const closed = 'A write naming no package onto a packaged item is closed (ADR-0146 D11); '
273- + `a package-less customization stored before it is still served until ${ ceremony } .` ;
245+ const shipped = `ships in '${ closed . base } '` ;
246+ const pair = `'${ closed . pair } ' (?package=${ closed . pair } )` ;
247+ const declared = `overrides: { package: '${ closed . base } ', basedOn }` ;
248+ const rule = 'A write naming no package onto a packaged item is closed (ADR-0146 D11); '
249+ + 'a package-less customization stored before it is still served until '
250+ + `\`os migrate packageless-overlays\` moves it into '${ closed . pair } '.` ;
274251 const message = operation === 'rollback'
275252 ? `${ item } ${ shipped } , and a rollback of its package-less row is closed (ADR-0146 D11): run `
276253 + `\`os migrate packageless-overlays\` to move the row into ${ pair } , then roll it back there.`
277254 : operation === 'delete'
278- ? `${ item } ${ shipped } : remove its customization from ${ pair } . ${ closed } `
279- : `${ item } ${ shipped } : ${ operation === 'publish' ? 'publish' : 'save' } it into ${ pair } , declaring ${ declared } . ${ closed } ` ;
255+ ? `${ item } ${ shipped } : remove its customization from ${ pair } . ${ rule } `
256+ : `${ item } ${ shipped } : ${ operation === 'publish' ? 'publish' : 'save' } it into ${ pair } , declaring ${ declared } . ${ rule } ` ;
280257 const err = new Error ( message ) ;
281258 ( err as any ) . code = 'NOT_OVERRIDABLE' ;
282259 ( err as any ) . status = 403 ;
0 commit comments