Skip to content

Commit dbd57ac

Browse files
committed
feat: refactor flows and agents imports for better organization and type safety
1 parent fecf5e1 commit dbd57ac

File tree

9 files changed

+76
-24
lines changed

9 files changed

+76
-24
lines changed

examples/app-crm/objectstack.config.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@ import * as apis from './src/apis';
88
import * as actions from './src/actions';
99
import * as dashboards from './src/dashboards';
1010
import * as reports from './src/reports';
11-
import * as flows from './src/flows';
12-
import * as agents from './src/agents';
11+
import { allFlows } from './src/flows';
12+
import { allAgents } from './src/agents';
1313
import * as ragPipelines from './src/rag';
1414
import * as profiles from './src/profiles';
1515
import * as apps from './src/apps';
16-
import * as interfaces from './src/interfaces';
1716
import * as translations from './src/translations';
1817
import { CrmSeedData } from './src/data';
1918

2019
// ─── Sharing & Security (special: mixed single/array values) ───────
2120
import {
22-
OrganizationDefaults,
2321
AccountTeamSharingRule, TerritorySharingRules,
2422
OpportunitySalesSharingRule,
2523
CaseEscalationSharingRule,
@@ -56,12 +54,11 @@ export default defineStack({
5654
actions: Object.values(actions),
5755
dashboards: Object.values(dashboards),
5856
reports: Object.values(reports),
59-
flows: Object.values(flows) as any,
60-
agents: Object.values(agents) as any,
57+
flows: allFlows,
58+
agents: allAgents,
6159
ragPipelines: Object.values(ragPipelines),
62-
profiles: Object.values(profiles),
60+
permissions: Object.values(profiles),
6361
apps: Object.values(apps),
64-
interfaces: Object.values(interfaces),
6562

6663
// Seed Data (top-level, registered as metadata)
6764
data: CrmSeedData,
@@ -77,13 +74,16 @@ export default defineStack({
7774
// I18n Translation Bundles (en, zh-CN, ja-JP, es-ES)
7875
translations: Object.values(translations),
7976

80-
// Sharing & security (requires explicit wiring)
77+
// Sharing & security
8178
sharingRules: [
8279
AccountTeamSharingRule,
8380
OpportunitySalesSharingRule,
8481
CaseEscalationSharingRule,
8582
...TerritorySharingRules,
8683
],
87-
roleHierarchy: RoleHierarchy,
88-
organizationDefaults: OrganizationDefaults,
89-
} as any);
84+
roles: RoleHierarchy.roles.map((r: { name: string; label: string; parentRole: string | null }) => ({
85+
name: r.name,
86+
label: r.label,
87+
parent: r.parentRole ?? undefined,
88+
})),
89+
});

examples/app-crm/src/agents/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
22

3+
import type { Agent } from '@objectstack/spec/ai';
4+
35
/**
46
* Agent Definitions Barrel
57
*/
@@ -8,3 +10,18 @@ export { LeadEnrichmentAgent } from './lead-enrichment.agent';
810
export { RevenueIntelligenceAgent } from './revenue-intelligence.agent';
911
export { SalesAssistantAgent } from './sales.agent';
1012
export { ServiceAgent } from './service.agent';
13+
14+
import { EmailCampaignAgent } from './email-campaign.agent';
15+
import { LeadEnrichmentAgent } from './lead-enrichment.agent';
16+
import { RevenueIntelligenceAgent } from './revenue-intelligence.agent';
17+
import { SalesAssistantAgent } from './sales.agent';
18+
import { ServiceAgent } from './service.agent';
19+
20+
/** All agent definitions as a typed array for defineStack() */
21+
export const allAgents: Agent[] = [
22+
EmailCampaignAgent,
23+
LeadEnrichmentAgent,
24+
RevenueIntelligenceAgent,
25+
SalesAssistantAgent,
26+
ServiceAgent,
27+
];

examples/app-crm/src/flows/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
22

3+
import type { Flow } from '@objectstack/spec/automation';
4+
35
/**
46
* Flow Definitions Barrel
57
*/
@@ -8,3 +10,18 @@ export { CaseEscalationFlow } from './case-escalation.flow';
810
export { LeadConversionFlow } from './lead-conversion.flow';
911
export { OpportunityApprovalFlow } from './opportunity-approval.flow';
1012
export { QuoteGenerationFlow } from './quote-generation.flow';
13+
14+
import { CampaignEnrollmentFlow } from './campaign-enrollment.flow';
15+
import { CaseEscalationFlow } from './case-escalation.flow';
16+
import { LeadConversionFlow } from './lead-conversion.flow';
17+
import { OpportunityApprovalFlow } from './opportunity-approval.flow';
18+
import { QuoteGenerationFlow } from './quote-generation.flow';
19+
20+
/** All flow definitions as a typed array for defineStack() */
21+
export const allFlows: Flow[] = [
22+
CampaignEnrollmentFlow,
23+
CaseEscalationFlow,
24+
LeadConversionFlow,
25+
OpportunityApprovalFlow,
26+
QuoteGenerationFlow,
27+
];

examples/app-crm/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"forceConsistentCasingInFileNames": true,
99
"skipLibCheck": true,
1010
"outDir": "./dist",
11-
"rootDir": "./src"
11+
"rootDir": "."
1212
},
13-
"include": ["src/**/*"]
13+
"include": ["src/**/*", "objectstack.config.ts"]
1414
}

