UNPKG

@symanticreative/vendure-admin-client

Version:

A TypeScript GraphQL client for Vendure Admin API to create custom dashboards

73 lines 2.87 kB
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 customer operations */ let CustomerService = class CustomerService extends BasePaginatedService { constructor(customerRepository) { super(customerRepository); } /** * Create a new customer * @param input - Customer creation input * @returns Promise resolving to created customer */ async createCustomer(input) { // Add any business logic, validation, or transformations here return this.create(input); } /** * Update an existing customer * @param input - Customer update input * @returns Promise resolving to updated customer */ async updateCustomer(input) { const { id, ...data } = input; // Add any business logic, validation, or transformations here return this.update(id, data); } /** * Get customer by email * @param email - Customer email * @returns Promise resolving to customer or null */ async getCustomerByEmail(email) { // This would typically be a direct repository call // For now, we'll implement it using the filter mechanism const customers = await this.getAll({ emailAddress: { eq: email } }); return customers.length > 0 ? customers[0] : null; } /** * Search customers * @param term - Search term * @param options - Pagination options * @returns Promise resolving to paginated customers */ async searchCustomers(term, options = {}) { // Search by name or email const searchOptions = { ...options, filter: { ...(options.filter || {}), // This is a simplified approach, actual implementation would depend on the API capabilities or: [ { firstName: { contains: term } }, { lastName: { contains: term } }, { emailAddress: { contains: term } } ] } }; return this.getPaginated(searchOptions); } }; CustomerService = __decorate([ Injectable() ], CustomerService); export { CustomerService }; //# sourceMappingURL=customer.service.js.map