/*
 * For any questions, contact us at: raman@worktif.com
 */

import type { PureContainer } from '@worktif/utils';

// Example services (you would import your actual services)
class ExampleService {
    async getData(id: string): Promise<{ id: string; data: string }> {
        return { id, data: `Example data for ${id}` };
    }
}

class ConfigService {
    getConfig(): { timeout: number; retries: number } {
        return { timeout: 5000, retries: 3 };
    }
}

/**
 * Example Ties Class
 *
 * Demonstrates the new object-based ties registration pattern.
 * Uses meaningful property names as container keys for type-safe dependency access.
 *
 * @example
 * ```typescript
 * const definition: MicroserviceDefinition = {
 *   ties: [ExampleTies],
 *   lambdas: [exampleHandler, multiServiceHandler]
 * };
 * ```
 */
export class ExampleTies {
    /**
     * Object-based registration using meaningful property names as keys.
     * This enables type-safe dependency access via event.ties.
     *
     * Property names here must match the property names in your handler ties objects.
     */
    static register = {
        exampleService: {
            instance: ExampleService,
            dependencies: [],
        },
        configService: {
            instance: ConfigService,
            dependencies: [],
        },
    };

    /**
     * Legacy register method for backward compatibility.
     *
     * @deprecated Use static register property for object-based ties
     * @param container - PureContainer instance
     */
    register(container: PureContainer<string>): void {
        // Register services using meaningful keys that match handler ties
        container.tie({
            ['exampleService']: {
                instance: ExampleService,
                dependencies: [],
            },
            ['configService']: {
                instance: ConfigService,
                dependencies: [],
            },
        });
    }
}
