Skip to content

Commit

Permalink
refactor: rename handlers for consistency and clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
Sma1lboy committed Jan 18, 2025
1 parent 642bcec commit 36a9730
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 166 deletions.
20 changes: 10 additions & 10 deletions backend/src/build-system/__tests__/fullstack-gen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { Logger } from '@nestjs/common';
import { ProjectInitHandler } from '../handlers/project-init';
import { PRDHandler } from '../handlers/product-manager/product-requirements-document/prd';
import { UXSMDHandler } from '../handlers/ux/sitemap-document';
import { UXSitemapStructureHandler } from '../handlers/ux/sitemap-structure';
import { UXDatamapHandler } from '../handlers/ux/datamap';
import { DatabaseRequirementHandler } from '../handlers/database/requirements-document';
import { UXSMSHandler } from '../handlers/ux/sitemap-structure';
import { UXDMDHandler } from '../handlers/ux/datamap';
import { DBRequirementHandler } from '../handlers/database/requirements-document';
import { FileStructureHandler } from '../handlers/file-manager/file-structure';
import { UXSitemapStructurePagebyPageHandler } from '../handlers/ux/sitemap-structure/sms-page';
import { UXSMSPageByPageHandler } from '../handlers/ux/sitemap-structure/sms-page';
import { DBSchemaHandler } from '../handlers/database/schemas/schemas';
import { FileArchGenerateHandler } from '../handlers/file-manager/file-arch';
import { FileFAHandler } from '../handlers/file-manager/file-arch';
import { BackendRequirementHandler } from '../handlers/backend/requirements-document';
import { BackendCodeHandler } from '../handlers/backend/code-generate';
import { BackendFileReviewHandler } from '../handlers/backend/file-review/file-review';
Expand All @@ -38,17 +38,17 @@ import { BackendFileReviewHandler } from '../handlers/backend/file-review/file-r
name: 'UX Sitemap Document Node',
},
{
handler: UXSitemapStructureHandler,
handler: UXSMSHandler,
name: 'UX Sitemap Structure Node',
// requires: ['op:UX:SMD'],
},
{
handler: UXDatamapHandler,
handler: UXDMDHandler,
name: 'UX DataMap Document Node',
// requires: ['op:UX:SMD'],
},
{
handler: DatabaseRequirementHandler,
handler: DBRequirementHandler,
name: 'Database Requirements Node',
// requires: ['op:UX:DATAMAP:DOC'],
},
Expand All @@ -61,7 +61,7 @@ import { BackendFileReviewHandler } from '../handlers/backend/file-review/file-r
},
},
{
handler: UXSitemapStructurePagebyPageHandler,
handler: UXSMSPageByPageHandler,
name: 'Level 2 UX Sitemap Structure Node details',
// requires: ['op:UX:SMS'],
},
Expand All @@ -71,7 +71,7 @@ import { BackendFileReviewHandler } from '../handlers/backend/file-review/file-r
// requires: ['op:DATABASE_REQ'],
},
{
handler: FileArchGenerateHandler,
handler: FileFAHandler,
name: 'File Arch',
// requires: ['op:FILE:STRUCT', 'op:UX:DATAMAP:DOC'],
},
Expand Down
174 changes: 87 additions & 87 deletions backend/src/build-system/__tests__/test-generate-doc.spec.ts
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
import { isIntegrationTest } from 'src/common/utils';
import { BuildSequence } from '../types';
import { executeBuildSequence } from './utils';
import { Logger } from '@nestjs/common';
// import { isIntegrationTest } from 'src/common/utils';
// import { BuildSequence } from '../types';
// import { executeBuildSequence } from './utils';
// import { Logger } from '@nestjs/common';

