@open-mercato/core 0.4.5-develop-0f0e676c72 → 0.4.5-develop-e694581d9f
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/generated/entities/customer_deal/index.js +4 -0
- package/dist/generated/entities/customer_deal/index.js.map +2 -2
- package/dist/generated/entities/customer_pipeline/index.js +17 -0
- package/dist/generated/entities/customer_pipeline/index.js.map +7 -0
- package/dist/generated/entities/customer_pipeline_stage/index.js +19 -0
- package/dist/generated/entities/customer_pipeline_stage/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +2 -0
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +4 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/customers/acl.js +2 -0
- package/dist/modules/customers/acl.js.map +2 -2
- package/dist/modules/customers/api/deals/[id]/route.js +4 -0
- package/dist/modules/customers/api/deals/[id]/route.js.map +2 -2
- package/dist/modules/customers/api/deals/route.js +12 -0
- package/dist/modules/customers/api/deals/route.js.map +2 -2
- package/dist/modules/customers/api/dictionaries/[kind]/route.js +20 -1
- package/dist/modules/customers/api/dictionaries/[kind]/route.js.map +2 -2
- package/dist/modules/customers/api/pipeline-stages/reorder/route.js +69 -0
- package/dist/modules/customers/api/pipeline-stages/reorder/route.js.map +7 -0
- package/dist/modules/customers/api/pipeline-stages/route.js +275 -0
- package/dist/modules/customers/api/pipeline-stages/route.js.map +7 -0
- package/dist/modules/customers/api/pipelines/route.js +245 -0
- package/dist/modules/customers/api/pipelines/route.js.map +7 -0
- package/dist/modules/customers/backend/config/customers/page.js +2 -0
- package/dist/modules/customers/backend/config/customers/page.js.map +2 -2
- package/dist/modules/customers/backend/config/customers/pipeline-stages/page.js +439 -0
- package/dist/modules/customers/backend/config/customers/pipeline-stages/page.js.map +7 -0
- package/dist/modules/customers/backend/config/customers/pipeline-stages/page.meta.js +17 -0
- package/dist/modules/customers/backend/config/customers/pipeline-stages/page.meta.js.map +7 -0
- package/dist/modules/customers/backend/customers/deals/[id]/page.js +19 -1
- package/dist/modules/customers/backend/customers/deals/[id]/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/page.js +35 -1
- package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/pipeline/page.js +102 -74
- package/dist/modules/customers/backend/customers/deals/pipeline/page.js.map +2 -2
- package/dist/modules/customers/cli.js +28 -2
- package/dist/modules/customers/cli.js.map +2 -2
- package/dist/modules/customers/commands/deals.js +34 -2
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/commands/index.js +2 -0
- package/dist/modules/customers/commands/index.js.map +2 -2
- package/dist/modules/customers/commands/pipeline-stages.js +126 -0
- package/dist/modules/customers/commands/pipeline-stages.js.map +7 -0
- package/dist/modules/customers/commands/pipelines.js +87 -0
- package/dist/modules/customers/commands/pipelines.js.map +7 -0
- package/dist/modules/customers/components/DictionarySettings.js +0 -5
- package/dist/modules/customers/components/DictionarySettings.js.map +2 -2
- package/dist/modules/customers/components/PipelineSettings.js +474 -0
- package/dist/modules/customers/components/PipelineSettings.js.map +7 -0
- package/dist/modules/customers/components/detail/DealForm.js +84 -12
- package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
- package/dist/modules/customers/data/entities.js +78 -0
- package/dist/modules/customers/data/entities.js.map +2 -2
- package/dist/modules/customers/data/validators.js +44 -0
- package/dist/modules/customers/data/validators.js.map +2 -2
- package/dist/modules/customers/migrations/Migration20260218191730.js +77 -0
- package/dist/modules/customers/migrations/Migration20260218191730.js.map +7 -0
- package/dist/modules/customers/setup.js +7 -3
- package/dist/modules/customers/setup.js.map +2 -2
- package/dist/modules/translations/api/[entityType]/[entityId]/route.js +46 -44
- package/dist/modules/translations/api/[entityType]/[entityId]/route.js.map +2 -2
- package/dist/modules/translations/api/context.js +10 -1
- package/dist/modules/translations/api/context.js.map +2 -2
- package/dist/modules/translations/commands/index.js +2 -0
- package/dist/modules/translations/commands/index.js.map +7 -0
- package/dist/modules/translations/commands/translations.js +160 -0
- package/dist/modules/translations/commands/translations.js.map +7 -0
- package/dist/modules/translations/index.js +1 -0
- package/dist/modules/translations/index.js.map +2 -2
- package/dist/modules/workflows/migrations/Migration20260222205305.js +14 -0
- package/dist/modules/workflows/migrations/Migration20260222205305.js.map +7 -0
- package/generated/entities/customer_deal/index.ts +2 -0
- package/generated/entities/customer_pipeline/index.ts +7 -0
- package/generated/entities/customer_pipeline_stage/index.ts +8 -0
- package/generated/entities.ids.generated.ts +2 -0
- package/generated/entity-fields-registry.ts +4 -0
- package/package.json +2 -2
- package/src/modules/customers/acl.ts +2 -0
- package/src/modules/customers/api/deals/[id]/route.ts +4 -0
- package/src/modules/customers/api/deals/route.ts +12 -0
- package/src/modules/customers/api/dictionaries/[kind]/route.ts +21 -1
- package/src/modules/customers/api/pipeline-stages/reorder/route.ts +71 -0
- package/src/modules/customers/api/pipeline-stages/route.ts +296 -0
- package/src/modules/customers/api/pipelines/route.ts +261 -0
- package/src/modules/customers/backend/config/customers/page.tsx +2 -0
- package/src/modules/customers/backend/config/customers/pipeline-stages/page.meta.ts +13 -0
- package/src/modules/customers/backend/config/customers/pipeline-stages/page.tsx +512 -0
- package/src/modules/customers/backend/customers/deals/[id]/page.tsx +21 -1
- package/src/modules/customers/backend/customers/deals/page.tsx +33 -1
- package/src/modules/customers/backend/customers/deals/pipeline/page.tsx +119 -79
- package/src/modules/customers/cli.ts +29 -1
- package/src/modules/customers/commands/deals.ts +44 -1
- package/src/modules/customers/commands/index.ts +2 -0
- package/src/modules/customers/commands/pipeline-stages.ts +156 -0
- package/src/modules/customers/commands/pipelines.ts +105 -0
- package/src/modules/customers/components/DictionarySettings.tsx +0 -5
- package/src/modules/customers/components/PipelineSettings.tsx +570 -0
- package/src/modules/customers/components/detail/DealForm.tsx +89 -11
- package/src/modules/customers/data/entities.ts +64 -0
- package/src/modules/customers/data/validators.ts +57 -0
- package/src/modules/customers/i18n/de.json +4 -0
- package/src/modules/customers/i18n/en.json +4 -0
- package/src/modules/customers/i18n/es.json +4 -0
- package/src/modules/customers/i18n/pl.json +5 -1
- package/src/modules/customers/migrations/Migration20260218191730.ts +84 -0
- package/src/modules/customers/setup.ts +5 -1
- package/src/modules/translations/api/[entityType]/[entityId]/route.ts +65 -60
- package/src/modules/translations/api/context.ts +12 -0
- package/src/modules/translations/commands/index.ts +1 -0
- package/src/modules/translations/commands/translations.ts +253 -0
- package/src/modules/translations/index.ts +1 -0
- package/src/modules/workflows/migrations/Migration20260222205305.ts +13 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/customers/api/pipeline-stages/route.ts"],
|
|
4
|
+
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport type { CommandRuntimeContext, CommandBus } from '@open-mercato/shared/lib/commands'\nimport { CustomerPipelineStage, CustomerDictionaryEntry } from '../../data/entities'\nimport {\n pipelineStageCreateSchema,\n pipelineStageUpdateSchema,\n pipelineStageDeleteSchema,\n type PipelineStageCreateInput,\n type PipelineStageUpdateInput,\n type PipelineStageDeleteInput,\n} from '../../data/validators'\nimport { withScopedPayload } from '../utils'\nimport { ensureDictionaryEntry } from '../../commands/shared'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { serializeOperationMetadata } from '@open-mercato/shared/lib/commands/operationMetadata'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: ['customers.pipelines.view'] },\n POST: { requireAuth: true, requireFeatures: ['customers.pipelines.manage'] },\n PUT: { requireAuth: true, requireFeatures: ['customers.pipelines.manage'] },\n DELETE: { requireAuth: true, requireFeatures: ['customers.pipelines.manage'] },\n}\n\nasync function buildContext(\n req: Request\n): Promise<{ ctx: CommandRuntimeContext; organizationId: string | null; tenantId: string | null }> {\n const container = await createRequestContainer()\n const auth = await getAuthFromRequest(req)\n const { translate } = await resolveTranslations()\n if (!auth) throw new CrudHttpError(401, { error: translate('customers.errors.unauthorized', 'Unauthorized') })\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request: req })\n const ctx: CommandRuntimeContext = {\n container,\n auth,\n organizationScope: scope,\n selectedOrganizationId: scope?.selectedId ?? auth.orgId ?? null,\n organizationIds: scope?.filterIds ?? (auth.orgId ? [auth.orgId] : null),\n request: req,\n }\n const organizationId = scope?.selectedId ?? auth.orgId ?? null\n const tenantId = auth.tenantId ?? null\n return { ctx, organizationId, tenantId }\n}\n\nexport async function GET(req: Request) {\n try {\n const { ctx, organizationId, tenantId } = await buildContext(req)\n if (!organizationId || !tenantId) {\n return NextResponse.json({ error: 'Organization and tenant context required' }, { status: 400 })\n }\n const url = new URL(req.url)\n const pipelineId = url.searchParams.get('pipelineId')\n\n const em = (ctx.container.resolve('em') as EntityManager)\n const where: Record<string, unknown> = { organizationId, tenantId }\n if (pipelineId) where.pipelineId = pipelineId\n\n const stages = await em.find(CustomerPipelineStage, where, { orderBy: { order: 'ASC' } })\n\n const stageLabels = stages.map((s) => s.label.trim().toLowerCase())\n const dictEntries = stageLabels.length\n ? await em.find(CustomerDictionaryEntry, {\n organizationId,\n tenantId,\n kind: 'pipeline_stage',\n normalizedValue: { $in: stageLabels },\n })\n : []\n const dictByNormalized = new Map<string, CustomerDictionaryEntry>()\n dictEntries.forEach((entry) => dictByNormalized.set(entry.normalizedValue, entry))\n\n const missingStages = stages.filter((s) => !dictByNormalized.has(s.label.trim().toLowerCase()))\n if (missingStages.length) {\n for (const stage of missingStages) {\n const created = await ensureDictionaryEntry(em, {\n tenantId,\n organizationId,\n kind: 'pipeline_stage',\n value: stage.label,\n })\n if (created) dictByNormalized.set(created.normalizedValue, created)\n }\n }\n\n const items = stages.map((stage) => {\n const dictEntry = dictByNormalized.get(stage.label.trim().toLowerCase())\n return {\n id: stage.id,\n pipelineId: stage.pipelineId,\n label: stage.label,\n order: stage.order,\n color: dictEntry?.color ?? null,\n icon: dictEntry?.icon ?? null,\n organizationId: stage.organizationId,\n tenantId: stage.tenantId,\n createdAt: stage.createdAt,\n updatedAt: stage.updatedAt,\n }\n })\n return NextResponse.json({ items, total: items.length })\n } catch (err) {\n if (err instanceof CrudHttpError) {\n return NextResponse.json(err.body, { status: err.status })\n }\n console.error('customers.pipeline-stages GET failed', err)\n return NextResponse.json({ error: 'Failed to load pipeline stages' }, { status: 500 })\n }\n}\n\nexport async function POST(req: Request) {\n try {\n const { ctx } = await buildContext(req)\n const body = await req.json().catch(() => ({}))\n const { translate } = await resolveTranslations()\n const scoped = withScopedPayload(body, ctx, translate)\n\n const commandBus = (ctx.container.resolve('commandBus') as CommandBus)\n const { result, logEntry } = await commandBus.execute<PipelineStageCreateInput, { stageId: string }>(\n 'customers.pipeline-stages.create',\n { input: pipelineStageCreateSchema.parse(scoped), ctx },\n )\n const response = NextResponse.json({ id: result?.stageId ?? null }, { status: 201 })\n if (logEntry?.undoToken && logEntry?.id && logEntry?.commandId) {\n response.headers.set(\n 'x-om-operation',\n serializeOperationMetadata({\n id: logEntry.id,\n undoToken: logEntry.undoToken,\n commandId: logEntry.commandId,\n actionLabel: logEntry.actionLabel ?? null,\n resourceKind: logEntry.resourceKind ?? 'customers.pipelineStage',\n resourceId: logEntry.resourceId ?? result?.stageId ?? null,\n executedAt: logEntry.createdAt instanceof Date ? logEntry.createdAt.toISOString() : undefined,\n })\n )\n }\n return response\n } catch (err) {\n if (err instanceof CrudHttpError) {\n return NextResponse.json(err.body, { status: err.status })\n }\n console.error('customers.pipeline-stages POST failed', err)\n return NextResponse.json({ error: 'Failed to create pipeline stage' }, { status: 400 })\n }\n}\n\nexport async function PUT(req: Request) {\n try {\n const { ctx } = await buildContext(req)\n const body = await req.json().catch(() => ({}))\n const { translate } = await resolveTranslations()\n const scoped = withScopedPayload(body, ctx, translate)\n\n const commandBus = (ctx.container.resolve('commandBus') as CommandBus)\n const { logEntry } = await commandBus.execute<PipelineStageUpdateInput, void>(\n 'customers.pipeline-stages.update',\n { input: pipelineStageUpdateSchema.parse(scoped), ctx },\n )\n const response = NextResponse.json({ ok: true })\n if (logEntry?.undoToken && logEntry?.id && logEntry?.commandId) {\n response.headers.set(\n 'x-om-operation',\n serializeOperationMetadata({\n id: logEntry.id,\n undoToken: logEntry.undoToken,\n commandId: logEntry.commandId,\n actionLabel: logEntry.actionLabel ?? null,\n resourceKind: logEntry.resourceKind ?? 'customers.pipelineStage',\n resourceId: logEntry.resourceId ?? null,\n executedAt: logEntry.createdAt instanceof Date ? logEntry.createdAt.toISOString() : undefined,\n })\n )\n }\n return response\n } catch (err) {\n if (err instanceof CrudHttpError) {\n return NextResponse.json(err.body, { status: err.status })\n }\n console.error('customers.pipeline-stages PUT failed', err)\n return NextResponse.json({ error: 'Failed to update pipeline stage' }, { status: 400 })\n }\n}\n\nexport async function DELETE(req: Request) {\n try {\n const { ctx } = await buildContext(req)\n const body = await req.json().catch(() => ({}))\n const { translate } = await resolveTranslations()\n const scoped = withScopedPayload(body, ctx, translate)\n\n const commandBus = (ctx.container.resolve('commandBus') as CommandBus)\n await commandBus.execute<PipelineStageDeleteInput, void>(\n 'customers.pipeline-stages.delete',\n { input: pipelineStageDeleteSchema.parse(scoped), ctx },\n )\n return NextResponse.json({ ok: true })\n } catch (err) {\n if (err instanceof CrudHttpError) {\n return NextResponse.json(err.body, { status: err.status })\n }\n console.error('customers.pipeline-stages DELETE failed', err)\n return NextResponse.json({ error: 'Failed to delete pipeline stage' }, { status: 400 })\n }\n}\n\nconst stageItemSchema = z.object({\n id: z.string().uuid(),\n pipelineId: z.string().uuid(),\n label: z.string(),\n order: z.number(),\n color: z.string().nullable(),\n icon: z.string().nullable(),\n organizationId: z.string().uuid(),\n tenantId: z.string().uuid(),\n createdAt: z.date(),\n updatedAt: z.date(),\n})\n\nconst stageListResponseSchema = z.object({\n items: z.array(stageItemSchema),\n total: z.number(),\n})\n\nconst stageCreateResponseSchema = z.object({\n id: z.string().uuid().nullable(),\n})\n\nconst stageOkResponseSchema = z.object({\n ok: z.boolean(),\n})\n\nconst stageErrorSchema = z.object({\n error: z.string(),\n})\n\nexport const openApi: OpenApiRouteDoc = {\n tag: 'Customers',\n summary: 'Manage pipeline stages',\n methods: {\n GET: {\n summary: 'List pipeline stages',\n description: 'Returns pipeline stages for the authenticated organization, optionally filtered by pipelineId.',\n query: z.object({ pipelineId: z.string().uuid().optional() }),\n responses: [\n { status: 200, description: 'Stage list', schema: stageListResponseSchema },\n ],\n errors: [\n { status: 401, description: 'Unauthorized', schema: stageErrorSchema },\n { status: 400, description: 'Invalid request', schema: stageErrorSchema },\n ],\n },\n POST: {\n summary: 'Create pipeline stage',\n description: 'Creates a new pipeline stage.',\n requestBody: { contentType: 'application/json', schema: pipelineStageCreateSchema },\n responses: [\n { status: 201, description: 'Stage created', schema: stageCreateResponseSchema },\n ],\n errors: [\n { status: 400, description: 'Validation failed', schema: stageErrorSchema },\n { status: 401, description: 'Unauthorized', schema: stageErrorSchema },\n ],\n },\n PUT: {\n summary: 'Update pipeline stage',\n description: 'Updates an existing pipeline stage.',\n requestBody: { contentType: 'application/json', schema: pipelineStageUpdateSchema },\n responses: [\n { status: 200, description: 'Stage updated', schema: stageOkResponseSchema },\n ],\n errors: [\n { status: 400, description: 'Validation failed', schema: stageErrorSchema },\n { status: 404, description: 'Stage not found', schema: stageErrorSchema },\n ],\n },\n DELETE: {\n summary: 'Delete pipeline stage',\n description: 'Deletes a pipeline stage. Returns 409 if active deals use this stage.',\n requestBody: { contentType: 'application/json', schema: pipelineStageDeleteSchema },\n responses: [\n { status: 200, description: 'Stage deleted', schema: stageOkResponseSchema },\n ],\n errors: [\n { status: 409, description: 'Stage has active deals', schema: stageErrorSchema },\n { status: 404, description: 'Stage not found', schema: stageErrorSchema },\n ],\n },\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAClB,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,SAAS,0CAA0C;AAGnD,SAAS,uBAAuB,+BAA+B;AAC/D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,kCAAkC;AAGpC,MAAM,WAAW;AAAA,EACtB,KAAK,EAAE,aAAa,MAAM,iBAAiB,CAAC,0BAA0B,EAAE;AAAA,EACxE,MAAM,EAAE,aAAa,MAAM,iBAAiB,CAAC,4BAA4B,EAAE;AAAA,EAC3E,KAAK,EAAE,aAAa,MAAM,iBAAiB,CAAC,4BAA4B,EAAE;AAAA,EAC1E,QAAQ,EAAE,aAAa,MAAM,iBAAiB,CAAC,4BAA4B,EAAE;AAC/E;AAEA,eAAe,aACb,KACiG;AACjG,QAAM,YAAY,MAAM,uBAAuB;AAC/C,QAAM,OAAO,MAAM,mBAAmB,GAAG;AACzC,QAAM,EAAE,UAAU,IAAI,MAAM,oBAAoB;AAChD,MAAI,CAAC,KAAM,OAAM,IAAI,cAAc,KAAK,EAAE,OAAO,UAAU,iCAAiC,cAAc,EAAE,CAAC;AAC7G,QAAM,QAAQ,MAAM,mCAAmC,EAAE,WAAW,MAAM,SAAS,IAAI,CAAC;AACxF,QAAM,MAA6B;AAAA,IACjC;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,IACnB,wBAAwB,OAAO,cAAc,KAAK,SAAS;AAAA,IAC3D,iBAAiB,OAAO,cAAc,KAAK,QAAQ,CAAC,KAAK,KAAK,IAAI;AAAA,IAClE,SAAS;AAAA,EACX;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{ NextResponse } from "next/server";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
|
|
4
|
+
import { getAuthFromRequest } from "@open-mercato/shared/lib/auth/server";
|
|
5
|
+
import { resolveOrganizationScopeForRequest } from "@open-mercato/core/modules/directory/utils/organizationScope";
|
|
6
|
+
import { CustomerPipeline } from "../../data/entities.js";
|
|
7
|
+
import {
|
|
8
|
+
pipelineCreateSchema,
|
|
9
|
+
pipelineUpdateSchema,
|
|
10
|
+
pipelineDeleteSchema
|
|
11
|
+
} from "../../data/validators.js";
|
|
12
|
+
import { withScopedPayload } from "../utils.js";
|
|
13
|
+
import { CrudHttpError } from "@open-mercato/shared/lib/crud/errors";
|
|
14
|
+
import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
|
|
15
|
+
import { serializeOperationMetadata } from "@open-mercato/shared/lib/commands/operationMetadata";
|
|
16
|
+
const metadata = {
|
|
17
|
+
GET: { requireAuth: true, requireFeatures: ["customers.pipelines.view"] },
|
|
18
|
+
POST: { requireAuth: true, requireFeatures: ["customers.pipelines.manage"] },
|
|
19
|
+
PUT: { requireAuth: true, requireFeatures: ["customers.pipelines.manage"] },
|
|
20
|
+
DELETE: { requireAuth: true, requireFeatures: ["customers.pipelines.manage"] }
|
|
21
|
+
};
|
|
22
|
+
async function buildContext(req) {
|
|
23
|
+
const container = await createRequestContainer();
|
|
24
|
+
const auth = await getAuthFromRequest(req);
|
|
25
|
+
const { translate } = await resolveTranslations();
|
|
26
|
+
if (!auth) throw new CrudHttpError(401, { error: translate("customers.errors.unauthorized", "Unauthorized") });
|
|
27
|
+
const scope = await resolveOrganizationScopeForRequest({ container, auth, request: req });
|
|
28
|
+
const ctx = {
|
|
29
|
+
container,
|
|
30
|
+
auth,
|
|
31
|
+
organizationScope: scope,
|
|
32
|
+
selectedOrganizationId: scope?.selectedId ?? auth.orgId ?? null,
|
|
33
|
+
organizationIds: scope?.filterIds ?? (auth.orgId ? [auth.orgId] : null),
|
|
34
|
+
request: req
|
|
35
|
+
};
|
|
36
|
+
const organizationId = scope?.selectedId ?? auth.orgId ?? null;
|
|
37
|
+
const tenantId = auth.tenantId ?? null;
|
|
38
|
+
return { ctx, organizationId, tenantId };
|
|
39
|
+
}
|
|
40
|
+
async function GET(req) {
|
|
41
|
+
try {
|
|
42
|
+
const { ctx, organizationId, tenantId } = await buildContext(req);
|
|
43
|
+
if (!organizationId || !tenantId) {
|
|
44
|
+
return NextResponse.json({ error: "Organization and tenant context required" }, { status: 400 });
|
|
45
|
+
}
|
|
46
|
+
const url = new URL(req.url);
|
|
47
|
+
const isDefaultParam = url.searchParams.get("isDefault");
|
|
48
|
+
const em = ctx.container.resolve("em");
|
|
49
|
+
const where = { organizationId, tenantId };
|
|
50
|
+
if (isDefaultParam === "true") where.isDefault = true;
|
|
51
|
+
if (isDefaultParam === "false") where.isDefault = false;
|
|
52
|
+
const pipelines = await em.find(CustomerPipeline, where, { orderBy: { createdAt: "ASC" } });
|
|
53
|
+
const items = pipelines.map((pipeline) => ({
|
|
54
|
+
id: pipeline.id,
|
|
55
|
+
name: pipeline.name,
|
|
56
|
+
isDefault: pipeline.isDefault,
|
|
57
|
+
organizationId: pipeline.organizationId,
|
|
58
|
+
tenantId: pipeline.tenantId,
|
|
59
|
+
createdAt: pipeline.createdAt,
|
|
60
|
+
updatedAt: pipeline.updatedAt
|
|
61
|
+
}));
|
|
62
|
+
return NextResponse.json({ items, total: items.length });
|
|
63
|
+
} catch (err) {
|
|
64
|
+
if (err instanceof CrudHttpError) {
|
|
65
|
+
return NextResponse.json(err.body, { status: err.status });
|
|
66
|
+
}
|
|
67
|
+
console.error("customers.pipelines GET failed", err);
|
|
68
|
+
return NextResponse.json({ error: "Failed to load pipelines" }, { status: 500 });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function POST(req) {
|
|
72
|
+
try {
|
|
73
|
+
const { ctx } = await buildContext(req);
|
|
74
|
+
const body = await req.json().catch(() => ({}));
|
|
75
|
+
const { translate } = await resolveTranslations();
|
|
76
|
+
const scoped = withScopedPayload(body, ctx, translate);
|
|
77
|
+
const commandBus = ctx.container.resolve("commandBus");
|
|
78
|
+
const { result, logEntry } = await commandBus.execute(
|
|
79
|
+
"customers.pipelines.create",
|
|
80
|
+
{ input: pipelineCreateSchema.parse(scoped), ctx }
|
|
81
|
+
);
|
|
82
|
+
const response = NextResponse.json({ id: result?.pipelineId ?? null }, { status: 201 });
|
|
83
|
+
if (logEntry?.undoToken && logEntry?.id && logEntry?.commandId) {
|
|
84
|
+
response.headers.set(
|
|
85
|
+
"x-om-operation",
|
|
86
|
+
serializeOperationMetadata({
|
|
87
|
+
id: logEntry.id,
|
|
88
|
+
undoToken: logEntry.undoToken,
|
|
89
|
+
commandId: logEntry.commandId,
|
|
90
|
+
actionLabel: logEntry.actionLabel ?? null,
|
|
91
|
+
resourceKind: logEntry.resourceKind ?? "customers.pipeline",
|
|
92
|
+
resourceId: logEntry.resourceId ?? result?.pipelineId ?? null,
|
|
93
|
+
executedAt: logEntry.createdAt instanceof Date ? logEntry.createdAt.toISOString() : void 0
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return response;
|
|
98
|
+
} catch (err) {
|
|
99
|
+
if (err instanceof CrudHttpError) {
|
|
100
|
+
return NextResponse.json(err.body, { status: err.status });
|
|
101
|
+
}
|
|
102
|
+
console.error("customers.pipelines POST failed", err);
|
|
103
|
+
return NextResponse.json({ error: "Failed to create pipeline" }, { status: 400 });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function PUT(req) {
|
|
107
|
+
try {
|
|
108
|
+
const { ctx } = await buildContext(req);
|
|
109
|
+
const body = await req.json().catch(() => ({}));
|
|
110
|
+
const { translate } = await resolveTranslations();
|
|
111
|
+
const scoped = withScopedPayload(body, ctx, translate);
|
|
112
|
+
const commandBus = ctx.container.resolve("commandBus");
|
|
113
|
+
const { logEntry } = await commandBus.execute(
|
|
114
|
+
"customers.pipelines.update",
|
|
115
|
+
{ input: pipelineUpdateSchema.parse(scoped), ctx }
|
|
116
|
+
);
|
|
117
|
+
const response = NextResponse.json({ ok: true });
|
|
118
|
+
if (logEntry?.undoToken && logEntry?.id && logEntry?.commandId) {
|
|
119
|
+
response.headers.set(
|
|
120
|
+
"x-om-operation",
|
|
121
|
+
serializeOperationMetadata({
|
|
122
|
+
id: logEntry.id,
|
|
123
|
+
undoToken: logEntry.undoToken,
|
|
124
|
+
commandId: logEntry.commandId,
|
|
125
|
+
actionLabel: logEntry.actionLabel ?? null,
|
|
126
|
+
resourceKind: logEntry.resourceKind ?? "customers.pipeline",
|
|
127
|
+
resourceId: logEntry.resourceId ?? null,
|
|
128
|
+
executedAt: logEntry.createdAt instanceof Date ? logEntry.createdAt.toISOString() : void 0
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return response;
|
|
133
|
+
} catch (err) {
|
|
134
|
+
if (err instanceof CrudHttpError) {
|
|
135
|
+
return NextResponse.json(err.body, { status: err.status });
|
|
136
|
+
}
|
|
137
|
+
console.error("customers.pipelines PUT failed", err);
|
|
138
|
+
return NextResponse.json({ error: "Failed to update pipeline" }, { status: 400 });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async function DELETE(req) {
|
|
142
|
+
try {
|
|
143
|
+
const { ctx } = await buildContext(req);
|
|
144
|
+
const body = await req.json().catch(() => ({}));
|
|
145
|
+
const { translate } = await resolveTranslations();
|
|
146
|
+
const scoped = withScopedPayload(body, ctx, translate);
|
|
147
|
+
const commandBus = ctx.container.resolve("commandBus");
|
|
148
|
+
await commandBus.execute(
|
|
149
|
+
"customers.pipelines.delete",
|
|
150
|
+
{ input: pipelineDeleteSchema.parse(scoped), ctx }
|
|
151
|
+
);
|
|
152
|
+
return NextResponse.json({ ok: true });
|
|
153
|
+
} catch (err) {
|
|
154
|
+
if (err instanceof CrudHttpError) {
|
|
155
|
+
return NextResponse.json(err.body, { status: err.status });
|
|
156
|
+
}
|
|
157
|
+
console.error("customers.pipelines DELETE failed", err);
|
|
158
|
+
return NextResponse.json({ error: "Failed to delete pipeline" }, { status: 400 });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const pipelineItemSchema = z.object({
|
|
162
|
+
id: z.string().uuid(),
|
|
163
|
+
name: z.string(),
|
|
164
|
+
isDefault: z.boolean(),
|
|
165
|
+
organizationId: z.string().uuid(),
|
|
166
|
+
tenantId: z.string().uuid(),
|
|
167
|
+
createdAt: z.date(),
|
|
168
|
+
updatedAt: z.date()
|
|
169
|
+
});
|
|
170
|
+
const pipelineListResponseSchema = z.object({
|
|
171
|
+
items: z.array(pipelineItemSchema),
|
|
172
|
+
total: z.number()
|
|
173
|
+
});
|
|
174
|
+
const pipelineCreateResponseSchema = z.object({
|
|
175
|
+
id: z.string().uuid().nullable()
|
|
176
|
+
});
|
|
177
|
+
const pipelineOkResponseSchema = z.object({
|
|
178
|
+
ok: z.boolean()
|
|
179
|
+
});
|
|
180
|
+
const pipelineErrorSchema = z.object({
|
|
181
|
+
error: z.string()
|
|
182
|
+
});
|
|
183
|
+
const openApi = {
|
|
184
|
+
tag: "Customers",
|
|
185
|
+
summary: "Manage customer pipelines",
|
|
186
|
+
methods: {
|
|
187
|
+
GET: {
|
|
188
|
+
summary: "List pipelines",
|
|
189
|
+
description: "Returns a list of pipelines scoped to the authenticated organization.",
|
|
190
|
+
query: z.object({ isDefault: z.string().optional() }),
|
|
191
|
+
responses: [
|
|
192
|
+
{ status: 200, description: "Pipeline list", schema: pipelineListResponseSchema }
|
|
193
|
+
],
|
|
194
|
+
errors: [
|
|
195
|
+
{ status: 401, description: "Unauthorized", schema: pipelineErrorSchema },
|
|
196
|
+
{ status: 400, description: "Invalid request", schema: pipelineErrorSchema }
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
POST: {
|
|
200
|
+
summary: "Create pipeline",
|
|
201
|
+
description: "Creates a new pipeline within the authenticated organization.",
|
|
202
|
+
requestBody: { contentType: "application/json", schema: pipelineCreateSchema },
|
|
203
|
+
responses: [
|
|
204
|
+
{ status: 201, description: "Pipeline created", schema: pipelineCreateResponseSchema }
|
|
205
|
+
],
|
|
206
|
+
errors: [
|
|
207
|
+
{ status: 400, description: "Validation failed", schema: pipelineErrorSchema },
|
|
208
|
+
{ status: 401, description: "Unauthorized", schema: pipelineErrorSchema }
|
|
209
|
+
]
|
|
210
|
+
},
|
|
211
|
+
PUT: {
|
|
212
|
+
summary: "Update pipeline",
|
|
213
|
+
description: "Updates an existing pipeline.",
|
|
214
|
+
requestBody: { contentType: "application/json", schema: pipelineUpdateSchema },
|
|
215
|
+
responses: [
|
|
216
|
+
{ status: 200, description: "Pipeline updated", schema: pipelineOkResponseSchema }
|
|
217
|
+
],
|
|
218
|
+
errors: [
|
|
219
|
+
{ status: 400, description: "Validation failed", schema: pipelineErrorSchema },
|
|
220
|
+
{ status: 404, description: "Pipeline not found", schema: pipelineErrorSchema }
|
|
221
|
+
]
|
|
222
|
+
},
|
|
223
|
+
DELETE: {
|
|
224
|
+
summary: "Delete pipeline",
|
|
225
|
+
description: "Deletes a pipeline. Returns 409 if active deals exist.",
|
|
226
|
+
requestBody: { contentType: "application/json", schema: pipelineDeleteSchema },
|
|
227
|
+
responses: [
|
|
228
|
+
{ status: 200, description: "Pipeline deleted", schema: pipelineOkResponseSchema }
|
|
229
|
+
],
|
|
230
|
+
errors: [
|
|
231
|
+
{ status: 409, description: "Pipeline has active deals", schema: pipelineErrorSchema },
|
|
232
|
+
{ status: 404, description: "Pipeline not found", schema: pipelineErrorSchema }
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
export {
|
|
238
|
+
DELETE,
|
|
239
|
+
GET,
|
|
240
|
+
POST,
|
|
241
|
+
PUT,
|
|
242
|
+
metadata,
|
|
243
|
+
openApi
|
|
244
|
+
};
|
|
245
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/customers/api/pipelines/route.ts"],
|
|
4
|
+
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { resolveOrganizationScopeForRequest } from '@open-mercato/core/modules/directory/utils/organizationScope'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport type { CommandRuntimeContext, CommandBus } from '@open-mercato/shared/lib/commands'\nimport { CustomerPipeline } from '../../data/entities'\nimport {\n pipelineCreateSchema,\n pipelineUpdateSchema,\n pipelineDeleteSchema,\n type PipelineCreateInput,\n type PipelineUpdateInput,\n type PipelineDeleteInput,\n} from '../../data/validators'\nimport { withScopedPayload } from '../utils'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { serializeOperationMetadata } from '@open-mercato/shared/lib/commands/operationMetadata'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: ['customers.pipelines.view'] },\n POST: { requireAuth: true, requireFeatures: ['customers.pipelines.manage'] },\n PUT: { requireAuth: true, requireFeatures: ['customers.pipelines.manage'] },\n DELETE: { requireAuth: true, requireFeatures: ['customers.pipelines.manage'] },\n}\n\nasync function buildContext(\n req: Request\n): Promise<{ ctx: CommandRuntimeContext; organizationId: string | null; tenantId: string | null }> {\n const container = await createRequestContainer()\n const auth = await getAuthFromRequest(req)\n const { translate } = await resolveTranslations()\n if (!auth) throw new CrudHttpError(401, { error: translate('customers.errors.unauthorized', 'Unauthorized') })\n const scope = await resolveOrganizationScopeForRequest({ container, auth, request: req })\n const ctx: CommandRuntimeContext = {\n container,\n auth,\n organizationScope: scope,\n selectedOrganizationId: scope?.selectedId ?? auth.orgId ?? null,\n organizationIds: scope?.filterIds ?? (auth.orgId ? [auth.orgId] : null),\n request: req,\n }\n const organizationId = scope?.selectedId ?? auth.orgId ?? null\n const tenantId = auth.tenantId ?? null\n return { ctx, organizationId, tenantId }\n}\n\nexport async function GET(req: Request) {\n try {\n const { ctx, organizationId, tenantId } = await buildContext(req)\n if (!organizationId || !tenantId) {\n return NextResponse.json({ error: 'Organization and tenant context required' }, { status: 400 })\n }\n const url = new URL(req.url)\n const isDefaultParam = url.searchParams.get('isDefault')\n\n const em = (ctx.container.resolve('em') as EntityManager)\n const where: Record<string, unknown> = { organizationId, tenantId }\n if (isDefaultParam === 'true') where.isDefault = true\n if (isDefaultParam === 'false') where.isDefault = false\n\n const pipelines = await em.find(CustomerPipeline, where, { orderBy: { createdAt: 'ASC' } })\n const items = pipelines.map((pipeline) => ({\n id: pipeline.id,\n name: pipeline.name,\n isDefault: pipeline.isDefault,\n organizationId: pipeline.organizationId,\n tenantId: pipeline.tenantId,\n createdAt: pipeline.createdAt,\n updatedAt: pipeline.updatedAt,\n }))\n return NextResponse.json({ items, total: items.length })\n } catch (err) {\n if (err instanceof CrudHttpError) {\n return NextResponse.json(err.body, { status: err.status })\n }\n console.error('customers.pipelines GET failed', err)\n return NextResponse.json({ error: 'Failed to load pipelines' }, { status: 500 })\n }\n}\n\nexport async function POST(req: Request) {\n try {\n const { ctx } = await buildContext(req)\n const body = await req.json().catch(() => ({}))\n const { translate } = await resolveTranslations()\n const scoped = withScopedPayload(body, ctx, translate)\n\n const commandBus = (ctx.container.resolve('commandBus') as CommandBus)\n const { result, logEntry } = await commandBus.execute<PipelineCreateInput, { pipelineId: string }>(\n 'customers.pipelines.create',\n { input: pipelineCreateSchema.parse(scoped), ctx },\n )\n const response = NextResponse.json({ id: result?.pipelineId ?? null }, { status: 201 })\n if (logEntry?.undoToken && logEntry?.id && logEntry?.commandId) {\n response.headers.set(\n 'x-om-operation',\n serializeOperationMetadata({\n id: logEntry.id,\n undoToken: logEntry.undoToken,\n commandId: logEntry.commandId,\n actionLabel: logEntry.actionLabel ?? null,\n resourceKind: logEntry.resourceKind ?? 'customers.pipeline',\n resourceId: logEntry.resourceId ?? result?.pipelineId ?? null,\n executedAt: logEntry.createdAt instanceof Date ? logEntry.createdAt.toISOString() : undefined,\n })\n )\n }\n return response\n } catch (err) {\n if (err instanceof CrudHttpError) {\n return NextResponse.json(err.body, { status: err.status })\n }\n console.error('customers.pipelines POST failed', err)\n return NextResponse.json({ error: 'Failed to create pipeline' }, { status: 400 })\n }\n}\n\nexport async function PUT(req: Request) {\n try {\n const { ctx } = await buildContext(req)\n const body = await req.json().catch(() => ({}))\n const { translate } = await resolveTranslations()\n const scoped = withScopedPayload(body, ctx, translate)\n\n const commandBus = (ctx.container.resolve('commandBus') as CommandBus)\n const { logEntry } = await commandBus.execute<PipelineUpdateInput, void>(\n 'customers.pipelines.update',\n { input: pipelineUpdateSchema.parse(scoped), ctx },\n )\n const response = NextResponse.json({ ok: true })\n if (logEntry?.undoToken && logEntry?.id && logEntry?.commandId) {\n response.headers.set(\n 'x-om-operation',\n serializeOperationMetadata({\n id: logEntry.id,\n undoToken: logEntry.undoToken,\n commandId: logEntry.commandId,\n actionLabel: logEntry.actionLabel ?? null,\n resourceKind: logEntry.resourceKind ?? 'customers.pipeline',\n resourceId: logEntry.resourceId ?? null,\n executedAt: logEntry.createdAt instanceof Date ? logEntry.createdAt.toISOString() : undefined,\n })\n )\n }\n return response\n } catch (err) {\n if (err instanceof CrudHttpError) {\n return NextResponse.json(err.body, { status: err.status })\n }\n console.error('customers.pipelines PUT failed', err)\n return NextResponse.json({ error: 'Failed to update pipeline' }, { status: 400 })\n }\n}\n\nexport async function DELETE(req: Request) {\n try {\n const { ctx } = await buildContext(req)\n const body = await req.json().catch(() => ({}))\n const { translate } = await resolveTranslations()\n const scoped = withScopedPayload(body, ctx, translate)\n\n const commandBus = (ctx.container.resolve('commandBus') as CommandBus)\n await commandBus.execute<PipelineDeleteInput, void>(\n 'customers.pipelines.delete',\n { input: pipelineDeleteSchema.parse(scoped), ctx },\n )\n return NextResponse.json({ ok: true })\n } catch (err) {\n if (err instanceof CrudHttpError) {\n return NextResponse.json(err.body, { status: err.status })\n }\n console.error('customers.pipelines DELETE failed', err)\n return NextResponse.json({ error: 'Failed to delete pipeline' }, { status: 400 })\n }\n}\n\nconst pipelineItemSchema = z.object({\n id: z.string().uuid(),\n name: z.string(),\n isDefault: z.boolean(),\n organizationId: z.string().uuid(),\n tenantId: z.string().uuid(),\n createdAt: z.date(),\n updatedAt: z.date(),\n})\n\nconst pipelineListResponseSchema = z.object({\n items: z.array(pipelineItemSchema),\n total: z.number(),\n})\n\nconst pipelineCreateResponseSchema = z.object({\n id: z.string().uuid().nullable(),\n})\n\nconst pipelineOkResponseSchema = z.object({\n ok: z.boolean(),\n})\n\nconst pipelineErrorSchema = z.object({\n error: z.string(),\n})\n\nexport const openApi: OpenApiRouteDoc = {\n tag: 'Customers',\n summary: 'Manage customer pipelines',\n methods: {\n GET: {\n summary: 'List pipelines',\n description: 'Returns a list of pipelines scoped to the authenticated organization.',\n query: z.object({ isDefault: z.string().optional() }),\n responses: [\n { status: 200, description: 'Pipeline list', schema: pipelineListResponseSchema },\n ],\n errors: [\n { status: 401, description: 'Unauthorized', schema: pipelineErrorSchema },\n { status: 400, description: 'Invalid request', schema: pipelineErrorSchema },\n ],\n },\n POST: {\n summary: 'Create pipeline',\n description: 'Creates a new pipeline within the authenticated organization.',\n requestBody: { contentType: 'application/json', schema: pipelineCreateSchema },\n responses: [\n { status: 201, description: 'Pipeline created', schema: pipelineCreateResponseSchema },\n ],\n errors: [\n { status: 400, description: 'Validation failed', schema: pipelineErrorSchema },\n { status: 401, description: 'Unauthorized', schema: pipelineErrorSchema },\n ],\n },\n PUT: {\n summary: 'Update pipeline',\n description: 'Updates an existing pipeline.',\n requestBody: { contentType: 'application/json', schema: pipelineUpdateSchema },\n responses: [\n { status: 200, description: 'Pipeline updated', schema: pipelineOkResponseSchema },\n ],\n errors: [\n { status: 400, description: 'Validation failed', schema: pipelineErrorSchema },\n { status: 404, description: 'Pipeline not found', schema: pipelineErrorSchema },\n ],\n },\n DELETE: {\n summary: 'Delete pipeline',\n description: 'Deletes a pipeline. Returns 409 if active deals exist.',\n requestBody: { contentType: 'application/json', schema: pipelineDeleteSchema },\n responses: [\n { status: 200, description: 'Pipeline deleted', schema: pipelineOkResponseSchema },\n ],\n errors: [\n { status: 409, description: 'Pipeline has active deals', schema: pipelineErrorSchema },\n { status: 404, description: 'Pipeline not found', schema: pipelineErrorSchema },\n ],\n },\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAClB,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AACnC,SAAS,0CAA0C;AAGnD,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,yBAAyB;AAClC,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,kCAAkC;AAGpC,MAAM,WAAW;AAAA,EACtB,KAAK,EAAE,aAAa,MAAM,iBAAiB,CAAC,0BAA0B,EAAE;AAAA,EACxE,MAAM,EAAE,aAAa,MAAM,iBAAiB,CAAC,4BAA4B,EAAE;AAAA,EAC3E,KAAK,EAAE,aAAa,MAAM,iBAAiB,CAAC,4BAA4B,EAAE;AAAA,EAC1E,QAAQ,EAAE,aAAa,MAAM,iBAAiB,CAAC,4BAA4B,EAAE;AAC/E;AAEA,eAAe,aACb,KACiG;AACjG,QAAM,YAAY,MAAM,uBAAuB;AAC/C,QAAM,OAAO,MAAM,mBAAmB,GAAG;AACzC,QAAM,EAAE,UAAU,IAAI,MAAM,oBAAoB;AAChD,MAAI,CAAC,KAAM,OAAM,IAAI,cAAc,KAAK,EAAE,OAAO,UAAU,iCAAiC,cAAc,EAAE,CAAC;AAC7G,QAAM,QAAQ,MAAM,mCAAmC,EAAE,WAAW,MAAM,SAAS,IAAI,CAAC;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MAChF;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,aAAa,EAAE,aAAa,oBAAoB,QAAQ,qBAAqB;AAAA,MAC7E,WAAW;AAAA,QACT,EAAE,QAAQ,KAAK,aAAa,oBAAoB,QAAQ,yBAAyB;AAAA,MACnF;AAAA,MACA,QAAQ;AAAA,QACN,EAAE,QAAQ,KAAK,aAAa,6BAA6B,QAAQ,oBAAoB;AAAA,QACrF,EAAE,QAAQ,KAAK,aAAa,sBAAsB,QAAQ,oBAAoB;AAAA,MAChF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,9 +2,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
|
|
3
3
|
import DictionarySettings from "../../../components/DictionarySettings.js";
|
|
4
4
|
import AddressFormatSettings from "../../../components/AddressFormatSettings.js";
|
|
5
|
+
import PipelineSettings from "../../../components/PipelineSettings.js";
|
|
5
6
|
function CustomersConfigurationPage() {
|
|
6
7
|
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsxs("div", { className: "space-y-8", children: [
|
|
7
8
|
/* @__PURE__ */ jsx(AddressFormatSettings, {}),
|
|
9
|
+
/* @__PURE__ */ jsx(PipelineSettings, {}),
|
|
8
10
|
/* @__PURE__ */ jsx(DictionarySettings, {})
|
|
9
11
|
] }) }) });
|
|
10
12
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/customers/backend/config/customers/page.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport DictionarySettings from '../../../components/DictionarySettings'\nimport AddressFormatSettings from '../../../components/AddressFormatSettings'\n\nexport default function CustomersConfigurationPage() {\n return (\n <Page>\n <PageBody>\n <div className=\"space-y-8\">\n <AddressFormatSettings />\n <DictionarySettings />\n </div>\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport DictionarySettings from '../../../components/DictionarySettings'\nimport AddressFormatSettings from '../../../components/AddressFormatSettings'\nimport PipelineSettings from '../../../components/PipelineSettings'\n\nexport default function CustomersConfigurationPage() {\n return (\n <Page>\n <PageBody>\n <div className=\"space-y-8\">\n <AddressFormatSettings />\n <PipelineSettings />\n <DictionarySettings />\n </div>\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": "AASM,SACE,KADF;AATN,SAAS,MAAM,gBAAgB;AAC/B,OAAO,wBAAwB;AAC/B,OAAO,2BAA2B;AAClC,OAAO,sBAAsB;AAEd,SAAR,6BAA8C;AACnD,SACE,oBAAC,QACD,8BAAC,YACC,+BAAC,SAAI,WAAU,aACb;AAAA,wBAAC,yBAAsB;AAAA,IACvB,oBAAC,oBAAiB;AAAA,IAClB,oBAAC,sBAAmB;AAAA,KACtB,GACF,GACA;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|