@open-mercato/core 0.6.1-develop.3115.bc23703ef8 → 0.6.1-develop.3144.b39fb4dfa6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/catalog/api/dictionaries/[key]/route.js +2 -2
- package/dist/modules/catalog/api/dictionaries/[key]/route.js.map +2 -2
- package/dist/modules/customers/api/activities/route.js +5 -5
- package/dist/modules/customers/api/activities/route.js.map +2 -2
- package/dist/modules/customers/api/assignable-staff/route.js +2 -2
- package/dist/modules/customers/api/assignable-staff/route.js.map +2 -2
- package/dist/modules/customers/api/companies/[id]/people/route.js +2 -2
- package/dist/modules/customers/api/companies/[id]/people/route.js.map +2 -2
- package/dist/modules/customers/api/dashboard/widgets/customer-todos/route.js +2 -2
- package/dist/modules/customers/api/dashboard/widgets/customer-todos/route.js.map +2 -2
- package/dist/modules/customers/api/dashboard/widgets/new-customers/route.js +2 -2
- package/dist/modules/customers/api/dashboard/widgets/new-customers/route.js.map +2 -2
- package/dist/modules/customers/api/dashboard/widgets/new-deals/route.js +2 -2
- package/dist/modules/customers/api/dashboard/widgets/new-deals/route.js.map +2 -2
- package/dist/modules/customers/api/dashboard/widgets/next-interactions/route.js +2 -2
- package/dist/modules/customers/api/dashboard/widgets/next-interactions/route.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/companies/route.js +2 -2
- package/dist/modules/customers/api/deals/[id]/companies/route.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/people/route.js +2 -2
- package/dist/modules/customers/api/deals/[id]/people/route.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js +6 -6
- package/dist/modules/customers/api/dictionaries/[kind]/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/[kind]/route.js +3 -3
- package/dist/modules/customers/api/dictionaries/[kind]/route.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/currency/route.js +2 -2
- package/dist/modules/customers/api/dictionaries/currency/route.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/kind-settings/route.js +3 -3
- package/dist/modules/customers/api/dictionaries/kind-settings/route.js.map +2 -2
- package/dist/modules/customers/api/entity-roles-factory.js +5 -5
- package/dist/modules/customers/api/entity-roles-factory.js.map +2 -2
- package/dist/modules/customers/api/interactions/cancel/route.js +2 -2
- package/dist/modules/customers/api/interactions/cancel/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/complete/route.js +2 -2
- package/dist/modules/customers/api/interactions/complete/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/conflicts/route.js +2 -2
- package/dist/modules/customers/api/interactions/conflicts/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/counts/route.js +2 -2
- package/dist/modules/customers/api/interactions/counts/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/route.js +2 -2
- package/dist/modules/customers/api/interactions/route.js.map +2 -2
- package/dist/modules/customers/api/interactions/tasks/route.js +2 -2
- package/dist/modules/customers/api/interactions/tasks/route.js.map +2 -2
- package/dist/modules/customers/api/labels/assign/route.js +2 -2
- package/dist/modules/customers/api/labels/assign/route.js.map +2 -2
- package/dist/modules/customers/api/labels/route.js +3 -3
- package/dist/modules/customers/api/labels/route.js.map +2 -2
- package/dist/modules/customers/api/labels/unassign/route.js +2 -2
- package/dist/modules/customers/api/labels/unassign/route.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js +3 -3
- package/dist/modules/customers/api/people/[id]/companies/[linkId]/route.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/companies/enriched/route.js +2 -2
- package/dist/modules/customers/api/people/[id]/companies/enriched/route.js.map +2 -2
- package/dist/modules/customers/api/people/[id]/companies/route.js +3 -3
- package/dist/modules/customers/api/people/[id]/companies/route.js.map +2 -2
- package/dist/modules/customers/api/pipeline-stages/reorder/route.js +2 -2
- package/dist/modules/customers/api/pipeline-stages/reorder/route.js.map +2 -2
- package/dist/modules/customers/api/pipeline-stages/route.js +5 -5
- package/dist/modules/customers/api/pipeline-stages/route.js.map +2 -2
- package/dist/modules/customers/api/pipelines/route.js +5 -5
- package/dist/modules/customers/api/pipelines/route.js.map +2 -2
- package/dist/modules/customers/api/settings/address-format/route.js +3 -3
- package/dist/modules/customers/api/settings/address-format/route.js.map +2 -2
- package/dist/modules/customers/api/tags/assign/route.js +2 -2
- package/dist/modules/customers/api/tags/assign/route.js.map +2 -2
- package/dist/modules/customers/api/tags/unassign/route.js +2 -2
- package/dist/modules/customers/api/tags/unassign/route.js.map +2 -2
- package/dist/modules/customers/api/todos/route.js +5 -5
- package/dist/modules/customers/api/todos/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js +3 -3
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/reorder/route.js +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/reorder/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js +3 -3
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/set-default/route.js +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/set-default/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/route.js +4 -4
- package/dist/modules/dictionaries/api/[dictionaryId]/route.js.map +2 -2
- package/dist/modules/dictionaries/api/route.js +3 -3
- package/dist/modules/dictionaries/api/route.js.map +2 -2
- package/dist/modules/feature_toggles/api/overrides/route.js +2 -2
- package/dist/modules/feature_toggles/api/overrides/route.js.map +2 -2
- package/dist/modules/planner/api/availability-date-specific.js +2 -2
- package/dist/modules/planner/api/availability-date-specific.js.map +2 -2
- package/dist/modules/planner/api/availability-weekly.js +2 -2
- package/dist/modules/planner/api/availability-weekly.js.map +2 -2
- package/dist/modules/resources/api/resources/tags/assign/route.js +2 -2
- package/dist/modules/resources/api/resources/tags/assign/route.js.map +2 -2
- package/dist/modules/resources/api/resources/tags/unassign/route.js +2 -2
- package/dist/modules/resources/api/resources/tags/unassign/route.js.map +2 -2
- package/dist/modules/sales/api/document-history/route.js +2 -2
- package/dist/modules/sales/api/document-history/route.js.map +2 -2
- package/dist/modules/sales/api/document-numbers/route.js +2 -2
- package/dist/modules/sales/api/document-numbers/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/accept/route.js +2 -2
- package/dist/modules/sales/api/quotes/accept/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/convert/route.js +2 -2
- package/dist/modules/sales/api/quotes/convert/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/public/[token]/route.js +2 -2
- package/dist/modules/sales/api/quotes/public/[token]/route.js.map +2 -2
- package/dist/modules/sales/api/quotes/send/route.js +2 -2
- package/dist/modules/sales/api/quotes/send/route.js.map +2 -2
- package/dist/modules/sales/api/returns/[id]/route.js +2 -2
- package/dist/modules/sales/api/returns/[id]/route.js.map +2 -2
- package/dist/modules/sales/api/settings/document-numbers/route.js +3 -3
- package/dist/modules/sales/api/settings/document-numbers/route.js.map +2 -2
- package/dist/modules/sales/api/settings/order-editing/route.js +3 -3
- package/dist/modules/sales/api/settings/order-editing/route.js.map +2 -2
- package/dist/modules/sales/widgets/dashboard/makeDashboardWidgetRoute.js +2 -2
- package/dist/modules/sales/widgets/dashboard/makeDashboardWidgetRoute.js.map +2 -2
- package/dist/modules/staff/api/leave-requests/accept/route.js +2 -2
- package/dist/modules/staff/api/leave-requests/accept/route.js.map +2 -2
- package/dist/modules/staff/api/leave-requests/reject/route.js +2 -2
- package/dist/modules/staff/api/leave-requests/reject/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/self/route.js +3 -3
- package/dist/modules/staff/api/team-members/self/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/tags/assign/route.js +2 -2
- package/dist/modules/staff/api/team-members/tags/assign/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/tags/unassign/route.js +2 -2
- package/dist/modules/staff/api/team-members/tags/unassign/route.js.map +2 -2
- package/dist/modules/translations/api/[entityType]/[entityId]/route.js +4 -4
- package/dist/modules/translations/api/[entityType]/[entityId]/route.js.map +2 -2
- package/dist/modules/translations/api/get/locales.js +2 -2
- package/dist/modules/translations/api/get/locales.js.map +2 -2
- package/dist/modules/translations/api/put/locales.js +2 -2
- package/dist/modules/translations/api/put/locales.js.map +2 -2
- package/package.json +5 -5
- package/src/modules/catalog/api/dictionaries/[key]/route.ts +2 -2
- package/src/modules/customers/api/activities/route.ts +5 -5
- package/src/modules/customers/api/assignable-staff/route.ts +2 -2
- package/src/modules/customers/api/companies/[id]/people/route.ts +2 -2
- package/src/modules/customers/api/dashboard/widgets/customer-todos/route.ts +2 -2
- package/src/modules/customers/api/dashboard/widgets/new-customers/route.ts +2 -2
- package/src/modules/customers/api/dashboard/widgets/new-deals/route.ts +2 -2
- package/src/modules/customers/api/dashboard/widgets/next-interactions/route.ts +2 -2
- package/src/modules/customers/api/deals/[id]/companies/route.ts +2 -2
- package/src/modules/customers/api/deals/[id]/people/route.ts +2 -2
- package/src/modules/customers/api/dictionaries/[kind]/[id]/route.ts +6 -6
- package/src/modules/customers/api/dictionaries/[kind]/route.ts +3 -3
- package/src/modules/customers/api/dictionaries/currency/route.ts +2 -2
- package/src/modules/customers/api/dictionaries/kind-settings/route.ts +3 -3
- package/src/modules/customers/api/entity-roles-factory.ts +5 -5
- package/src/modules/customers/api/interactions/cancel/route.ts +2 -2
- package/src/modules/customers/api/interactions/complete/route.ts +2 -2
- package/src/modules/customers/api/interactions/conflicts/route.ts +2 -2
- package/src/modules/customers/api/interactions/counts/route.ts +2 -2
- package/src/modules/customers/api/interactions/route.ts +2 -2
- package/src/modules/customers/api/interactions/tasks/route.ts +2 -2
- package/src/modules/customers/api/labels/assign/route.ts +2 -2
- package/src/modules/customers/api/labels/route.ts +3 -3
- package/src/modules/customers/api/labels/unassign/route.ts +2 -2
- package/src/modules/customers/api/people/[id]/companies/[linkId]/route.ts +3 -3
- package/src/modules/customers/api/people/[id]/companies/enriched/route.ts +2 -2
- package/src/modules/customers/api/people/[id]/companies/route.ts +3 -3
- package/src/modules/customers/api/pipeline-stages/reorder/route.ts +2 -2
- package/src/modules/customers/api/pipeline-stages/route.ts +5 -5
- package/src/modules/customers/api/pipelines/route.ts +5 -5
- package/src/modules/customers/api/settings/address-format/route.ts +3 -3
- package/src/modules/customers/api/tags/assign/route.ts +2 -2
- package/src/modules/customers/api/tags/unassign/route.ts +2 -2
- package/src/modules/customers/api/todos/route.ts +5 -5
- package/src/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.ts +3 -3
- package/src/modules/dictionaries/api/[dictionaryId]/entries/reorder/route.ts +2 -2
- package/src/modules/dictionaries/api/[dictionaryId]/entries/route.ts +3 -3
- package/src/modules/dictionaries/api/[dictionaryId]/entries/set-default/route.ts +2 -2
- package/src/modules/dictionaries/api/[dictionaryId]/route.ts +4 -4
- package/src/modules/dictionaries/api/route.ts +3 -3
- package/src/modules/feature_toggles/api/overrides/route.ts +2 -2
- package/src/modules/planner/api/availability-date-specific.ts +2 -2
- package/src/modules/planner/api/availability-weekly.ts +2 -2
- package/src/modules/resources/api/resources/tags/assign/route.ts +2 -2
- package/src/modules/resources/api/resources/tags/unassign/route.ts +2 -2
- package/src/modules/sales/api/document-history/route.ts +2 -2
- package/src/modules/sales/api/document-numbers/route.ts +2 -2
- package/src/modules/sales/api/quotes/accept/route.ts +2 -2
- package/src/modules/sales/api/quotes/convert/route.ts +2 -2
- package/src/modules/sales/api/quotes/public/[token]/route.ts +2 -2
- package/src/modules/sales/api/quotes/send/route.ts +2 -2
- package/src/modules/sales/api/returns/[id]/route.ts +2 -2
- package/src/modules/sales/api/settings/document-numbers/route.ts +3 -3
- package/src/modules/sales/api/settings/order-editing/route.ts +3 -3
- package/src/modules/sales/widgets/dashboard/makeDashboardWidgetRoute.ts +2 -2
- package/src/modules/staff/api/leave-requests/accept/route.ts +2 -2
- package/src/modules/staff/api/leave-requests/reject/route.ts +2 -2
- package/src/modules/staff/api/team-members/self/route.ts +3 -3
- package/src/modules/staff/api/team-members/tags/assign/route.ts +2 -2
- package/src/modules/staff/api/team-members/tags/unassign/route.ts +2 -2
- package/src/modules/translations/api/[entityType]/[entityId]/route.ts +4 -4
- package/src/modules/translations/api/get/locales.ts +2 -2
- package/src/modules/translations/api/put/locales.ts +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
3
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
3
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
4
4
|
import type { CommandBus } from '@open-mercato/shared/lib/commands'
|
|
5
5
|
import type { CommandExecuteResult } from '@open-mercato/shared/lib/commands/types'
|
|
6
6
|
import { serializeOperationMetadata } from '@open-mercato/shared/lib/commands/operationMetadata'
|
|
@@ -190,7 +190,7 @@ export async function GET(req: Request, ctx: { params?: { kind?: string } }) {
|
|
|
190
190
|
|
|
191
191
|
return NextResponse.json(responseBody)
|
|
192
192
|
} catch (err) {
|
|
193
|
-
if (err
|
|
193
|
+
if (isCrudHttpError(err)) {
|
|
194
194
|
return NextResponse.json(err.body, { status: err.status })
|
|
195
195
|
}
|
|
196
196
|
const { translate } = await resolveTranslations()
|
|
@@ -289,7 +289,7 @@ export async function POST(req: Request, ctx: { params?: { kind?: string } }) {
|
|
|
289
289
|
}
|
|
290
290
|
return response
|
|
291
291
|
} catch (err) {
|
|
292
|
-
if (err
|
|
292
|
+
if (isCrudHttpError(err)) {
|
|
293
293
|
return NextResponse.json(err.body, { status: err.status })
|
|
294
294
|
}
|
|
295
295
|
const { translate } = await resolveTranslations()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
import { Dictionary, DictionaryEntry } from '@open-mercato/core/modules/dictionaries/data/entities'
|
|
4
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
4
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
5
5
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
6
6
|
|
|
7
7
|
export const metadata = {
|
|
@@ -62,7 +62,7 @@ export async function GET(req: Request) {
|
|
|
62
62
|
})),
|
|
63
63
|
})
|
|
64
64
|
} catch (err) {
|
|
65
|
-
if (err
|
|
65
|
+
if (isCrudHttpError(err)) {
|
|
66
66
|
return NextResponse.json(err.body, { status: err.status })
|
|
67
67
|
}
|
|
68
68
|
console.error('[customers.currencyDictionary.GET] Unexpected error', err)
|
|
@@ -3,7 +3,7 @@ import { z } from 'zod'
|
|
|
3
3
|
import { TableNotFoundException } from '@mikro-orm/core'
|
|
4
4
|
import { CustomerDictionaryKindSetting } from '../../../data/entities'
|
|
5
5
|
import { resolveDictionaryRouteContext } from '../context'
|
|
6
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
6
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
7
7
|
import { findWithDecryption } from '@open-mercato/shared/lib/encryption/find'
|
|
8
8
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
9
9
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
@@ -79,7 +79,7 @@ export async function GET(req: Request) {
|
|
|
79
79
|
if (isMissingKindSettingsTable(err)) {
|
|
80
80
|
return NextResponse.json({ items: [] })
|
|
81
81
|
}
|
|
82
|
-
if (err
|
|
82
|
+
if (isCrudHttpError(err)) {
|
|
83
83
|
return NextResponse.json(err.body, { status: err.status })
|
|
84
84
|
}
|
|
85
85
|
console.error('[customers/dictionaries/kind-settings.GET]', err)
|
|
@@ -180,7 +180,7 @@ export async function PATCH(req: Request) {
|
|
|
180
180
|
}
|
|
181
181
|
return response
|
|
182
182
|
} catch (err) {
|
|
183
|
-
if (err
|
|
183
|
+
if (isCrudHttpError(err)) {
|
|
184
184
|
return NextResponse.json(err.body, { status: err.status })
|
|
185
185
|
}
|
|
186
186
|
console.error('[customers/dictionaries/kind-settings.PATCH]', err)
|
|
@@ -4,7 +4,7 @@ import type { CommandBus } from '@open-mercato/shared/lib/commands'
|
|
|
4
4
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
5
5
|
import { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'
|
|
6
6
|
import { validateCrudMutationGuard, runCrudMutationGuardAfterSuccess } from '@open-mercato/shared/lib/crud/mutation-guard'
|
|
7
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
7
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
8
8
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
9
9
|
import { findOneWithDecryption, findWithDecryption } from '@open-mercato/shared/lib/encryption/find'
|
|
10
10
|
import { User } from '@open-mercato/core/modules/auth/data/entities'
|
|
@@ -318,7 +318,7 @@ export function createEntityRolesHandlers(entityType: EntityType) {
|
|
|
318
318
|
})),
|
|
319
319
|
})
|
|
320
320
|
} catch (err) {
|
|
321
|
-
if (err
|
|
321
|
+
if (isCrudHttpError(err)) return NextResponse.json(err.body, { status: err.status })
|
|
322
322
|
if (err instanceof z.ZodError) return buildValidationErrorResponse(err, translate)
|
|
323
323
|
console.error(`${logPrefix}.get failed`, err)
|
|
324
324
|
return NextResponse.json({ error: translate('customers.errors.failed_to_load_roles', 'Failed to load roles') }, { status: 500 })
|
|
@@ -375,7 +375,7 @@ export function createEntityRolesHandlers(entityType: EntityType) {
|
|
|
375
375
|
{ resourceKind, resourceId: entityId },
|
|
376
376
|
)
|
|
377
377
|
} catch (err) {
|
|
378
|
-
if (err
|
|
378
|
+
if (isCrudHttpError(err)) return NextResponse.json(err.body, { status: err.status })
|
|
379
379
|
if (err instanceof z.ZodError) return buildValidationErrorResponse(err, translate)
|
|
380
380
|
console.error(`${logPrefix}.post failed`, err)
|
|
381
381
|
return NextResponse.json({ error: translate('customers.errors.failed_to_assign_role', 'Failed to assign role') }, { status: 500 })
|
|
@@ -433,7 +433,7 @@ export function createEntityRolesHandlers(entityType: EntityType) {
|
|
|
433
433
|
{ resourceKind, resourceId: entityId },
|
|
434
434
|
)
|
|
435
435
|
} catch (err) {
|
|
436
|
-
if (err
|
|
436
|
+
if (isCrudHttpError(err)) return NextResponse.json(err.body, { status: err.status })
|
|
437
437
|
if (err instanceof z.ZodError) return buildValidationErrorResponse(err, translate)
|
|
438
438
|
console.error(`${logPrefix}.put failed`, err)
|
|
439
439
|
return NextResponse.json({ error: translate('customers.errors.failed_to_update_role', 'Failed to update role') }, { status: 500 })
|
|
@@ -489,7 +489,7 @@ export function createEntityRolesHandlers(entityType: EntityType) {
|
|
|
489
489
|
{ resourceKind, resourceId: entityId },
|
|
490
490
|
)
|
|
491
491
|
} catch (err) {
|
|
492
|
-
if (err
|
|
492
|
+
if (isCrudHttpError(err)) return NextResponse.json(err.body, { status: err.status })
|
|
493
493
|
if (err instanceof z.ZodError) return buildValidationErrorResponse(err, translate)
|
|
494
494
|
console.error(`${logPrefix}.delete failed`, err)
|
|
495
495
|
return NextResponse.json({ error: translate('customers.errors.failed_to_delete_role', 'Failed to delete role') }, { status: 500 })
|
|
@@ -5,7 +5,7 @@ import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
|
5
5
|
import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'
|
|
6
6
|
import type { CommandRuntimeContext, CommandBus } from '@open-mercato/shared/lib/commands'
|
|
7
7
|
import { interactionCancelSchema, type InteractionCancelInput } from '../../../data/validators'
|
|
8
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
8
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
9
9
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
10
10
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
11
11
|
import { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'
|
|
@@ -80,7 +80,7 @@ export async function POST(req: Request) {
|
|
|
80
80
|
{ resourceKind: 'customers.interaction', resourceId: parsed.id },
|
|
81
81
|
)
|
|
82
82
|
} catch (err) {
|
|
83
|
-
if (err
|
|
83
|
+
if (isCrudHttpError(err)) {
|
|
84
84
|
return NextResponse.json(err.body, { status: err.status })
|
|
85
85
|
}
|
|
86
86
|
if (err instanceof z.ZodError) {
|
|
@@ -5,7 +5,7 @@ import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
|
5
5
|
import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'
|
|
6
6
|
import type { CommandRuntimeContext, CommandBus } from '@open-mercato/shared/lib/commands'
|
|
7
7
|
import { interactionCompleteSchema, type InteractionCompleteInput } from '../../../data/validators'
|
|
8
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
8
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
9
9
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
10
10
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
11
11
|
import { readJsonSafe } from '@open-mercato/shared/lib/http/readJsonSafe'
|
|
@@ -80,7 +80,7 @@ export async function POST(req: Request) {
|
|
|
80
80
|
{ resourceKind: 'customers.interaction', resourceId: parsed.id },
|
|
81
81
|
)
|
|
82
82
|
} catch (err) {
|
|
83
|
-
if (err
|
|
83
|
+
if (isCrudHttpError(err)) {
|
|
84
84
|
return NextResponse.json(err.body, { status: err.status })
|
|
85
85
|
}
|
|
86
86
|
if (err instanceof z.ZodError) {
|
|
@@ -2,7 +2,7 @@ import { NextResponse } from 'next/server'
|
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
4
4
|
import { sql } from 'kysely'
|
|
5
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
5
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
6
6
|
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
7
7
|
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
8
8
|
import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'
|
|
@@ -190,7 +190,7 @@ export async function GET(req: Request) {
|
|
|
190
190
|
result: { hasConflicts: conflicts.length > 0, conflicts },
|
|
191
191
|
})
|
|
192
192
|
} catch (err) {
|
|
193
|
-
if (err
|
|
193
|
+
if (isCrudHttpError(err)) {
|
|
194
194
|
return NextResponse.json(err.body, { status: err.status })
|
|
195
195
|
}
|
|
196
196
|
console.error('[customers/interactions/conflicts] GET failed', err)
|
|
@@ -2,7 +2,7 @@ import { NextResponse } from 'next/server'
|
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
4
4
|
import { sql } from 'kysely'
|
|
5
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
5
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
6
6
|
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
7
7
|
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
8
8
|
import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'
|
|
@@ -106,7 +106,7 @@ export async function GET(req: Request) {
|
|
|
106
106
|
|
|
107
107
|
return NextResponse.json({ ok: true, result: { ...counts, total } })
|
|
108
108
|
} catch (err) {
|
|
109
|
-
if (err
|
|
109
|
+
if (isCrudHttpError(err)) {
|
|
110
110
|
return NextResponse.json(err.body, { status: err.status })
|
|
111
111
|
}
|
|
112
112
|
console.error('[customers/interactions/counts] GET failed', err)
|
|
@@ -3,7 +3,7 @@ import { z } from 'zod'
|
|
|
3
3
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
4
4
|
import { sql } from 'kysely'
|
|
5
5
|
import { makeCrudRoute } from '@open-mercato/shared/lib/crud/factory'
|
|
6
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
6
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
7
7
|
import { loadCustomFieldValues } from '@open-mercato/shared/lib/crud/custom-fields'
|
|
8
8
|
import { normalizeCustomFieldResponse } from '@open-mercato/shared/lib/custom-fields/normalize'
|
|
9
9
|
import { applyResponseEnrichers } from '@open-mercato/shared/lib/crud/enricher-runner'
|
|
@@ -543,7 +543,7 @@ export async function GET(req: Request) {
|
|
|
543
543
|
nextCursor,
|
|
544
544
|
})
|
|
545
545
|
} catch (err) {
|
|
546
|
-
if (err
|
|
546
|
+
if (isCrudHttpError(err)) {
|
|
547
547
|
return NextResponse.json(err.body, { status: err.status })
|
|
548
548
|
}
|
|
549
549
|
if (err instanceof z.ZodError) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
4
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
4
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
5
5
|
import { parseBooleanToken } from '@open-mercato/shared/lib/boolean'
|
|
6
6
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
7
7
|
import type { QueryEngine } from '@open-mercato/shared/lib/query/types'
|
|
@@ -108,7 +108,7 @@ export async function GET(request: Request): Promise<Response> {
|
|
|
108
108
|
totalPages: paged.totalPages,
|
|
109
109
|
})
|
|
110
110
|
} catch (err) {
|
|
111
|
-
if (err
|
|
111
|
+
if (isCrudHttpError(err)) {
|
|
112
112
|
return NextResponse.json(err.body, { status: err.status })
|
|
113
113
|
}
|
|
114
114
|
if (err instanceof z.ZodError) {
|
|
@@ -4,7 +4,7 @@ import { labelAssignCommandSchema, labelAssignmentSchema, type LabelAssignComman
|
|
|
4
4
|
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
5
5
|
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
6
6
|
import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'
|
|
7
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
7
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
8
8
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
9
9
|
import type { CommandBus } from '@open-mercato/shared/lib/commands'
|
|
10
10
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
@@ -168,7 +168,7 @@ export async function POST(req: Request) {
|
|
|
168
168
|
const migrationError = await createMissingCustomerLabelTablesError()
|
|
169
169
|
return NextResponse.json(migrationError.body, { status: migrationError.status })
|
|
170
170
|
}
|
|
171
|
-
if (err
|
|
171
|
+
if (isCrudHttpError(err)) {
|
|
172
172
|
return NextResponse.json(err.body, { status: err.status })
|
|
173
173
|
}
|
|
174
174
|
console.error('[customers/labels/assign.POST]', err)
|
|
@@ -5,7 +5,7 @@ import { labelCreateCommandSchema, labelCreateSchema, type LabelCreateCommandInp
|
|
|
5
5
|
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
6
6
|
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
7
7
|
import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'
|
|
8
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
8
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
9
9
|
import type { EntityManager, FilterQuery } from '@mikro-orm/postgresql'
|
|
10
10
|
import type { CommandBus } from '@open-mercato/shared/lib/commands'
|
|
11
11
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
@@ -139,7 +139,7 @@ export async function GET(req: Request) {
|
|
|
139
139
|
if (isMissingCustomerLabelTable(err)) {
|
|
140
140
|
return NextResponse.json({ items: [], assignedIds: [] })
|
|
141
141
|
}
|
|
142
|
-
if (err
|
|
142
|
+
if (isCrudHttpError(err)) {
|
|
143
143
|
return NextResponse.json(err.body, { status: err.status })
|
|
144
144
|
}
|
|
145
145
|
console.error('[customers/labels.GET]', err)
|
|
@@ -256,7 +256,7 @@ export async function POST(req: Request) {
|
|
|
256
256
|
const migrationError = await createMissingCustomerLabelTablesError()
|
|
257
257
|
return NextResponse.json(migrationError.body, { status: migrationError.status })
|
|
258
258
|
}
|
|
259
|
-
if (err
|
|
259
|
+
if (isCrudHttpError(err)) {
|
|
260
260
|
return NextResponse.json(err.body, { status: err.status })
|
|
261
261
|
}
|
|
262
262
|
console.error('[customers/labels.POST]', err)
|
|
@@ -4,7 +4,7 @@ import { labelUnassignCommandSchema, labelAssignmentSchema, type LabelUnassignCo
|
|
|
4
4
|
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
5
5
|
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
6
6
|
import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'
|
|
7
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
7
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
8
8
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
9
9
|
import type { CommandBus } from '@open-mercato/shared/lib/commands'
|
|
10
10
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
@@ -168,7 +168,7 @@ export async function POST(req: Request) {
|
|
|
168
168
|
const migrationError = await createMissingCustomerLabelTablesError()
|
|
169
169
|
return NextResponse.json(migrationError.body, { status: migrationError.status })
|
|
170
170
|
}
|
|
171
|
-
if (err
|
|
171
|
+
if (isCrudHttpError(err)) {
|
|
172
172
|
return NextResponse.json(err.body, { status: err.status })
|
|
173
173
|
}
|
|
174
174
|
console.error('[customers/labels/unassign.POST]', err)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { z } from 'zod'
|
|
3
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
3
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
4
4
|
import {
|
|
5
5
|
runCrudMutationGuardAfterSuccess,
|
|
6
6
|
validateCrudMutationGuard,
|
|
@@ -225,7 +225,7 @@ export async function PATCH(req: Request, ctx: { params?: { id?: string; linkId?
|
|
|
225
225
|
}
|
|
226
226
|
return response
|
|
227
227
|
} catch (err) {
|
|
228
|
-
if (err
|
|
228
|
+
if (isCrudHttpError(err)) {
|
|
229
229
|
return NextResponse.json(err.body, { status: err.status })
|
|
230
230
|
}
|
|
231
231
|
return NextResponse.json({ error: translate('customers.errors.internal', 'Internal server error') }, { status: 500 })
|
|
@@ -323,7 +323,7 @@ export async function DELETE(req: Request, ctx: { params?: { id?: string; linkId
|
|
|
323
323
|
}
|
|
324
324
|
return response
|
|
325
325
|
} catch (err) {
|
|
326
|
-
if (err
|
|
326
|
+
if (isCrudHttpError(err)) {
|
|
327
327
|
return NextResponse.json(err.body, { status: err.status })
|
|
328
328
|
}
|
|
329
329
|
return NextResponse.json({ error: translate('customers.errors.internal', 'Internal server error') }, { status: 500 })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
4
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
4
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
5
5
|
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
6
6
|
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
7
7
|
import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'
|
|
@@ -380,7 +380,7 @@ export async function GET(req: Request, ctx: { params?: { id?: string } }) {
|
|
|
380
380
|
totalPages,
|
|
381
381
|
})
|
|
382
382
|
} catch (err) {
|
|
383
|
-
if (err
|
|
383
|
+
if (isCrudHttpError(err)) {
|
|
384
384
|
return NextResponse.json(err.body, { status: err.status })
|
|
385
385
|
}
|
|
386
386
|
console.error('[customers/people/[id]/companies/enriched] GET failed', err)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { z } from 'zod'
|
|
3
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
3
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
4
4
|
import {
|
|
5
5
|
runCrudMutationGuardAfterSuccess,
|
|
6
6
|
validateCrudMutationGuard,
|
|
@@ -91,7 +91,7 @@ export async function GET(req: Request, ctx: { params?: { id?: string } }) {
|
|
|
91
91
|
}))
|
|
92
92
|
return NextResponse.json({ items })
|
|
93
93
|
} catch (err) {
|
|
94
|
-
if (err
|
|
94
|
+
if (isCrudHttpError(err)) {
|
|
95
95
|
return NextResponse.json(err.body, { status: err.status })
|
|
96
96
|
}
|
|
97
97
|
return NextResponse.json({ error: translate('customers.errors.internal', 'Internal server error') }, { status: 500 })
|
|
@@ -207,7 +207,7 @@ export async function POST(req: Request, ctx: { params?: { id?: string } }) {
|
|
|
207
207
|
}
|
|
208
208
|
return response
|
|
209
209
|
} catch (err) {
|
|
210
|
-
if (err
|
|
210
|
+
if (isCrudHttpError(err)) {
|
|
211
211
|
return NextResponse.json(err.body, { status: err.status })
|
|
212
212
|
}
|
|
213
213
|
return NextResponse.json({ error: translate('customers.errors.internal', 'Internal server error') }, { status: 500 })
|
|
@@ -6,7 +6,7 @@ import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/d
|
|
|
6
6
|
import type { CommandRuntimeContext, CommandBus } from '@open-mercato/shared/lib/commands'
|
|
7
7
|
import { pipelineStageReorderSchema, type PipelineStageReorderInput } from '../../../data/validators'
|
|
8
8
|
import { withScopedPayload } from '../../utils'
|
|
9
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
9
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
10
10
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
11
11
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
12
12
|
|
|
@@ -40,7 +40,7 @@ export async function POST(req: Request) {
|
|
|
40
40
|
)
|
|
41
41
|
return NextResponse.json({ ok: true })
|
|
42
42
|
} catch (err) {
|
|
43
|
-
if (err
|
|
43
|
+
if (isCrudHttpError(err)) {
|
|
44
44
|
return NextResponse.json(err.body, { status: err.status })
|
|
45
45
|
}
|
|
46
46
|
console.error('customers.pipeline-stages.reorder failed', err)
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from '../../data/validators'
|
|
17
17
|
import { withScopedPayload } from '../utils'
|
|
18
18
|
import { ensureDictionaryEntry } from '../../commands/shared'
|
|
19
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
19
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
20
20
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
21
21
|
import { serializeOperationMetadata } from '@open-mercato/shared/lib/commands/operationMetadata'
|
|
22
22
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
@@ -106,7 +106,7 @@ export async function GET(req: Request) {
|
|
|
106
106
|
})
|
|
107
107
|
return NextResponse.json({ items, total: items.length })
|
|
108
108
|
} catch (err) {
|
|
109
|
-
if (err
|
|
109
|
+
if (isCrudHttpError(err)) {
|
|
110
110
|
return NextResponse.json(err.body, { status: err.status })
|
|
111
111
|
}
|
|
112
112
|
console.error('customers.pipeline-stages GET failed', err)
|
|
@@ -143,7 +143,7 @@ export async function POST(req: Request) {
|
|
|
143
143
|
}
|
|
144
144
|
return response
|
|
145
145
|
} catch (err) {
|
|
146
|
-
if (err
|
|
146
|
+
if (isCrudHttpError(err)) {
|
|
147
147
|
return NextResponse.json(err.body, { status: err.status })
|
|
148
148
|
}
|
|
149
149
|
console.error('customers.pipeline-stages POST failed', err)
|
|
@@ -180,7 +180,7 @@ export async function PUT(req: Request) {
|
|
|
180
180
|
}
|
|
181
181
|
return response
|
|
182
182
|
} catch (err) {
|
|
183
|
-
if (err
|
|
183
|
+
if (isCrudHttpError(err)) {
|
|
184
184
|
return NextResponse.json(err.body, { status: err.status })
|
|
185
185
|
}
|
|
186
186
|
console.error('customers.pipeline-stages PUT failed', err)
|
|
@@ -202,7 +202,7 @@ export async function DELETE(req: Request) {
|
|
|
202
202
|
)
|
|
203
203
|
return NextResponse.json({ ok: true })
|
|
204
204
|
} catch (err) {
|
|
205
|
-
if (err
|
|
205
|
+
if (isCrudHttpError(err)) {
|
|
206
206
|
return NextResponse.json(err.body, { status: err.status })
|
|
207
207
|
}
|
|
208
208
|
console.error('customers.pipeline-stages DELETE failed', err)
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
type PipelineDeleteInput,
|
|
16
16
|
} from '../../data/validators'
|
|
17
17
|
import { withScopedPayload } from '../utils'
|
|
18
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
18
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
19
19
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
20
20
|
import { serializeOperationMetadata } from '@open-mercato/shared/lib/commands/operationMetadata'
|
|
21
21
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
@@ -74,7 +74,7 @@ export async function GET(req: Request) {
|
|
|
74
74
|
}))
|
|
75
75
|
return NextResponse.json({ items, total: items.length })
|
|
76
76
|
} catch (err) {
|
|
77
|
-
if (err
|
|
77
|
+
if (isCrudHttpError(err)) {
|
|
78
78
|
return NextResponse.json(err.body, { status: err.status })
|
|
79
79
|
}
|
|
80
80
|
console.error('customers.pipelines GET failed', err)
|
|
@@ -111,7 +111,7 @@ export async function POST(req: Request) {
|
|
|
111
111
|
}
|
|
112
112
|
return response
|
|
113
113
|
} catch (err) {
|
|
114
|
-
if (err
|
|
114
|
+
if (isCrudHttpError(err)) {
|
|
115
115
|
return NextResponse.json(err.body, { status: err.status })
|
|
116
116
|
}
|
|
117
117
|
console.error('customers.pipelines POST failed', err)
|
|
@@ -148,7 +148,7 @@ export async function PUT(req: Request) {
|
|
|
148
148
|
}
|
|
149
149
|
return response
|
|
150
150
|
} catch (err) {
|
|
151
|
-
if (err
|
|
151
|
+
if (isCrudHttpError(err)) {
|
|
152
152
|
return NextResponse.json(err.body, { status: err.status })
|
|
153
153
|
}
|
|
154
154
|
console.error('customers.pipelines PUT failed', err)
|
|
@@ -170,7 +170,7 @@ export async function DELETE(req: Request) {
|
|
|
170
170
|
)
|
|
171
171
|
return NextResponse.json({ ok: true })
|
|
172
172
|
} catch (err) {
|
|
173
|
-
if (err
|
|
173
|
+
if (isCrudHttpError(err)) {
|
|
174
174
|
return NextResponse.json(err.body, { status: err.status })
|
|
175
175
|
}
|
|
176
176
|
console.error('customers.pipelines DELETE failed', err)
|
|
@@ -6,7 +6,7 @@ import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/d
|
|
|
6
6
|
import type { CommandBus, CommandRuntimeContext } from '@open-mercato/shared/lib/commands'
|
|
7
7
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
8
8
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
9
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
9
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
10
10
|
import { customerSettingsUpsertSchema, type CustomerSettingsUpsertInput } from '../../../data/validators'
|
|
11
11
|
import { loadCustomerSettings } from '../../../commands/settings'
|
|
12
12
|
import type { CustomerAddressFormat } from '../../../data/entities'
|
|
@@ -67,7 +67,7 @@ export async function GET(req: Request) {
|
|
|
67
67
|
addressFormat: record?.addressFormat ?? 'line_first',
|
|
68
68
|
})
|
|
69
69
|
} catch (err) {
|
|
70
|
-
if (err
|
|
70
|
+
if (isCrudHttpError(err)) {
|
|
71
71
|
return NextResponse.json(err.body, { status: err.status })
|
|
72
72
|
}
|
|
73
73
|
const { translate } = await resolveTranslations()
|
|
@@ -93,7 +93,7 @@ export async function PUT(req: Request) {
|
|
|
93
93
|
addressFormat: result?.addressFormat ?? input.addressFormat,
|
|
94
94
|
})
|
|
95
95
|
} catch (err) {
|
|
96
|
-
if (err
|
|
96
|
+
if (isCrudHttpError(err)) {
|
|
97
97
|
return NextResponse.json(err.body, { status: err.status })
|
|
98
98
|
}
|
|
99
99
|
const { translate } = await resolveTranslations()
|
|
@@ -6,7 +6,7 @@ import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/d
|
|
|
6
6
|
import { serializeOperationMetadata } from '@open-mercato/shared/lib/commands/operationMetadata'
|
|
7
7
|
import type { CommandRuntimeContext, CommandBus } from '@open-mercato/shared/lib/commands'
|
|
8
8
|
import { tagAssignmentSchema, type TagAssignmentInput } from '../../../data/validators'
|
|
9
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
9
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
10
10
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
11
11
|
import { withScopedPayload } from '../../utils'
|
|
12
12
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
@@ -63,7 +63,7 @@ export async function POST(req: Request) {
|
|
|
63
63
|
}
|
|
64
64
|
return response
|
|
65
65
|
} catch (err) {
|
|
66
|
-
if (err
|
|
66
|
+
if (isCrudHttpError(err)) {
|
|
67
67
|
return NextResponse.json(err.body, { status: err.status })
|
|
68
68
|
}
|
|
69
69
|
const { translate } = await resolveTranslations()
|
|
@@ -6,7 +6,7 @@ import { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/d
|
|
|
6
6
|
import { serializeOperationMetadata } from '@open-mercato/shared/lib/commands/operationMetadata'
|
|
7
7
|
import type { CommandRuntimeContext, CommandBus } from '@open-mercato/shared/lib/commands'
|
|
8
8
|
import { tagAssignmentSchema, type TagAssignmentInput } from '../../../data/validators'
|
|
9
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
9
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
10
10
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
11
11
|
import { withScopedPayload } from '../../utils'
|
|
12
12
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
@@ -63,7 +63,7 @@ export async function POST(req: Request) {
|
|
|
63
63
|
}
|
|
64
64
|
return response
|
|
65
65
|
} catch (err) {
|
|
66
|
-
if (err
|
|
66
|
+
if (isCrudHttpError(err)) {
|
|
67
67
|
return NextResponse.json(err.body, { status: err.status })
|
|
68
68
|
}
|
|
69
69
|
const { translate } = await resolveTranslations()
|
|
@@ -7,7 +7,7 @@ import { z } from 'zod'
|
|
|
7
7
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
8
8
|
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
9
9
|
import type { CommandBus } from '@open-mercato/shared/lib/commands'
|
|
10
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
10
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
11
11
|
import { parseBooleanToken } from '@open-mercato/shared/lib/boolean'
|
|
12
12
|
import { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'
|
|
13
13
|
import {
|
|
@@ -303,7 +303,7 @@ export async function GET(request: Request): Promise<Response> {
|
|
|
303
303
|
}),
|
|
304
304
|
)
|
|
305
305
|
} catch (err) {
|
|
306
|
-
if (err
|
|
306
|
+
if (isCrudHttpError(err)) {
|
|
307
307
|
return withAdapterHeaders(NextResponse.json(err.body, { status: err.status }))
|
|
308
308
|
}
|
|
309
309
|
if (err instanceof z.ZodError) {
|
|
@@ -403,7 +403,7 @@ export async function POST(request: Request): Promise<Response> {
|
|
|
403
403
|
),
|
|
404
404
|
)
|
|
405
405
|
} catch (err) {
|
|
406
|
-
if (err
|
|
406
|
+
if (isCrudHttpError(err)) {
|
|
407
407
|
return withAdapterHeaders(NextResponse.json(err.body, { status: err.status }))
|
|
408
408
|
}
|
|
409
409
|
if (err instanceof z.ZodError) {
|
|
@@ -494,7 +494,7 @@ export async function PUT(request: Request): Promise<Response> {
|
|
|
494
494
|
|
|
495
495
|
return withAdapterHeaders(NextResponse.json({ ok: true }))
|
|
496
496
|
} catch (err) {
|
|
497
|
-
if (err
|
|
497
|
+
if (isCrudHttpError(err)) {
|
|
498
498
|
return withAdapterHeaders(NextResponse.json(err.body, { status: err.status }))
|
|
499
499
|
}
|
|
500
500
|
if (err instanceof z.ZodError) {
|
|
@@ -568,7 +568,7 @@ export async function DELETE(request: Request): Promise<Response> {
|
|
|
568
568
|
|
|
569
569
|
return withAdapterHeaders(NextResponse.json({ ok: true }))
|
|
570
570
|
} catch (err) {
|
|
571
|
-
if (err
|
|
571
|
+
if (isCrudHttpError(err)) {
|
|
572
572
|
return withAdapterHeaders(NextResponse.json(err.body, { status: err.status }))
|
|
573
573
|
}
|
|
574
574
|
if (err instanceof z.ZodError) {
|
|
@@ -3,7 +3,7 @@ import { z } from 'zod'
|
|
|
3
3
|
import { Dictionary, DictionaryEntry } from '@open-mercato/core/modules/dictionaries/data/entities'
|
|
4
4
|
import { resolveDictionariesRouteContext } from '@open-mercato/core/modules/dictionaries/api/context'
|
|
5
5
|
import { updateDictionaryEntrySchema } from '@open-mercato/core/modules/dictionaries/data/validators'
|
|
6
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
6
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
7
7
|
import type { CommandBus } from '@open-mercato/shared/lib/commands'
|
|
8
8
|
import { serializeOperationMetadata } from '@open-mercato/shared/lib/commands/operationMetadata'
|
|
9
9
|
import type { OpenApiMethodDoc, OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
@@ -122,7 +122,7 @@ export async function PATCH(req: Request, ctx: { params?: { dictionaryId?: strin
|
|
|
122
122
|
}
|
|
123
123
|
return response
|
|
124
124
|
} catch (err) {
|
|
125
|
-
if (err
|
|
125
|
+
if (isCrudHttpError(err)) {
|
|
126
126
|
return NextResponse.json(err.body, { status: err.status })
|
|
127
127
|
}
|
|
128
128
|
console.error('[dictionaries/:id/entries/:entryId.PATCH] Unexpected error', err)
|
|
@@ -161,7 +161,7 @@ export async function DELETE(req: Request, ctx: { params?: { dictionaryId?: stri
|
|
|
161
161
|
}
|
|
162
162
|
return response
|
|
163
163
|
} catch (err) {
|
|
164
|
-
if (err
|
|
164
|
+
if (isCrudHttpError(err)) {
|
|
165
165
|
return NextResponse.json(err.body, { status: err.status })
|
|
166
166
|
}
|
|
167
167
|
console.error('[dictionaries/:id/entries/:entryId.DELETE] Unexpected error', err)
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
reorderDictionaryEntriesSchema,
|
|
8
8
|
type ReorderDictionaryEntriesCommandInput,
|
|
9
9
|
} from '@open-mercato/core/modules/dictionaries/data/validators'
|
|
10
|
-
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
10
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
11
11
|
import type { CommandBus } from '@open-mercato/shared/lib/commands'
|
|
12
12
|
import type { OpenApiMethodDoc, OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
13
13
|
import { serializeOperationMetadata } from '@open-mercato/shared/lib/commands/operationMetadata'
|
|
@@ -124,7 +124,7 @@ export async function POST(req: Request, ctx: { params?: { dictionaryId?: string
|
|
|
124
124
|
}
|
|
125
125
|
return response
|
|
126
126
|
} catch (err) {
|
|
127
|
-
if (err
|
|
127
|
+
if (isCrudHttpError(err)) {
|
|
128
128
|
return NextResponse.json(err.body, { status: err.status })
|
|
129
129
|
}
|
|
130
130
|
console.error('[dictionaries/:id/entries/reorder.POST] Unexpected error', err)
|