Creating Workspaces
Workspaces are organizational containers that group related workflows together. They provide a structured way to organize your automations and make them accessible through the Loopstack Studio interface.
Creating a Workspace
A workspace is created by extending the Workspace base class and decorating it with @BlockConfig. Workflows are registered using the @Workflow() decorator on class properties.
Basic Workspace Definition
TypeScript
import { Injectable } from '@nestjs/common';
import { BlockConfig, Workflow } from '@loopstack/common';
import { WorkspaceBase } from '@loopstack/core';
import { MyFirstWorkflow } from './workflows/my-first-workflow';
import { DataProcessingWorkflow } from './workflows/data-processing-workflow';
@Injectable()
@BlockConfig({
config: {
title: 'Customer Analytics Workspace',
description: 'This workspace processes customer data and generates insights for the marketing team',
},
})
export class CustomerAnalyticsWorkspace extends WorkspaceBase {
// Make workflows available in the workspace
@Workflow() myFirstWorkflow: MyFirstWorkflow;
@Workflow() dataProcessingWorkflow: DataProcessingWorkflow;
}Key Components
@Injectable(): Required NestJS decorator for dependency injection@Workflow(): Decorator used to inject workflowsconfig.title: A display name for the workspaceconfig.description: A detailed explanation of the workspaceβs purpose
Using a Separate YAML File (Optional)
For consistency with other blocks or if you prefer external configuration, you can define workspace properties in a separate YAML file:
TypeScript
import { Injectable } from '@nestjs/common';
import { BlockConfig, Workflow } from '@loopstack/common';
import { WorkspaceBase } from '@loopstack/core';
import { MyFirstWorkflow } from './workflows/my-first-workflow';
import { DataProcessingWorkflow } from './workflows/data-processing-workflow';
@Injectable()
@BlockConfig({
configFile: __dirname + '/customer-analytics-workspace.yaml',
})
export class CustomerAnalyticsWorkspace extends WorkspaceBase {
@Workflow() myFirstWorkflow: MyFirstWorkflow;
@Workflow() dataProcessingWorkflow: DataProcessingWorkflow;
}Registering the Workspace
Add your workspace to your moduleβs providers to make it available:
import { Module } from '@nestjs/common';
import { LoopCoreModule } from '@loopstack/core';
import { CustomerAnalyticsWorkspace } from './customer-analytics-workspace';
@Module({
imports: [
LoopCoreModule,
],
providers: [
CustomerAnalyticsWorkspace,
// ... other providers
],
})
export class YourModule {}Using Your Workspace
Once registered, your workspace will appear in the Loopstack Studio:
- Navigate to the Workspaces section
- Create a new instance of your workspace
- Run any of the workflows included in the workspace via the Run button
Last updated on