@@ -3205,10 +3205,15 @@ async function readPackageCustomizations(
32053205 * - **flow** — the metadata registry's flows (`listItems('flow')`, which
32063206 * already leaves a disabled package's out), whose `start` node's
32073207 * `config.objectName` is a base-owned object, attributed to the package
3208- * stamp the registration put on it when that stamp is a code package's
3209- * ({@link isCodeArtifactBody}: not the package-less `sys_metadata`
3210- * sentinel, not a tenant-authored overlay). A flow authored in this
3211- * environment is the environment's, not a package's, and is not listed.
3208+ * stamp the registration put on it (its `_packageId`).
3209+ *
3210+ * Both kinds ask ONE question of their stamp, {@link codePackageOf}: is it a
3211+ * code package's ({@link isCodeArtifactBody}: not the package-less
3212+ * `sys_metadata` sentinel, not a tenant-authored body), and neither the base
3213+ * nor its pair? Only where the stamp is read differs: the contributor's
3214+ * `packageId` beside its `definition`, or the flow's own `_packageId`. An item
3215+ * authored in this environment is the environment's, not a package's, and is
3216+ * not listed, whichever kind it is.
32123217 *
32133218 * Ordered by object, kind, name and package.
32143219 */
@@ -3220,8 +3225,14 @@ function readBaseContributions(
32203225 type Contribution = GetPackageCustomizationsResponse [ 'contributions' ] [ number ] ;
32213226 const contributions : Contribution [ ] = [ ] ;
32223227 if ( typeof registry ?. getAllObjects !== 'function' ) return contributions ;
3223- const isContributor = ( packageId : unknown ) : packageId is string =>
3224- typeof packageId === 'string' && packageId !== '' && packageId !== baseId && packageId !== pairId ;
3228+ // The one stamp reading both kinds share: the package `packageId` names
3229+ // when `body` is a code package's item and the package is neither the base
3230+ // nor its pair; `undefined` otherwise.
3231+ const codePackageOf = ( packageId : unknown , body : unknown ) : string | undefined => {
3232+ if ( typeof packageId !== 'string' || packageId === baseId || packageId === pairId ) return undefined ;
3233+ const stamped = { _packageId : packageId , _provenance : ( body as { _provenance ?: unknown } | null | undefined ) ?. _provenance } ;
3234+ return isCodeArtifactBody ( stamped ) ? packageId : undefined ;
3235+ } ;
32253236
32263237 const owned = new Set < string > ( ) ;
32273238 for ( const object of registry . getAllObjects ( baseId ) as Array < { name ?: unknown } > ) {
@@ -3231,22 +3242,25 @@ function readBaseContributions(
32313242
32323243 for ( const name of owned ) {
32333244 for ( const contributor of registry . getObjectContributors ( name ) as Array < { packageId ?: unknown ; ownership ?: unknown ; definition ?: any } > ) {
3234- if ( contributor . ownership !== 'extend' || ! isContributor ( contributor . packageId ) ) continue ;
3245+ if ( contributor . ownership !== 'extend' ) continue ;
3246+ const packageId = codePackageOf ( contributor . packageId , contributor . definition ) ;
3247+ if ( packageId === undefined ) continue ;
32353248 for ( const field of Object . keys ( contributor . definition ?. fields ?? { } ) ) {
3236- contributions . push ( { kind : 'field' , object : name , name : field , packageId : contributor . packageId } ) ;
3249+ contributions . push ( { kind : 'field' , object : name , name : field , packageId } ) ;
32373250 }
32383251 }
32393252 }
32403253
32413254 if ( owned . size > 0 && typeof registry . listItems === 'function' ) {
32423255 for ( const flow of registry . listItems ( 'flow' ) as Array < { name ?: unknown ; nodes ?: unknown ; _packageId ?: unknown } > ) {
3243- if ( ! isCodeArtifactBody ( flow ) || ! isContributor ( flow . _packageId ) || typeof flow . name !== 'string' ) continue ;
3256+ const packageId = codePackageOf ( flow . _packageId , flow ) ;
3257+ if ( packageId === undefined || typeof flow . name !== 'string' ) continue ;
32443258 const start = Array . isArray ( flow . nodes )
32453259 ? flow . nodes . find ( ( node : any ) => node ?. type === 'start' )
32463260 : undefined ;
32473261 const object = start ?. config ?. objectName ;
32483262 if ( typeof object !== 'string' || ! owned . has ( object ) ) continue ;
3249- contributions . push ( { kind : 'flow' , object, name : flow . name , packageId : flow . _packageId } ) ;
3263+ contributions . push ( { kind : 'flow' , object, name : flow . name , packageId } ) ;
32503264 }
32513265 }
32523266
0 commit comments