@open-mercato/core 0.11.1-develop.8538.1.78ea48b6e6 → 0.11.1-develop.8545.1.dd603570fd
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/.turbo/turbo-build.log +1 -1
- package/dist/modules/customer_accounts/api/admin/users/[id].js +10 -9
- package/dist/modules/customer_accounts/api/admin/users/[id].js.map +2 -2
- package/dist/modules/customer_accounts/api/portal/notifications/[id]/dismiss.js +3 -2
- package/dist/modules/customer_accounts/api/portal/notifications/[id]/dismiss.js.map +2 -2
- package/dist/modules/customer_accounts/api/portal/notifications/[id]/read.js +3 -2
- package/dist/modules/customer_accounts/api/portal/notifications/[id]/read.js.map +2 -2
- package/dist/modules/customer_accounts/api/portal/notifications/mark-all-read.js +4 -0
- package/dist/modules/customer_accounts/api/portal/notifications/mark-all-read.js.map +2 -2
- package/dist/modules/customer_accounts/api/portal/notifications/unread-count.js +4 -0
- package/dist/modules/customer_accounts/api/portal/notifications/unread-count.js.map +2 -2
- package/dist/modules/customer_accounts/api/portal/notifications.js +4 -0
- package/dist/modules/customer_accounts/api/portal/notifications.js.map +2 -2
- package/dist/modules/customer_accounts/lib/customerEntityOwnership.js +12 -1
- package/dist/modules/customer_accounts/lib/customerEntityOwnership.js.map +2 -2
- package/dist/modules/customer_accounts/lib/moduleEntityRegistration.js +8 -0
- package/dist/modules/customer_accounts/lib/moduleEntityRegistration.js.map +7 -0
- package/dist/modules/customer_accounts/lib/portalNotificationsAvailability.js +9 -0
- package/dist/modules/customer_accounts/lib/portalNotificationsAvailability.js.map +7 -0
- package/dist/modules/directory/utils/organizationScope.js +3 -2
- package/dist/modules/directory/utils/organizationScope.js.map +2 -2
- package/dist/modules/entities/api/records.js +4 -3
- package/dist/modules/entities/api/records.js.map +2 -2
- package/dist/modules/entities/backend/entities/user/[entityId]/records/page.js +22 -38
- package/dist/modules/entities/backend/entities/user/[entityId]/records/page.js.map +2 -2
- package/dist/modules/progress/api/active/route.js +11 -3
- package/dist/modules/progress/api/active/route.js.map +2 -2
- package/dist/modules/progress/api/jobPermissions.js +42 -0
- package/dist/modules/progress/api/jobPermissions.js.map +7 -0
- package/dist/modules/progress/api/jobs/[id]/route.js +6 -11
- package/dist/modules/progress/api/jobs/[id]/route.js.map +2 -2
- package/dist/modules/wms/index.js +1 -1
- package/dist/modules/wms/index.js.map +2 -2
- package/dist/modules/wms/setup.js +4 -1
- package/dist/modules/wms/setup.js.map +2 -2
- package/dist/modules/workflows/api/events/route.js +1 -1
- package/dist/modules/workflows/api/events/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/[id]/events/route.js +1 -1
- package/dist/modules/workflows/api/instances/[id]/events/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/[id]/steps/route.js +1 -1
- package/dist/modules/workflows/api/instances/[id]/steps/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/failure-queue/route.js +1 -1
- package/dist/modules/workflows/api/instances/failure-queue/route.js.map +2 -2
- package/dist/modules/workflows/lib/event-logger.js +1 -1
- package/dist/modules/workflows/lib/event-logger.js.map +2 -2
- package/dist/modules/workflows/lib/work-inbox/user-task-source.js +1 -1
- package/dist/modules/workflows/lib/work-inbox/user-task-source.js.map +2 -2
- package/package.json +7 -7
- package/src/modules/customer_accounts/api/admin/users/[id].ts +10 -9
- package/src/modules/customer_accounts/api/portal/notifications/[id]/dismiss.ts +8 -5
- package/src/modules/customer_accounts/api/portal/notifications/[id]/read.ts +8 -5
- package/src/modules/customer_accounts/api/portal/notifications/mark-all-read.ts +4 -0
- package/src/modules/customer_accounts/api/portal/notifications/unread-count.ts +4 -0
- package/src/modules/customer_accounts/api/portal/notifications.ts +4 -0
- package/src/modules/customer_accounts/lib/customerEntityOwnership.ts +13 -1
- package/src/modules/customer_accounts/lib/moduleEntityRegistration.ts +12 -0
- package/src/modules/customer_accounts/lib/portalNotificationsAvailability.ts +7 -0
- package/src/modules/directory/utils/organizationScope.ts +3 -2
- package/src/modules/entities/api/records.ts +4 -3
- package/src/modules/entities/backend/entities/user/[entityId]/records/page.tsx +25 -31
- package/src/modules/entities/i18n/de.json +20 -1
- package/src/modules/entities/i18n/en.json +20 -1
- package/src/modules/entities/i18n/es.json +20 -1
- package/src/modules/entities/i18n/ko.json +20 -1
- package/src/modules/entities/i18n/pl.json +20 -1
- package/src/modules/progress/api/active/route.ts +18 -3
- package/src/modules/progress/api/jobPermissions.ts +50 -0
- package/src/modules/progress/api/jobs/[id]/route.ts +7 -20
- package/src/modules/wms/index.ts +1 -1
- package/src/modules/wms/setup.ts +4 -1
- package/src/modules/workflows/api/events/route.ts +1 -1
- package/src/modules/workflows/api/instances/[id]/events/route.ts +1 -1
- package/src/modules/workflows/api/instances/[id]/steps/route.ts +3 -2
- package/src/modules/workflows/api/instances/failure-queue/route.ts +1 -1
- package/src/modules/workflows/lib/event-logger.ts +1 -1
- package/src/modules/workflows/lib/work-inbox/user-task-source.ts +3 -2
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server'
|
|
2
2
|
import { z } from 'zod'
|
|
3
|
-
import { getAuthFromRequest
|
|
3
|
+
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
4
4
|
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
5
|
-
import type { AwilixContainer } from 'awilix'
|
|
6
|
-
import type { RbacService } from '@open-mercato/core/modules/auth/services/rbacService'
|
|
7
5
|
import { updateProgressSchema } from '../../../data/validators'
|
|
8
|
-
import type { ProgressJob } from '../../../data/entities'
|
|
9
6
|
import type { ProgressService } from '../../../lib/progressService'
|
|
7
|
+
import { createProgressJobMutationPolicy, progressCancelFeatures } from '../../jobPermissions'
|
|
10
8
|
import {
|
|
11
9
|
hasReadableProgressScope,
|
|
12
10
|
hasWritableProgressScope,
|
|
@@ -16,26 +14,13 @@ import {
|
|
|
16
14
|
const routeMetadata = {
|
|
17
15
|
GET: { requireAuth: true, requireFeatures: ['progress.view'] },
|
|
18
16
|
PUT: { requireAuth: true, requireFeatures: ['progress.update'] },
|
|
19
|
-
DELETE: { requireAuth: true, requireFeatures:
|
|
17
|
+
DELETE: { requireAuth: true, requireFeatures: progressCancelFeatures },
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
export const metadata = routeMetadata
|
|
23
21
|
|
|
24
22
|
const jobIdSchema = z.guid()
|
|
25
23
|
|
|
26
|
-
async function canMutateProgressJob(
|
|
27
|
-
container: AwilixContainer,
|
|
28
|
-
auth: NonNullable<AuthContext>,
|
|
29
|
-
job: Pick<ProgressJob, 'startedByUserId' | 'organizationId'>,
|
|
30
|
-
): Promise<boolean> {
|
|
31
|
-
if (job.startedByUserId === auth.sub) return true
|
|
32
|
-
const rbacService = container.resolve('rbacService') as RbacService
|
|
33
|
-
return rbacService.userHasAllFeatures(auth.sub, ['progress.manage'], {
|
|
34
|
-
tenantId: auth.tenantId ?? null,
|
|
35
|
-
organizationId: job.organizationId ?? null,
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
24
|
function cannotCancelJobResponse() {
|
|
40
25
|
return NextResponse.json({ error: 'Cannot cancel this job' }, { status: 400 })
|
|
41
26
|
}
|
|
@@ -118,7 +103,8 @@ export async function PUT(req: Request, { params }: { params: { id: string } })
|
|
|
118
103
|
const existing = jobIdSchema.safeParse(params.id).success
|
|
119
104
|
? await progressService.getJob(params.id, progressContext)
|
|
120
105
|
: null
|
|
121
|
-
|
|
106
|
+
const canMutateJob = createProgressJobMutationPolicy(container, auth)
|
|
107
|
+
if (!existing || !(await canMutateJob(existing))) {
|
|
122
108
|
return NextResponse.json({ error: 'Not found' }, { status: 404 })
|
|
123
109
|
}
|
|
124
110
|
|
|
@@ -147,7 +133,8 @@ export async function DELETE(req: Request, { params }: { params: { id: string }
|
|
|
147
133
|
}
|
|
148
134
|
try {
|
|
149
135
|
const existing = await progressService.getJob(params.id, progressContext)
|
|
150
|
-
|
|
136
|
+
const canMutateJob = createProgressJobMutationPolicy(container, auth)
|
|
137
|
+
if (!existing || !(await canMutateJob(existing))) {
|
|
151
138
|
return cannotCancelJobResponse()
|
|
152
139
|
}
|
|
153
140
|
await progressService.cancelJob(params.id, progressContext)
|
package/src/modules/wms/index.ts
CHANGED
package/src/modules/wms/setup.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
|
|
2
2
|
import { ensureRoles } from '@open-mercato/core/modules/auth/lib/setup-app'
|
|
3
|
+
import { FeatureToggle } from '@open-mercato/core/modules/feature_toggles/data/entities'
|
|
3
4
|
import {
|
|
4
5
|
WMS_CUSTOM_ROLE_NAMES,
|
|
5
6
|
WMS_OPERATOR_FEATURES,
|
|
@@ -15,7 +16,9 @@ async function seedWmsRoles(em: Parameters<typeof ensureRoles>[0], tenantId: str
|
|
|
15
16
|
|
|
16
17
|
export const setup: ModuleSetupConfig = {
|
|
17
18
|
seedDefaults: async (ctx) => {
|
|
18
|
-
|
|
19
|
+
if (ctx.em.getMetadata().find(FeatureToggle)) {
|
|
20
|
+
await seedWmsIntegrationToggles(ctx.em)
|
|
21
|
+
}
|
|
19
22
|
await seedWmsRoles(ctx.em, ctx.tenantId)
|
|
20
23
|
},
|
|
21
24
|
defaultRoleFeatures: {
|
|
@@ -90,7 +90,8 @@ export async function GET(request: NextRequest, context: RouteContext) {
|
|
|
90
90
|
|
|
91
91
|
// Ordered by when the step was entered so the Gantt and the overlay read the
|
|
92
92
|
// run in execution order. `createdAt` is the tiebreaker because a step
|
|
93
|
-
// instance is persisted before `enteredAt` is stamped on some paths
|
|
93
|
+
// instance is persisted before `enteredAt` is stamped on some paths, and
|
|
94
|
+
// `id` comes last so steps sharing both timestamps page deterministically.
|
|
94
95
|
const [steps, total] = await em.findAndCount(
|
|
95
96
|
StepInstance,
|
|
96
97
|
{
|
|
@@ -99,7 +100,7 @@ export async function GET(request: NextRequest, context: RouteContext) {
|
|
|
99
100
|
...orgFilter.where,
|
|
100
101
|
},
|
|
101
102
|
{
|
|
102
|
-
orderBy: [{ enteredAt: 'ASC' }, { createdAt: 'ASC' }],
|
|
103
|
+
orderBy: [{ enteredAt: 'ASC' }, { createdAt: 'ASC' }, { id: 'ASC' }],
|
|
103
104
|
limit,
|
|
104
105
|
offset,
|
|
105
106
|
}
|
|
@@ -113,7 +113,7 @@ export async function GET(request: NextRequest) {
|
|
|
113
113
|
// Grouping first, over a bounded scan, so the group counts describe the
|
|
114
114
|
// same set the caller is paging through.
|
|
115
115
|
const scanned = (await em.find(WorkflowInstance, where, {
|
|
116
|
-
orderBy: { createdAt: 'DESC' },
|
|
116
|
+
orderBy: { createdAt: 'DESC', id: 'DESC' },
|
|
117
117
|
limit: FAILURE_GROUP_SCAN_LIMIT,
|
|
118
118
|
})) as WorkflowInstance[]
|
|
119
119
|
const scannedInputs = scanned.map(toTriageInput)
|
|
@@ -196,7 +196,8 @@ export function toUserTaskWorkInboxRow(task: UserTask, now: Date): WorkInboxRow
|
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
198
|
* SQL orders by due date (Postgres puts NULLs last on ASC, which is what the
|
|
199
|
-
* inbox wants)
|
|
199
|
+
* inbox wants), then by recency, then by `id` so the window is a total order
|
|
200
|
+
* and tied rows cannot shift between requests; the canonical priority → due → created
|
|
200
201
|
* ordering is applied by the merge service over the returned window, because
|
|
201
202
|
* `priority` is an authored label with no ordinal column to sort on. Phase 1 is
|
|
202
203
|
* a projection — a persisted sort key belongs with the `Task` entity, which
|
|
@@ -213,7 +214,7 @@ async function listUserTaskWorkItems(
|
|
|
213
214
|
const where = buildUserTaskWorkInboxWhere(query, context.scope, options)
|
|
214
215
|
|
|
215
216
|
const [tasks, total] = await em.findAndCount(UserTask, where, {
|
|
216
|
-
orderBy: [{ dueDate: 'ASC' }, { createdAt: 'DESC' }],
|
|
217
|
+
orderBy: [{ dueDate: 'ASC' }, { createdAt: 'DESC' }, { id: 'ASC' }],
|
|
217
218
|
limit: query.offset + query.limit,
|
|
218
219
|
offset: 0,
|
|
219
220
|
})
|