Skip to content

Commit 0e38798

Browse files
Copilothotlong
andcommitted
Upgrade @objectstack/spec to v0.4.1 and update imports
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 628e485 commit 0e38798

File tree

13 files changed

+71
-128
lines changed

13 files changed

+71
-128
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@objectql/platform-node": "^3.0.1",
4646
"@objectql/starter-basic": "^1.8.4",
4747
"@objectql/starter-enterprise": "^1.8.4",
48-
"@objectstack/spec": "0.3.3",
48+
"@objectstack/spec": "0.4.1",
4949
"build": "^0.1.4"
5050
}
5151
}

packages/kernel/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"@objectql/core": "^3.0.1",
1313
"@objectql/types": "^3.0.1",
14-
"@objectstack/spec": "0.3.3",
14+
"@objectstack/spec": "0.4.1",
1515
"fast-glob": "^3.3.2",
1616
"js-yaml": "^4.1.0"
1717
},

packages/kernel/src/examples/crm-plugin-example.ts

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { ObjectOS } from '../objectos';
6-
import type { ObjectStackManifest, PluginDefinition } from '@objectstack/spec/kernel';
6+
import type { ObjectStackManifest, PluginDefinition } from '@objectstack/spec/system';
77

88
export const CRMManifest: ObjectStackManifest = {
99
id: 'com.example.crm',
@@ -12,37 +12,21 @@ export const CRMManifest: ObjectStackManifest = {
1212
name: 'Example CRM Plugin',
1313
description: 'A complete CRM plugin demonstrating spec compliance',
1414
permissions: ['system.user.read', 'system.data.write'],
15-
definitions: {
16-
objects: {
17-
crm_lead: {
18-
name: 'crm_lead',
19-
label: 'Lead',
20-
pluralLabel: 'Leads',
21-
description: 'Sales lead tracking',
22-
icon: 'user-plus',
23-
active: true,
24-
isSystem: false,
25-
abstract: false,
26-
datasource: 'default',
27-
fields: {
28-
name: {
29-
type: 'text',
30-
label: 'Lead Name',
31-
required: true,
32-
searchable: true,
33-
multiple: false,
34-
unique: false,
35-
deleteBehavior: 'set_null',
36-
hidden: false,
37-
readonly: false,
38-
encryption: false,
39-
index: false,
40-
externalId: false,
41-
},
42-
},
43-
},
44-
},
45-
},
15+
// In v0.4.1, objects are defined via glob patterns pointing to object definition files
16+
objects: ['./objects/*.object.yml'],
17+
// Contribution points for extending the platform
18+
contributes: {
19+
// Register custom actions that can be invoked by flows or API
20+
actions: [
21+
{
22+
name: 'convertLead',
23+
label: 'Convert Lead to Account',
24+
description: 'Converts a lead to an account and contact',
25+
}
26+
],
27+
// Register custom events that this plugin listens to
28+
events: ['lead.created', 'lead.converted'],
29+
}
4630
};
4731

4832
export const CRMPlugin: PluginDefinition = {

packages/kernel/src/kernel-context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* Kernel Context Implementation
33
*
4-
* Implements the KernelContext interface from @objectstack/spec/kernel.
4+
* Implements the KernelContext interface from @objectstack/spec/system.
55
* Provides static environment information available at boot time.
66
*/
77

8-
import type { KernelContext } from '@objectstack/spec/kernel';
8+
import type { KernelContext } from '@objectstack/spec/system';
99
import { randomUUID } from 'crypto';
1010

1111
/**

packages/kernel/src/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Logger Implementation
33
*
4-
* Provides structured logging that conforms to the @objectstack/spec/kernel Logger interface.
4+
* Provides structured logging that conforms to the @objectstack/spec/system Logger interface.
55
*/
66

77
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';

packages/kernel/src/objectos.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ObjectQL } from '@objectql/core';
22
import { ObjectQLConfig, ObjectQLPlugin } from '@objectql/types';
3-
import type { PluginDefinition, ObjectStackManifest, KernelContext } from '@objectstack/spec/kernel';
3+
import type { PluginDefinition, ObjectStackManifest, KernelContext } from '@objectstack/spec/system';
44
import { ObjectOSPlugin } from './plugins/objectql';
55
import { KernelContextManager } from './kernel-context';
66
import { StorageManager } from './scoped-storage';

packages/kernel/src/plugin-context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* Plugin Context Builder
33
*
44
* Creates PluginContext instances that provide plugins with access to
5-
* ObjectStack APIs according to @objectstack/spec/kernel.
5+
* ObjectStack APIs according to @objectstack/spec/system.
66
*/
77

8-
import type { PluginContextData } from '@objectstack/spec/kernel';
8+
import type { PluginContextData } from '@objectstack/spec/system';
99
import type { IObjectQL } from '@objectql/types';
1010
import { Logger, createLogger } from './logger';
1111
import { ScopedStorage } from './scoped-storage';

packages/kernel/src/plugin-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/**
22
* Plugin Manager
33
*
4-
* Manages the plugin lifecycle according to @objectstack/spec/kernel.
4+
* Manages the plugin lifecycle according to @objectstack/spec/system.
55
* Handles plugin registration, initialization, and lifecycle hooks.
66
*/
77

88
import type {
99
PluginDefinition,
1010
PluginContextData,
1111
ObjectStackManifest
12-
} from '@objectstack/spec/kernel';
12+
} from '@objectstack/spec/system';
1313
import { Logger, createLogger } from './logger';
1414
import { ScopedStorage } from './scoped-storage';
1515

