fix merge conflicts
This commit is contained in:
@@ -2,18 +2,32 @@ export default async (req, res) => {
|
||||
try {
|
||||
const customerService = req.scope.resolve("customerService")
|
||||
|
||||
const limit = parseInt(req.query.limit) || 10
|
||||
const limit = parseInt(req.query.limit) || 50
|
||||
const offset = parseInt(req.query.offset) || 0
|
||||
|
||||
const selector = {}
|
||||
|
||||
if ("q" in req.query) {
|
||||
selector.q = req.query.q
|
||||
}
|
||||
|
||||
let expandFields = []
|
||||
if ("expand" in req.query) {
|
||||
expandFields = req.query.expand.split(",")
|
||||
}
|
||||
|
||||
const listConfig = {
|
||||
relations: [],
|
||||
relations: expandFields.length ? expandFields : [],
|
||||
skip: offset,
|
||||
take: limit,
|
||||
}
|
||||
|
||||
const customers = await customerService.list({}, listConfig)
|
||||
const [customers, count] = await customerService.listAndCount(
|
||||
selector,
|
||||
listConfig
|
||||
)
|
||||
|
||||
res.json({ customers, count: customers.length, offset, limit })
|
||||
res.json({ customers, count, offset, limit })
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ const defaultRelations = [
|
||||
"shipping_methods",
|
||||
"payments",
|
||||
"fulfillments",
|
||||
"fulfillments.tracking_links",
|
||||
"fulfillments.items",
|
||||
"returns",
|
||||
"gift_cards",
|
||||
"gift_card_transactions",
|
||||
|
||||
@@ -23,7 +23,7 @@ export default async (req, res) => {
|
||||
await claimService.createShipment(
|
||||
claim_id,
|
||||
value.fulfillment_id,
|
||||
value.tracking_numbers
|
||||
value.tracking_numbers.map(n => ({ tracking_number: n }))
|
||||
)
|
||||
|
||||
const order = await orderService.retrieve(id, {
|
||||
|
||||
@@ -22,7 +22,7 @@ export default async (req, res) => {
|
||||
await orderService.createShipment(
|
||||
id,
|
||||
value.fulfillment_id,
|
||||
value.tracking_numbers
|
||||
value.tracking_numbers.map(n => ({ tracking_number: n }))
|
||||
)
|
||||
|
||||
const order = await orderService.retrieve(id, {
|
||||
|
||||
@@ -23,7 +23,7 @@ export default async (req, res) => {
|
||||
await swapService.createShipment(
|
||||
swap_id,
|
||||
value.fulfillment_id,
|
||||
value.tracking_numbers
|
||||
value.tracking_numbers.map(n => ({ tracking_number: n }))
|
||||
)
|
||||
|
||||
const order = await orderService.retrieve(id, {
|
||||
|
||||
@@ -188,6 +188,8 @@ export const defaultRelations = [
|
||||
"shipping_methods",
|
||||
"payments",
|
||||
"fulfillments",
|
||||
"fulfillments.tracking_links",
|
||||
"fulfillments.items",
|
||||
"returns",
|
||||
"gift_cards",
|
||||
"gift_card_transactions",
|
||||
@@ -271,6 +273,7 @@ export const allowedRelations = [
|
||||
"shipping_methods",
|
||||
"payments",
|
||||
"fulfillments",
|
||||
"fulfillments.tracking_links",
|
||||
"returns",
|
||||
"claims",
|
||||
"swaps",
|
||||
|
||||
@@ -14,13 +14,23 @@ export default async (req, res) => {
|
||||
selector.q = req.query.q
|
||||
}
|
||||
|
||||
let includeFields = []
|
||||
if ("fields" in req.query) {
|
||||
includeFields = req.query.fields.split(",")
|
||||
}
|
||||
|
||||
let expandFields = []
|
||||
if ("expand" in req.query) {
|
||||
expandFields = req.query.expand.split(",")
|
||||
}
|
||||
|
||||
if ("is_giftcard" in req.query) {
|
||||
selector.is_giftcard = req.query.is_giftcard === "true"
|
||||
}
|
||||
|
||||
const listConfig = {
|
||||
select: defaultFields,
|
||||
relations: defaultRelations,
|
||||
select: includeFields.length ? includeFields : defaultFields,
|
||||
relations: expandFields.length ? expandFields : defaultRelations,
|
||||
skip: offset,
|
||||
take: limit,
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ export default async (req, res) => {
|
||||
|
||||
const schema = Validator.object().keys({
|
||||
title: Validator.string().optional(),
|
||||
subtitle: Validator.string()
|
||||
.optional()
|
||||
.allow(null, ""),
|
||||
description: Validator.string().optional(),
|
||||
type: Validator.object()
|
||||
.keys({
|
||||
|
||||
Reference in New Issue
Block a user