// TODO: adding integration flag
(isIntegrationTest ? describe : describe.skip)(
'Sequence: PRD -> UXSD -> UXDD -> UXSS',
() => {
it('should execute the full sequence and log results to individual files', async () => {
const sequence: BuildSequence = {
id: 'test-backend-sequence',
version: '1.0.0',
name: 'Spotify-like Music Web',
description: 'Users can play music',
databaseType: 'SQLite',
steps: [
{
id: 'step-1',
name: 'Generate PRD',
nodes: [
{
id: 'op:PRD',
name: 'PRD Generation Node',
},
],
},
{
id: 'step-2',
name: 'Generate UX Sitemap Document',
nodes: [
{
id: 'op:UX:SMD',
name: 'UX Sitemap Document Node',
},
],
},
{
id: 'step-3',
name: 'Generate UX Sitemap Structure',
nodes: [
{
id: 'op:UX:SMS',
name: 'UX Sitemap Structure Node',
},
],
},
{
id: 'step-4',
name: 'UX Data Map Document',
nodes: [
{
id: 'op:UX:DATAMAP:DOC',
name: 'UX Data Map Document node',
},
],
},
{
id: 'step-5',
name: 'UX SMD LEVEL 2 Page Details',
nodes: [
{
id: 'op:UX:SMS:LEVEL2',
name: 'UX SMD LEVEL 2 Page Details Node',
},
],
},
],
};
// // TODO: adding integration flag
// (isIntegrationTest ? describe : describe.skip)(
// 'Sequence: PRD -> UXSD -> UXDD -> UXSS',
// () => {
// it('should execute the full sequence and log results to individual files', async () => {
// const sequence: BuildSequence = {
// id: 'test-backend-sequence',
// version: '1.0.0',
// name: 'Spotify-like Music Web',
// description: 'Users can play music',
// databaseType: 'SQLite',
// steps: [
// {
// id: 'step-1',
// name: 'Generate PRD',
// nodes: [
// {
// id: 'op:PRD',
// name: 'PRD Generation Node',
// },
// ],
// },
// {
// id: 'step-2',
// name: 'Generate UX Sitemap Document',
// nodes: [
// {
// id: 'op:UX:SMD',
// name: 'UX Sitemap Document Node',
// },
// ],
// },
// {
// id: 'step-3',
// name: 'Generate UX Sitemap Structure',
// nodes: [
// {
// id: 'op:UX:SMS',
// name: 'UX Sitemap Structure Node',
// },
// ],
// },
// {
// id: 'step-4',
// name: 'UX Data Map Document',
// nodes: [
// {
// id: 'op:UX:DATAMAP:DOC',
// name: 'UX Data Map Document node',
// },
// ],
// },
// {
// id: 'step-5',
// name: 'UX SMD LEVEL 2 Page Details',
// nodes: [
// {
// id: 'op:UX:SMS:LEVEL2',
// name: 'UX SMD LEVEL 2 Page Details Node',
// },
// ],
// },
// ],
// };

try {
const result = await executeBuildSequence(
'test-generate-all-ux-part',
sequence,
);
// try {
// const result = await executeBuildSequence(
// 'test-generate-all-ux-part',
// sequence,
// );

Logger.log(
'Sequence completed successfully. Logs stored in:',
result.logFolderPath,
);
// Logger.log(
// 'Sequence completed successfully. Logs stored in:',
// result.logFolderPath,
// );

if (!result.success) {
throw result.error;
}
} catch (error) {
Logger.error('Error during sequence execution:', error);
throw error;
}
}, 600000);
},
);
// if (!result.success) {
// throw result.error;
// }
// } catch (error) {
// Logger.error('Error during sequence execution:', error);
// throw error;
// }
// }, 600000);
// },
// );
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { executeBuildSequence } from './utils';
import { isIntegrationTest } from 'src/common/utils';
import { PRDHandler } from '../handlers/product-manager/product-requirements-document/prd';
import { UXSMDHandler } from '../handlers/ux/sitemap-document';
import { DatabaseRequirementHandler } from '../handlers/database/requirements-document';
import { DBRequirementHandler } from '../handlers/database/requirements-document';
import { DBSchemaHandler } from '../handlers/database/schemas/schemas';
import { BackendCodeHandler } from '../handlers/backend/code-generate';
import { ProjectInitHandler } from '../handlers/project-init';
Expand Down Expand Up @@ -49,7 +49,7 @@ import { ProjectInitHandler } from '../handlers/project-init';
},

{
handler: DatabaseRequirementHandler,
handler: DBRequirementHandler,
name: 'Database Requirements Node',
// requires: ['op:UX:DATAMAP:DOC'],
},
Expand Down
12 changes: 6 additions & 6 deletions backend/src/build-system/__tests__/test.sms-lvl2.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { isIntegrationTest } from 'src/common/utils';
import { PRDHandler } from '../handlers/product-manager/product-requirements-document/prd';
import { ProjectInitHandler } from '../handlers/project-init';
import { UXDatamapHandler } from '../handlers/ux/datamap';
import { UXDMDHandler } from '../handlers/ux/datamap';
import { UXSMDHandler } from '../handlers/ux/sitemap-document';
import { UXSitemapStructureHandler } from '../handlers/ux/sitemap-structure';
import { UXSitemapStructurePagebyPageHandler } from '../handlers/ux/sitemap-structure/sms-page';
import { UXSMSHandler as UXSMSHandler } from '../handlers/ux/sitemap-structure';
import { UXSMSPageByPageHandler } from '../handlers/ux/sitemap-structure/sms-page';
import { BuildSequence } from '../types';
import { executeBuildSequence } from './utils';

Expand Down Expand Up @@ -34,15 +34,15 @@ import { executeBuildSequence } from './utils';
},

