@open-mercato/core 0.5.1-develop.2744.9c8be0dd93 → 0.5.1-develop.2762.90c271efe2

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.
Files changed (41) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/modules/audit_logs/services/accessLogService.js +3 -4
  3. package/dist/modules/audit_logs/services/accessLogService.js.map +2 -2
  4. package/dist/modules/audit_logs/services/actionLogService.js +3 -2
  5. package/dist/modules/audit_logs/services/actionLogService.js.map +2 -2
  6. package/dist/modules/auth/api/users/route.js +38 -2
  7. package/dist/modules/auth/api/users/route.js.map +2 -2
  8. package/dist/modules/catalog/lib/bulkDelete.js +17 -14
  9. package/dist/modules/catalog/lib/bulkDelete.js.map +2 -2
  10. package/dist/modules/configs/lib/system-status.js +2 -1
  11. package/dist/modules/configs/lib/system-status.js.map +2 -2
  12. package/dist/modules/customer_accounts/api/portal/password-change.js +3 -1
  13. package/dist/modules/customer_accounts/api/portal/password-change.js.map +2 -2
  14. package/dist/modules/customers/api/deals/[id]/route.js +2 -1
  15. package/dist/modules/customers/api/deals/[id]/route.js.map +2 -2
  16. package/dist/modules/customers/api/interactions/route.js +2 -1
  17. package/dist/modules/customers/api/interactions/route.js.map +2 -2
  18. package/dist/modules/customers/lib/interactionReadModel.js +6 -1
  19. package/dist/modules/customers/lib/interactionReadModel.js.map +2 -2
  20. package/dist/modules/feature_toggles/lib/feature-flag-check.js +7 -3
  21. package/dist/modules/feature_toggles/lib/feature-flag-check.js.map +2 -2
  22. package/dist/modules/inbox_ops/encryption.js +47 -0
  23. package/dist/modules/inbox_ops/encryption.js.map +7 -0
  24. package/dist/modules/workflows/api/definitions/[id]/route.js +3 -0
  25. package/dist/modules/workflows/api/definitions/[id]/route.js.map +2 -2
  26. package/dist/modules/workflows/api/definitions/route.js +2 -0
  27. package/dist/modules/workflows/api/definitions/route.js.map +2 -2
  28. package/package.json +3 -3
  29. package/src/modules/audit_logs/services/accessLogService.ts +5 -4
  30. package/src/modules/audit_logs/services/actionLogService.ts +9 -2
  31. package/src/modules/auth/api/users/route.ts +55 -2
  32. package/src/modules/catalog/lib/bulkDelete.ts +17 -14
  33. package/src/modules/configs/lib/system-status.ts +2 -1
  34. package/src/modules/customer_accounts/api/portal/password-change.ts +6 -1
  35. package/src/modules/customers/api/deals/[id]/route.ts +2 -1
  36. package/src/modules/customers/api/interactions/route.ts +2 -1
  37. package/src/modules/customers/lib/interactionReadModel.ts +12 -1
  38. package/src/modules/feature_toggles/lib/feature-flag-check.ts +7 -4
  39. package/src/modules/inbox_ops/encryption.ts +51 -0
  40. package/src/modules/workflows/api/definitions/[id]/route.ts +7 -0
  41. package/src/modules/workflows/api/definitions/route.ts +6 -0
@@ -1,6 +1,6 @@
1
1
  import { FeatureToggle, FeatureToggleOverride } from "../data/entities"
2
2
  import { EntityManager } from "@mikro-orm/core"
3
- import { CacheService } from "@open-mercato/cache"
3
+ import { CacheService, runWithCacheTenant } from "@open-mercato/cache"
4
4
 
5
5
  type ToggleValueType = "boolean" | "string" | "number" | "json"
6
6
 
@@ -73,13 +73,16 @@ export class FeatureTogglesService {
73
73
  result: ToggleResolutionResult,
74
74
  ) {
75
75
  const key = getIsEnabledCacheKey(identifier, tenantId)
76
- await this.cache.set(key, result, { ttl: this.cacheTtlMs, tags: getCacheTags(identifier, tenantId) })
76
+ await runWithCacheTenant(
77
+ tenantId,
78
+ () => this.cache.set(key, result, { ttl: this.cacheTtlMs, tags: getCacheTags(identifier, tenantId) }),
79
+ )
77
80
  }
78
81
 
