@symanticreative/vendure-admin-client
Version:
A TypeScript GraphQL client for Vendure Admin API to create custom dashboards
110 lines • 3.53 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 { BasePaginatedRepository } from './base.repository';
import { GET_ORDER, GET_ORDERS, UPDATE_ORDER_STATUS } from '../graphql/orders/order.queries';
/**
* Repository for order operations
*/
let OrderRepository = class OrderRepository extends BasePaginatedRepository {
constructor(graphqlClient) {
super(graphqlClient);
}
/**
* Get the GraphQL query for finding by ID
*/
getFindByIdQuery() {
return GET_ORDER;
}
/**
* Get the GraphQL query for finding all
*/
getFindAllQuery() {
return GET_ORDERS;
}
/**
* Get the GraphQL mutation for creating
* Note: Orders are typically created through the storefront, not admin
*/
getCreateMutation() {
throw new Error('Creating orders through admin API is not supported');
}
/**
* Get the GraphQL mutation for updating
* Note: Instead of a general update, we'll use status updates
*/
getUpdateMutation() {
throw new Error('Use updateOrderStatus instead of general update');
}
/**
* Get the GraphQL mutation for deleting
* Note: Orders are typically not deleted but canceled
*/
getDeleteMutation() {
throw new Error('Deleting orders is not supported, use status transitions instead');
}
/**
* Get the GraphQL query for pagination
*/
getFindWithPaginationQuery() {
return GET_ORDERS;
}
/**
* Get the result path for finding by ID
*/
getFindByIdResultPath() {
return 'order';
}
/**
* Get the result path for finding all
*/
getFindAllResultPath() {
return 'orders.items';
}
/**
* Get the result path for creating
*/
getCreateResultPath() {
throw new Error('Creating orders through admin API is not supported');
}
/**
* Get the result path for updating
*/
getUpdateResultPath() {
throw new Error('Use updateOrderStatus instead of general update');
}
/**
* Get the result path for deleting
*/
getDeleteResultPath() {
throw new Error('Deleting orders is not supported, use status transitions instead');
}
/**
* Get the result path for pagination
*/
getFindWithPaginationResultPath() {
return 'orders';
}
/**
* Update order status
* @param input - Order status update input
* @returns Promise resolving to updated order
*/
async updateOrderStatus(input) {
const variables = {
id: input.orderId,
state: input.status
};
const result = await this.graphqlClient.mutate(UPDATE_ORDER_STATUS, variables);
return result.transitionOrderToState;
}
};
OrderRepository = __decorate([
Injectable()
], OrderRepository);
export { OrderRepository };
//# sourceMappingURL=order.repository.js.map