@furog18/shopify-admin-shared
v1.0.23
Published
Shared constants and types for Shopify Admin App
Readme
@furog18/shopify-admin-shared
This package contains shared constants and types that are used by both the backend and frontend of the Shopify Admin App.
What's Included
Constants
ORDER_STATUS- Order status constants (new, cancelled, fulfilled, rejected, in_progress)ORDER_FULFILLMENT_STATUS- Order fulfillment status constants (in_progress, ready_to_pack, ready_to_ship, courier_assigned, shipped)
Types
OrderStatus- TypeScript type for order status valuesOrderFulfillmentStatus- TypeScript type for fulfillment status values
Usage
In Backend (Node.js/TypeScript)
import { ORDER_STATUS, ORDER_FULFILLMENT_STATUS, type OrderStatus } from '@furog18/shopify-admin-shared';
// Use constants
if (order.status === ORDER_STATUS.NEW) {
// Handle new order
}
// Use types
function processOrder(status: OrderStatus) {
// Type-safe status handling
}In Frontend (React/TypeScript)
import { ORDER_STATUS, ORDER_FULFILLMENT_STATUS, type OrderStatus } from '@furog18/shopify-admin-shared';
// Use constants
const isNewOrder = order.status === ORDER_STATUS.NEW;
// Use types
interface Order {
status: OrderStatus;
fulfillment_status?: OrderFulfillmentStatus;
}Development
Building
npm run buildWatch Mode
npm run devAdding New Constants
- Add your constants to
src/constants.ts - Export them from
src/index.ts - Run
npm run buildto compile - Update both backend and frontend to use the new constants
Benefits
- Single Source of Truth: Constants are defined in one place
- Type Safety: Full TypeScript support across the entire application
- Consistency: Backend and frontend always use the same values
- Maintainability: Changes only need to be made in one location
- No Duplication: Eliminates the need to maintain separate constant files
