@@ -20,6 +20,7 @@ import { ObjectKernel, type PluginContext } from '@objectstack/core';
2020import { defineStack } from '@objectstack/spec' ;
2121import { ObjectQL } from './engine.js' ;
2222import { ObjectQLPlugin } from './plugin.js' ;
23+ import { FIND_BOUND_ACTION_COLLISIONS , SchemaRegistry } from './registry.js' ;
2324
2425/** The package that OWNS the target object, with an action of its own. */
2526const OWNER = {
@@ -59,14 +60,14 @@ async function engineWith(packages: any[]) {
5960const servedRename = ( engine : ObjectQL ) : any [ ] =>
6061 ( ( engine . registry . getObject ( 'bc_org' ) as any ) ?. actions ?? [ ] ) . filter ( ( a : any ) => a ?. name === 'rename' ) ;
6162
62- describe ( 'SchemaRegistry.findBoundActionCollisions ' , ( ) => {
63+ describe ( 'the registry\'s bound-action collision audit ' , ( ) => {
6364 for ( const [ order , packages ] of [
6465 [ 'owner first' , [ OWNER , TWIN ] ] ,
6566 [ 'twin first' , [ TWIN , OWNER ] ] ,
6667 ] as const ) {
6768 it ( `${ order } : a different declaration under the object's own action name is one pair, naming both packages` , async ( ) => {
6869 const engine = await engineWith ( [ ...packages ] ) ;
69- expect ( engine . registry . findBoundActionCollisions ( ) ) . toEqual ( [
70+ expect ( engine . registry [ FIND_BOUND_ACTION_COLLISIONS ] ( ) ) . toEqual ( [
7071 { objectName : 'bc_org' , action : 'rename' , servedPackageId : 'com.test.owner' , shadowedPackageId : 'com.test.twin' } ,
7172 ] ) ;
7273 // Reported, not acted on: the object still serves its own declaration.
@@ -76,7 +77,7 @@ describe('SchemaRegistry.findBoundActionCollisions', () => {
7677
7778 it ( 'one declaration carried by two packages is not a collision' , async ( ) => {
7879 const engine = await engineWith ( [ OWNER , CARRIER ] ) ;
79- expect ( engine . registry . findBoundActionCollisions ( ) ) . toEqual ( [ ] ) ;
80+ expect ( engine . registry [ FIND_BOUND_ACTION_COLLISIONS ] ( ) ) . toEqual ( [ ] ) ;
8081 } ) ;
8182
8283 it ( 'a same-stack bound action — merged onto its object and kept top-level — is not a collision' , async ( ) => {
@@ -88,24 +89,34 @@ describe('SchemaRegistry.findBoundActionCollisions', () => {
8889 // The JSON round trip is the compiled artifact's shape: two copies, not one reference.
8990 const engine = await engineWith ( [ JSON . parse ( JSON . stringify ( { ...stack , ...stack . manifest } ) ) ] ) ;
9091 expect ( ( engine . registry . getObject ( 'bc_same' ) as any ) ?. actions ?. map ( ( a : any ) => a . name ) ) . toEqual ( [ 'same_action' ] ) ;
91- expect ( engine . registry . findBoundActionCollisions ( ) ) . toEqual ( [ ] ) ;
92+ expect ( engine . registry [ FIND_BOUND_ACTION_COLLISIONS ] ( ) ) . toEqual ( [ ] ) ;
9293 } ) ;
9394
9495 it ( 'two packages binding different declarations of one name to a third package\'s object: the first attached is served, the second reported' , async ( ) => {
9596 const owner = { ...OWNER , objects : [ { ...OWNER . objects [ 0 ] , actions : [ ] } ] } ;
9697 const second = { ...TWIN , id : 'com.test.second' , name : 'second' , actions : [ { ...TWIN . actions [ 0 ] , label : 'Rename (second)' , target : 'https://example.com/second' } ] } ;
9798 const engine = await engineWith ( [ owner , TWIN , second ] ) ;
9899 expect ( servedRename ( engine ) . map ( ( a ) => a . _packageId ) ) . toEqual ( [ 'com.test.twin' ] ) ;
99- expect ( engine . registry . findBoundActionCollisions ( ) ) . toEqual ( [
100+ expect ( engine . registry [ FIND_BOUND_ACTION_COLLISIONS ] ( ) ) . toEqual ( [
100101 { objectName : 'bc_org' , action : 'rename' , servedPackageId : 'com.test.twin' , shadowedPackageId : 'com.test.second' } ,
101102 ] ) ;
102103 } ) ;
103104
105+ it ( 'is no nameable member of the published face: keyed on a symbol neither package entry exports' , async ( ) => {
106+ const entry = await import ( './index.js' ) ;
107+ const core = await import ( './core.js' ) ;
108+ expect ( 'FIND_BOUND_ACTION_COLLISIONS' in entry ) . toBe ( false ) ;
109+ expect ( 'FIND_BOUND_ACTION_COLLISIONS' in core ) . toBe ( false ) ;
110+ expect ( Object . values ( entry ) ) . not . toContain ( FIND_BOUND_ACTION_COLLISIONS ) ;
111+ expect ( Object . getOwnPropertyNames ( SchemaRegistry . prototype ) ) . not . toContain ( 'findBoundActionCollisions' ) ;
112+ expect ( Object . getOwnPropertySymbols ( SchemaRegistry . prototype ) ) . toContain ( FIND_BOUND_ACTION_COLLISIONS ) ;
113+ } ) ;
114+
104115 it ( 'narrowed to a set of packages, it answers only the pairs naming one of them' , async ( ) => {
105116 const engine = await engineWith ( [ OWNER , TWIN , BYSTANDER ] ) ;
106- expect ( engine . registry . findBoundActionCollisions ( new Set ( [ 'com.test.bystander' ] ) ) ) . toEqual ( [ ] ) ;
107- expect ( engine . registry . findBoundActionCollisions ( new Set ( [ 'com.test.owner' ] ) ) ) . toHaveLength ( 1 ) ;
108- expect ( engine . registry . findBoundActionCollisions ( new Set ( [ 'com.test.twin' ] ) ) ) . toHaveLength ( 1 ) ;
117+ expect ( engine . registry [ FIND_BOUND_ACTION_COLLISIONS ] ( new Set ( [ 'com.test.bystander' ] ) ) ) . toEqual ( [ ] ) ;
118+ expect ( engine . registry [ FIND_BOUND_ACTION_COLLISIONS ] ( new Set ( [ 'com.test.owner' ] ) ) ) . toHaveLength ( 1 ) ;
119+ expect ( engine . registry [ FIND_BOUND_ACTION_COLLISIONS ] ( new Set ( [ 'com.test.twin' ] ) ) ) . toHaveLength ( 1 ) ;
109120 } ) ;
110121} ) ;
111122
0 commit comments