79
82
  private async resolveToggle(identifier: string, tenantId: string): Promise<ToggleResolutionResult> {
80
83
  const key = getIsEnabledCacheKey(identifier, tenantId)
81
84
 
82
- const cached = await this.cache.get(key)
85
+ const cached = await runWithCacheTenant(tenantId, () => this.cache.get(key))
83
86
  if (cached) {
84
87
  const parsed = toCachedResolution(cached)
85
88
  if (parsed) return parsed
@@ -122,7 +125,7 @@ export class FeatureTogglesService {
122
125
  }
123
126
 
124
127
  public async invalidateIsEnabledCacheByKey(identifier: string, tenantId: string) {
125
- await this.cache.delete(getIsEnabledCacheKey(identifier, tenantId))
128
+ await runWithCacheTenant(tenantId, () => this.cache.delete(getIsEnabledCacheKey(identifier, tenantId)))
126
129
  }
127
130
 
128
131
  public async getFeatureToggleValue<T>(
@@ -0,0 +1,51 @@
1
+ import type { ModuleEncryptionMap } from '@open-mercato/shared/modules/encryption'
2
+
3
+ // Message body, extracted business data, and correspondent identities all
4
+ // count as tenant PII. Columns routed through WHERE/ILIKE lookups or UNIQUE
5
+ // indexes (`inbox_settings.inbox_address`, `inbox_emails.message_id`,
6
+ // `in_reply_to`, `references`, `*.metadata`) are intentionally left plaintext
7
+ // for now — encrypting them requires paired `*_hash` columns plus rewriting
8
+ // the inbound-webhook lookups, which is out of scope for this fix.
9
+ export const defaultEncryptionMaps: ModuleEncryptionMap[] = [
10
+ {
11
+ entityId: 'inbox_ops:inbox_email',
12
+ fields: [
13
+ { field: 'subject' },
14
+ { field: 'raw_text' },
15
+ { field: 'raw_html' },
16
+ { field: 'cleaned_text' },
17
+ { field: 'thread_messages' },
18
+ { field: 'forwarded_by_address' },
19
+ { field: 'forwarded_by_name' },
20
+ { field: 'to_address' },
21
+ { field: 'reply_to' },
22
+ { field: 'processing_error' },
23
+ ],
24
+ },
25
+ {
26
+ entityId: 'inbox_ops:inbox_proposal',
27
+ fields: [
28
+ { field: 'summary' },
29
+ { field: 'participants' },
30
+ { field: 'translations' },
31
+ ],
32
+ },
33
+ {
34
+ entityId: 'inbox_ops:inbox_proposal_action',
35
+ fields: [
36
+ { field: 'description' },
37
+ { field: 'payload' },
38
+ { field: 'execution_error' },
39
+ ],
40
+ },
41
+ {
42
+ entityId: 'inbox_ops:inbox_discrepancy',
43
+ fields: [
44
+ { field: 'description' },
45
+ { field: 'expected_value' },
46
+ { field: 'found_value' },
47
+ ],
48
+ },
49
+ ]
50
+
51
+ export default defaultEncryptionMaps
@@ -19,6 +19,7 @@ import {
19
19
  type UpdateWorkflowDefinitionApiInput,
20
20
  } from '../../../data/validators'
21
21
  import { serializeWorkflowDefinition } from '../serialize'
22
+ import { invalidateTriggerCache } from '../../../lib/event-trigger-service'
22
23
 
23
24
  export const metadata = {
24
25
  requireAuth: true,
@@ -178,6 +179,10 @@ export async function PUT(
178
179
 
179
180
  await em.flush()
180
181
 
182
+ // Embedded triggers may have changed; invalidate the in-memory cache so
183
+ // the wildcard event subscriber reloads them on the next event.
184
+ if (tenantId) invalidateTriggerCache(tenantId, organizationId ?? undefined)
185
+
181
186
  return NextResponse.json({
182
187
  data: serializeWorkflowDefinition(definition),
183
188
  message: 'Workflow definition updated successfully',
@@ -269,6 +274,8 @@ export async function DELETE(
269
274
 
270
275
  await em.flush()
271
276
 
277
+ if (tenantId) invalidateTriggerCache(tenantId, organizationId ?? undefined)
278
+
272
279
  return NextResponse.json({
273
280
  message: 'Workflow definition deleted successfully',
274
281
  })
@@ -18,6 +18,7 @@ import {
18
18
  type CreateWorkflowDefinitionApiInput,
19
19
  } from '../../data/validators'
20
20
  import { serializeWorkflowDefinition } from './serialize'
21
+ import { invalidateTriggerCache } from '../../lib/event-trigger-service'
21
22
 
22
23
  export const metadata = {
23
24
  requireAuth: true,
@@ -209,6 +210,11 @@ export async function POST(request: NextRequest) {
209
210
 
210
211
  await em.persist(definition).flush()
211
212
 
213
+ // Newly-created embedded triggers must be visible to the wildcard event
214
+ // subscriber immediately; invalidate the in-memory trigger cache so the
215
+ // next event reload picks up this definition.
216
+ if (tenantId) invalidateTriggerCache(tenantId, organizationId ?? undefined)
217
+
212
218
  return NextResponse.json(
213
219
  {
214
220
  data: serializeWorkflowDefinition(definition),