examples/app-host/objectstack.config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ const authPlugin = new AuthPlugin({
2424

2525
export default defineStack({
2626
manifest: {
27-
id: 'app-host',
28-
name: 'app_host',
27+
id: 'com.example.host',
28+
namespace: 'host',
29+
name: 'App Host',
2930
version: '1.0.0',
3031
description: 'Host application aggregating CRM, Todo and BI plugins',
3132
type: 'app',
@@ -91,8 +92,9 @@ export default defineStack({
9192
*/
9293
export const PreviewHostExample = defineStack({
9394
manifest: {
94-
id: 'app-host-preview',
95-
name: 'app_host_preview',
95+
id: 'com.example.host-preview',
96+
namespace: 'host',
97+
name: 'App Host Preview',
9698
version: '1.0.0',
9799
description: 'Host application in preview/demo mode — bypasses login, simulates admin user',
98100
type: 'app',

examples/app-todo/objectstack.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as objects from './src/objects';
77
import * as actions from './src/actions';
88
import * as dashboards from './src/dashboards';
99
import * as reports from './src/reports';
10-
import * as flows from './src/flows';
10+
import { allFlows } from './src/flows';
1111
import * as apps from './src/apps';
1212
import * as translations from './src/translations';
1313

@@ -59,7 +59,7 @@ export default defineStack({
5959
actions: Object.values(actions),
6060
dashboards: Object.values(dashboards),
6161
reports: Object.values(reports),
62-
flows: Object.values(flows) as any,
62+
flows: allFlows,
6363
apps: Object.values(apps),
6464

6565
// I18n Configuration — per-locale file organization

examples/app-todo/src/flows/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
22

3+
import type { Flow } from '@objectstack/spec/automation';
4+
35
/**
46
* Flow Definitions Barrel
57
*/
@@ -9,3 +11,18 @@ export {
911
TaskCompletionFlow,
1012
QuickAddTaskFlow,
1113
} from './task.flow';
14+
15+
import {
16+
TaskReminderFlow,
17+
OverdueEscalationFlow,
18+
TaskCompletionFlow,
19+
QuickAddTaskFlow,
20+
} from './task.flow';
21+
22+
/** All flow definitions as a typed array for defineStack() */
23+
export const allFlows: Flow[] = [
24+
TaskReminderFlow,
25+
OverdueEscalationFlow,
26+
TaskCompletionFlow,
27+
QuickAddTaskFlow,
28+
];

examples/app-todo/src/flows/task.flow.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
22

3-
import type { Automation } from '@objectstack/spec';
4-
type Flow = Automation.Flow;
3+
import type { Flow } from '@objectstack/spec/automation';
54

65
/** Task Reminder Flow — scheduled flow to send reminders for upcoming tasks */
76
export const TaskReminderFlow: Flow = {

examples/app-todo/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"forceConsistentCasingInFileNames": true,
99
"skipLibCheck": true,
1010
"outDir": "./dist",
11-
"rootDir": "./src"
11+
"rootDir": "."
1212
},
13-
"include": ["src/**/*"]
13+
"include": ["src/**/*", "objectstack.config.ts"]
1414
}

0 commit comments

Comments
 (0)