@symanticreative/vendure-admin-client
Version:
A TypeScript GraphQL client for Vendure Admin API to create custom dashboards
69 lines • 2.65 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Injectable } from '../core/di/injectable.decorator';
import { BasePaginatedService } from './base.service';
/**
* Service for product operations
*/
let ProductService = class ProductService extends BasePaginatedService {
constructor(productRepository) {
super(productRepository);
}
/**
* Create a new product
* @param input - Product creation input
* @returns Promise resolving to the created product
*/
async createProduct(input) {
// Add any business logic, validation, or transformations here
return this.create(input);
}
/**
* Update an existing product
* @param input - Product update input
* @returns Promise resolving to the updated product
*/
async updateProduct(input) {
const { id, ...data } = input;
// Add any business logic, validation, or transformations here
return this.update(id, data);
}
/**
* Get product by slug
* @param slug - Product slug
* @returns Promise resolving to product or null
*/
async getProductBySlug(slug) {
// This would typically be implemented in the repository
// For now, we'll get all products and filter
const products = await this.getAll();
return products.find(product => product.slug === slug) || null;
}
/**
* Search products by term
* @param term - Search term
* @param options - Pagination options
* @returns Promise resolving to paginated products
*/
async searchProducts(term, options = {}) {
// Implement product search functionality
// This might require a custom repository method or GraphQL query
const searchOptions = {
...options,
filter: {
...(options.filter || {}),
name: { contains: term }
}
};
return this.getPaginated(searchOptions);
}
};
ProductService = __decorate([
Injectable()
], ProductService);
export { ProductService };
//# sourceMappingURL=product.service.js.map