packages/kernel/src/plugins/example-spec-plugin.ts

Lines changed: 36 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* ObjectStack specification for plugin lifecycle and context.
66
*/
77

8-
import type { PluginDefinition, PluginContextData, ObjectStackManifest } from '@objectstack/spec/kernel';
8+
import type { PluginDefinition, PluginContextData, ObjectStackManifest } from '@objectstack/spec/system';
99

1010
/**
1111
* Plugin Manifest
12-
* Conforms to @objectstack/spec/kernel/ManifestSchema
12+
* Conforms to @objectstack/spec/system/ManifestSchema
1313
*
1414
* This is typically stored in a package.json or manifest.json file
1515
* and loaded by the kernel. For this example, we define it inline.
@@ -24,74 +24,31 @@ export const ExampleCRMManifest: ObjectStackManifest = {
2424
'system.user.read',
2525
'system.data.write',
2626
],
27-
// Object files can be specified as glob patterns
27+
// In v0.4.1, objects are defined via glob patterns pointing to object definition files
28+
// Object files should be YAML or TypeScript files following the object schema
2829
objects: ['./objects/*.object.yml'],
29-
// Or provided inline as compiled definitions
30-
definitions: {
31-
objects: {
32-
'crm_lead': {
33-
name: 'crm_lead',
34-
label: 'Lead',
35-
pluralLabel: 'Leads',
36-
description: 'Sales lead tracking',
37-
icon: 'user-plus',
38-
active: true,
39-
isSystem: false,
40-
abstract: false,
41-
datasource: 'default',
42-
fields: {
43-
name: {
44-
type: 'text',
45-
label: 'Lead Name',
46-
required: true,
47-
searchable: true,
48-
multiple: false,
49-
unique: false,
50-
deleteBehavior: 'set_null',
51-
hidden: false,
52-
readonly: false,
53-
encryption: false,
54-
index: false,
55-
externalId: false,
56-
},
57-
email: {
58-
type: 'email',
59-
label: 'Email',
60-
required: true,
61-
searchable: true,
62-
unique: true,
63-
multiple: false,
64-
deleteBehavior: 'set_null',
65-
hidden: false,
66-
readonly: false,
67-
encryption: false,
68-
index: true,
69-
externalId: false,
70-
},
71-
status: {
72-
type: 'select',
73-
label: 'Status',
74-
required: true,
75-
searchable: true,
76-
multiple: false,
77-
unique: false,
78-
deleteBehavior: 'set_null',
79-
hidden: false,
80-
readonly: false,
81-
encryption: false,
82-
index: false,
83-
externalId: false,
84-
options: [
85-
{ label: 'New', value: 'new', default: true },
86-
{ label: 'Contacted', value: 'contacted' },
87-
{ label: 'Qualified', value: 'qualified' },
88-
{ label: 'Converted', value: 'converted' },
89-
{ label: 'Lost', value: 'lost' },
90-
],
91-
},
92-
},
93-
},
94-
},
30+
31+
// Contribution points for extending the platform
32+
contributes: {
33+
// Register custom actions that can be invoked by flows or API
34+
actions: [
35+
{
36+
name: 'convertLead',
37+
label: 'Convert Lead to Account',
38+
description: 'Converts a lead to an account and contact',
39+
}
40+
],
41+
// Register custom events that this plugin listens to
42+
events: ['crm_lead.created', 'crm_lead.converted'],
43+
44+
// Register custom field types
45+
fieldTypes: [
46+
{
47+
name: 'lead_status',
48+
label: 'Lead Status',
49+
description: 'Special field type for lead status with workflow integration',
50+
}
51+
],
9552
},
9653
};
9754

@@ -103,7 +60,7 @@ export const ExampleCRMManifest: ObjectStackManifest = {
10360
* - Using the plugin context (ql, os, logger, storage, etc.)
10461
* - Registering routes and scheduled jobs
10562
*
106-
* Conforms to @objectstack/spec/kernel/PluginLifecycleSchema
63+
* Conforms to @objectstack/spec/system/PluginLifecycleSchema
10764
*/
10865
export const ExampleCRMPlugin: PluginDefinition = {
10966

@@ -125,7 +82,7 @@ export const ExampleCRMPlugin: PluginDefinition = {
12582
async onEnable(context: PluginContextData) {
12683
context.logger.info('CRM Plugin: Enabling...');
12784

128-
// The metadata from ExampleCRMManifest.definitions is loaded by the kernel
85+
// The metadata from object files (specified in manifest.objects) is loaded by the kernel
12986
// before this hook is called
13087

13188
// Register custom routes
@@ -226,20 +183,22 @@ export const ExampleCRMPlugin: PluginDefinition = {
226183
* await os.init();
227184
* ```
228185
*
229-
* ## Plugin Architecture Notes
186+
* ## Plugin Architecture Notes (v0.4.1)
230187
*
231-
* In the ObjectStack spec, plugins are separated into two parts:
188+
* In the ObjectStack spec v0.4.1, plugins are separated into two parts:
232189
*
233-
* 1. **Manifest** (@objectstack/spec/kernel/ManifestSchema)
190+
* 1. **Manifest** (@objectstack/spec/system/ManifestSchema)
234191
* - Static configuration (id, version, name, permissions)
235-
* - Object definitions and metadata
192+
* - Object file glob patterns (objects are defined in separate files)
193+
* - Contribution points (actions, events, field types, etc.)
236194
* - Typically stored in package.json or manifest.json
237195
*
238-
* 2. **Lifecycle Hooks** (@objectstack/spec/kernel/PluginLifecycleSchema)
196+
* 2. **Lifecycle Hooks** (@objectstack/spec/system/PluginLifecycleSchema)
239197
* - Runtime behavior (onInstall, onEnable, onLoad, etc.)
240198
* - Executable code
241199
* - Typically exported from index.ts or main.js
242200
*
243201
* The kernel loads manifests first to understand what plugins are available,
244-
* then executes lifecycle hooks at appropriate times.
202+
* then loads object definitions from the files specified in manifest.objects,
203+
* and finally executes lifecycle hooks at appropriate times.
245204
*/

0 commit comments

Comments
 (0)