Skip to content

Commit ba525a5

Browse files
committed
feat: register system objects for auto-discovery in various plugins
1 parent d10f649 commit ba525a5

7 files changed

Lines changed: 74 additions & 4 deletions

File tree

packages/metadata/src/plugin.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Plugin, PluginContext } from '@objectstack/core';
44
import { NodeMetadataManager } from './node-metadata-manager.js';
55
import { DEFAULT_METADATA_TYPE_REGISTRY } from '@objectstack/spec/kernel';
66
import type { MetadataPluginConfig } from '@objectstack/spec/kernel';
7+
import { SysMetadataObject } from './objects/sys-metadata.object.js';
78

89
export interface MetadataPluginOptions {
910
rootDir?: string;
@@ -38,14 +39,25 @@ export class MetadataPlugin implements Plugin {
3839
}
3940

4041
init = async (ctx: PluginContext) => {
41-
ctx.logger.info('Initializing Metadata Manager', {
42+
ctx.logger.info('Initializing Metadata Manager', {
4243
root: this.options.rootDir || process.cwd(),
4344
watch: this.options.watch
4445
});
45-
46+
4647
// Register Metadata Manager as primary metadata service provider
4748
// This takes precedence over ObjectQL's fallback metadata service
4849
ctx.registerService('metadata', this.manager);
50+
51+
// Register metadata system objects so ObjectQLPlugin auto-discovers them
52+
ctx.registerService('app.com.objectstack.metadata', {
53+
id: 'com.objectstack.metadata',
54+
name: 'Metadata',
55+
version: '1.0.0',
56+
type: 'plugin',
57+
namespace: 'sys',
58+
objects: [SysMetadataObject],
59+
});
60+
4961
ctx.logger.info('MetadataPlugin providing metadata service (primary mode)', {
5062
mode: 'file-system',
5163
features: ['watch', 'persistence', 'multi-format', 'query', 'overlay', 'type-registry']

packages/plugins/plugin-audit/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"test": "vitest run --passWithNoTests"
1818
},
1919
"dependencies": {
20+
"@objectstack/core": "workspace:*",
2021
"@objectstack/spec": "workspace:*"
2122
},
2223
"devDependencies": {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
import type { Plugin, PluginContext } from '@objectstack/core';
4+
import { SysAuditLog } from './objects/index.js';
5+
6+
/**
7+
* AuditPlugin
8+
*
9+
* Registers the sys_audit_log system object with ObjectQL so it is
10+
* discoverable by the studio and available for CRUD operations.
11+
*/
12+
export class AuditPlugin implements Plugin {
13+
name = 'com.objectstack.audit';
14+
type = 'standard';
15+
version = '1.0.0';
16+
17+
async init(ctx: PluginContext): Promise<void> {
18+
// Register audit system objects so ObjectQLPlugin auto-discovers them
19+
ctx.registerService('app.com.objectstack.audit', {
20+
id: 'com.objectstack.audit',
21+
name: 'Audit',
22+
version: '1.0.0',
23+
type: 'plugin',
24+
namespace: 'sys',
25+
objects: [SysAuditLog],
26+
});
27+
28+
ctx.logger.info('Audit Plugin initialized');
29+
}
30+
}

packages/plugins/plugin-audit/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77
* Provides the sys_audit_log system object definition for immutable audit trails.
88
*/
99

10+
export { AuditPlugin } from './audit-plugin.js';
11+
1012
// System Object Definitions (sys namespace)
1113
export { SysAuditLog } from './objects/index.js';

packages/plugins/plugin-security/src/security-plugin.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { PermissionSet, RowLevelSecurityPolicy } from '@objectstack/spec/se
55
import { PermissionEvaluator } from './permission-evaluator.js';
66
import { RLSCompiler } from './rls-compiler.js';
77
import { FieldMasker } from './field-masker.js';
8+
import { SysRole, SysPermissionSet } from './objects/index.js';
89

910
/**
1011
* SecurityPlugin
@@ -31,12 +32,22 @@ export class SecurityPlugin implements Plugin {
3132

3233
async init(ctx: PluginContext): Promise<void> {
3334
ctx.logger.info('Initializing Security Plugin...');
34-
35+
3536
// Register security services
3637
ctx.registerService('security.permissions', this.permissionEvaluator);
3738
ctx.registerService('security.rls', this.rlsCompiler);
3839
ctx.registerService('security.fieldMasker', this.fieldMasker);
39-
40+
41+
// Register security system objects so ObjectQLPlugin auto-discovers them
42+
ctx.registerService('app.com.objectstack.security', {
43+
id: 'com.objectstack.security',
44+
name: 'Security',
45+
version: '1.0.0',
46+
type: 'plugin',
47+
namespace: 'sys',
48+
objects: [SysRole, SysPermissionSet],
49+
});
50+
4051
ctx.logger.info('Security Plugin initialized');
4152
}
4253

packages/services/service-feed/src/feed-service-plugin.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import type { Plugin, PluginContext } from '@objectstack/core';
44
import { InMemoryFeedAdapter } from './in-memory-feed-adapter.js';
55
import type { InMemoryFeedAdapterOptions } from './in-memory-feed-adapter.js';
6+
import { FeedItem, FeedReaction, RecordSubscription } from './objects/index.js';
67

78
/**
89
* Configuration options for the FeedServicePlugin.
@@ -53,6 +54,16 @@ export class FeedServicePlugin implements Plugin {
5354
async init(ctx: PluginContext): Promise<void> {
5455
const feed = new InMemoryFeedAdapter(this.options.memory);
5556
ctx.registerService('feed', feed);
57+
58+
// Register feed system objects so ObjectQLPlugin auto-discovers them
59+
ctx.registerService('app.com.objectstack.service.feed', {
60+
id: 'com.objectstack.service.feed',
61+
name: 'Feed Service',
62+
version: '1.0.0',
63+
type: 'plugin',
64+
objects: [FeedItem, FeedReaction, RecordSubscription],
65+
});
66+
5667
ctx.logger.info('FeedServicePlugin: registered in-memory feed adapter');
5768
}
5869
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)