Skip to content

Commit 5901c29

Browse files
Copilothotlong
andcommitted
feat: add objectName to example app action definitions and changeset
- Updated app-todo task actions with objectName: 'task' - Updated app-crm actions: lead, opportunity, case, contact with matching objectName - Global actions (log_call, export_csv) intentionally remain without objectName - Added changeset for @objectstack/spec minor version bump Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent ed3ee3e commit 5901c29

6 files changed

Lines changed: 28 additions & 0 deletions

File tree

.changeset/action-object-merge.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/spec': minor
3+
---
4+
5+
feat: auto-merge actions into object metadata via objectName
6+
7+
- Added optional `objectName` field to `ActionSchema` for associating actions with specific objects
8+
- Added optional `actions` field to `ObjectSchema` to hold object-scoped actions
9+
- `defineStack()` and `composeStacks()` now auto-merge top-level actions with `objectName` into their target object's `actions` array
10+
- Added cross-reference validation for `action.objectName` referencing undefined objects
11+
- Top-level `actions` array is preserved for global access (platform overview, search)
12+
- Updated example apps (CRM, Todo) to use `objectName` on their action definitions

examples/app-crm/src/actions/case.actions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { Action } from '@objectstack/spec/ui';
66
export const EscalateCaseAction: Action = {
77
name: 'escalate_case',
88
label: 'Escalate Case',
9+
objectName: 'case',
910
icon: 'alert-triangle',
1011
type: 'modal',
1112
target: 'escalate_case_modal',
@@ -28,6 +29,7 @@ export const EscalateCaseAction: Action = {
2829
export const CloseCaseAction: Action = {
2930
name: 'close_case',
3031
label: 'Close Case',
32+
objectName: 'case',
3133
icon: 'check-circle',
3234
type: 'modal',
3335
target: 'close_case_modal',

examples/app-crm/src/actions/contact.actions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { Action } from '@objectstack/spec/ui';
66
export const MarkPrimaryContactAction: Action = {
77
name: 'mark_primary',
88
label: 'Mark as Primary Contact',
9+
objectName: 'contact',
910
icon: 'star',
1011
type: 'script',
1112
target: 'markAsPrimaryContact',
@@ -20,6 +21,7 @@ export const MarkPrimaryContactAction: Action = {
2021
export const SendEmailAction: Action = {
2122
name: 'send_email',
2223
label: 'Send Email',
24+
objectName: 'contact',
2325
icon: 'mail',
2426
type: 'modal',
2527
target: 'email_composer',

examples/app-crm/src/actions/lead.actions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { Action } from '@objectstack/spec/ui';
66
export const ConvertLeadAction: Action = {
77
name: 'convert_lead',
88
label: 'Convert Lead',
9+
objectName: 'lead',
910
icon: 'arrow-right-circle',
1011
type: 'flow',
1112
target: 'lead_conversion',
@@ -20,6 +21,7 @@ export const ConvertLeadAction: Action = {
2021
export const CreateCampaignAction: Action = {
2122
name: 'create_campaign',
2223
label: 'Add to Campaign',
24+
objectName: 'lead',
2325
icon: 'send',
2426
type: 'modal',
2527
target: 'add_to_campaign_modal',

examples/app-crm/src/actions/opportunity.actions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { Action } from '@objectstack/spec/ui';
66
export const CloneOpportunityAction: Action = {
77
name: 'clone_opportunity',
88
label: 'Clone Opportunity',
9+
objectName: 'opportunity',
910
icon: 'copy',
1011
type: 'script',
1112
target: 'cloneRecord',
@@ -18,6 +19,7 @@ export const CloneOpportunityAction: Action = {
1819
export const MassUpdateStageAction: Action = {
1920
name: 'mass_update_stage',
2021
label: 'Update Stage',
22+
objectName: 'opportunity',
2123
icon: 'layers',
2224
type: 'modal',
2325
target: 'mass_update_stage_modal',

examples/app-todo/src/actions/task.actions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { Action } from '@objectstack/spec/ui';
66
export const CompleteTaskAction: Action = {
77
name: 'complete_task',
88
label: 'Mark Complete',
9+
objectName: 'task',
910
icon: 'check-circle',
1011
type: 'script',
1112
target: 'completeTask',
@@ -18,6 +19,7 @@ export const CompleteTaskAction: Action = {
1819
export const StartTaskAction: Action = {
1920
name: 'start_task',
2021
label: 'Start Task',
22+
objectName: 'task',
2123
icon: 'play-circle',
2224
type: 'script',
2325
target: 'startTask',
@@ -30,6 +32,7 @@ export const StartTaskAction: Action = {
3032
export const DeferTaskAction: Action = {
3133
name: 'defer_task',
3234
label: 'Defer Task',
35+
objectName: 'task',
3336
icon: 'clock',
3437
type: 'modal',
3538
target: 'defer_task_modal',
@@ -56,6 +59,7 @@ export const DeferTaskAction: Action = {
5659
export const SetReminderAction: Action = {
5760
name: 'set_reminder',
5861
label: 'Set Reminder',
62+
objectName: 'task',
5963
icon: 'bell',
6064
type: 'modal',
6165
target: 'set_reminder_modal',
@@ -76,6 +80,7 @@ export const SetReminderAction: Action = {
7680
export const CloneTaskAction: Action = {
7781
name: 'clone_task',
7882
label: 'Clone Task',
83+
objectName: 'task',
7984
icon: 'copy',
8085
type: 'script',
8186
target: 'cloneTask',
@@ -88,6 +93,7 @@ export const CloneTaskAction: Action = {
8893
export const MassCompleteTasksAction: Action = {
8994
name: 'mass_complete',
9095
label: 'Complete Selected',
96+
objectName: 'task',
9197
icon: 'check-square',
9298
type: 'script',
9399
target: 'massCompleteTasks',
@@ -100,6 +106,7 @@ export const MassCompleteTasksAction: Action = {
100106
export const DeleteCompletedAction: Action = {
101107
name: 'delete_completed',
102108
label: 'Delete Completed',
109+
objectName: 'task',
103110
icon: 'trash-2',
104111
type: 'script',
105112
target: 'deleteCompletedTasks',
@@ -112,6 +119,7 @@ export const DeleteCompletedAction: Action = {
112119
export const ExportToCsvAction: Action = {
113120
name: 'export_csv',
114121
label: 'Export to CSV',
122+
objectName: 'task',
115123
icon: 'download',
116124
type: 'script',
117125
target: 'exportTasksToCSV',

0 commit comments

Comments
 (0)