{
handler: UXSitemapStructureHandler,
handler: UXSMSHandler,
name: 'UX Sitemap Structure Node',
},
{
handler: UXDatamapHandler,
handler: UXDMDHandler,
name: 'UX DataMap Document Node',
},
{
handler: UXSitemapStructurePagebyPageHandler,
handler: UXSMSPageByPageHandler,
name: 'Level 2 UX Sitemap Structure Node details',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from 'src/build-system/errors';
import { BuildNode, BuildNodeRequire } from 'src/build-system/hanlder-manager';
import { UXSMDHandler } from '../../ux/sitemap-document';
import { UXDatamapHandler } from '../../ux/datamap';
import { UXDMDHandler } from '../../ux/datamap';
import { DBSchemaHandler } from '../../database/schemas/schemas';
import { BackendRequirementHandler } from '../requirements-document';

Expand All @@ -23,7 +23,7 @@ import { BackendRequirementHandler } from '../requirements-document';
*/

@BuildNode()
@BuildNodeRequire([UXSMDHandler, UXDatamapHandler, DBSchemaHandler])
@BuildNodeRequire([UXSMDHandler, UXDMDHandler, DBSchemaHandler])
export class BackendCodeHandler implements BuildHandler<string> {
async run(context: BuilderContext): Promise<BuildResult<string>> {
const projectName =
Expand All @@ -32,7 +32,7 @@ export class BackendCodeHandler implements BuildHandler<string> {
context.getGlobalContext('databaseType') || 'Default database type';
// Retrieve required documents
const sitemapDoc = context.getNodeData(UXSMDHandler);
const datamapDoc = context.getNodeData(UXDatamapHandler);
const datamapDoc = context.getNodeData(UXDMDHandler);
const databaseSchemas = context.getNodeData(DBSchemaHandler);
const backendRequirementDoc =
context.getNodeData(BackendRequirementHandler)?.overview || '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
} from 'src/build-system/errors';
import { chatSyncWithClocker } from 'src/build-system/utils/handler-helper';
import { BuildNode, BuildNodeRequire } from 'src/build-system/hanlder-manager';
import { DatabaseRequirementHandler } from '../../database/requirements-document';
import { UXDatamapHandler } from '../../ux/datamap';
import { DBRequirementHandler } from '../../database/requirements-document';
import { UXDMDHandler } from '../../ux/datamap';
import { UXSMDHandler } from '../../ux/sitemap-document';

type BackendRequirementResult = {
Expand All @@ -29,7 +29,7 @@ type BackendRequirementResult = {
*/

@BuildNode()
@BuildNodeRequire([DatabaseRequirementHandler, UXDatamapHandler, UXSMDHandler])
@BuildNodeRequire([DBRequirementHandler, UXDMDHandler, UXSMDHandler])
export class BackendRequirementHandler
implements BuildHandler<BackendRequirementResult>
{
Expand All @@ -46,8 +46,8 @@ export class BackendRequirementHandler
const projectName =
context.getGlobalContext('projectName') || 'Default Project Name';

const dbRequirements = context.getNodeData(DatabaseRequirementHandler);
const datamapDoc = context.getNodeData(UXDatamapHandler);
const dbRequirements = context.getNodeData(DBRequirementHandler);
const datamapDoc = context.getNodeData(UXDMDHandler);
const sitemapDoc = context.getNodeData(UXSMDHandler);

if (!dbRequirements || !datamapDoc || !sitemapDoc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {
ModelUnavailableError,
} from 'src/build-system/errors';
import { chatSyncWithClocker } from 'src/build-system/utils/handler-helper';
import { UXDatamapHandler } from '../../ux/datamap';
import { UXDMDHandler } from '../../ux/datamap';
import { BuildNode, BuildNodeRequire } from 'src/build-system/hanlder-manager';

@BuildNode()
@BuildNodeRequire([UXDatamapHandler])
export class DatabaseRequirementHandler implements BuildHandler<string> {
@BuildNodeRequire([UXDMDHandler])
export class DBRequirementHandler implements BuildHandler<string> {
private readonly logger = new Logger('DatabaseRequirementHandler');

async run(context: BuilderContext): Promise<BuildResult<string>> {
Expand All @@ -22,7 +22,7 @@ export class DatabaseRequirementHandler implements BuildHandler<string> {
const projectName =
context.getGlobalContext('projectName') || 'Default Project Name';

const datamapDoc = context.getNodeData(UXDatamapHandler);
const datamapDoc = context.getNodeData(UXDMDHandler);

if (!datamapDoc) {
this.logger.error('Data mapping document is missing.');
Expand All @@ -46,7 +46,7 @@ export class DatabaseRequirementHandler implements BuildHandler<string> {
messages: [{ content: prompt, role: 'system' }],
},
'generateDatabaseRequirementPrompt',
DatabaseRequirementHandler.name,
DBRequirementHandler.name,
);
} catch (error) {
throw new ModelUnavailableError('Model Unavailable:' + error);
Expand Down
Loading

0 comments on commit 36a9730

Please sign in to comment.