@open-mercato/core 0.6.8-develop.7032.1.70d74d4bfe → 0.6.8-develop.7038.1.ea954afd80
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/customers/ai-tools/deal-analyzer-pack.js +13 -2
- package/dist/modules/customers/ai-tools/deal-analyzer-pack.js.map +2 -2
- package/dist/modules/integrations/api/[id]/credentials/route.js +6 -1
- package/dist/modules/integrations/api/[id]/credentials/route.js.map +2 -2
- package/dist/modules/integrations/backend/integrations/[id]/page.js +38 -29
- package/dist/modules/integrations/backend/integrations/[id]/page.js.map +2 -2
- package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js +36 -9
- package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js.map +2 -2
- package/dist/modules/integrations/backend/integrations/credential-secret-fields.js +55 -0
- package/dist/modules/integrations/backend/integrations/credential-secret-fields.js.map +7 -0
- package/dist/modules/integrations/data/validators.js +11 -3
- package/dist/modules/integrations/data/validators.js.map +2 -2
- package/dist/modules/integrations/lib/credentials-masking.js +6 -2
- package/dist/modules/integrations/lib/credentials-masking.js.map +2 -2
- package/dist/modules/wms/api/zones/route.js +15 -2
- package/dist/modules/wms/api/zones/route.js.map +2 -2
- package/dist/modules/wms/commands/configuration.js +64 -6
- package/dist/modules/wms/commands/configuration.js.map +2 -2
- package/dist/modules/wms/commands/shared.js +5 -1
- package/dist/modules/wms/commands/shared.js.map +2 -2
- package/dist/modules/wms/components/backend/WmsConfigurationPage.js +43 -8
- package/dist/modules/wms/components/backend/WmsConfigurationPage.js.map +3 -3
- package/package.json +7 -7
- package/src/modules/customers/ai-tools/deal-analyzer-pack.ts +17 -2
- package/src/modules/integrations/api/[id]/credentials/route.ts +6 -4
- package/src/modules/integrations/backend/integrations/[id]/page.tsx +61 -31
- package/src/modules/integrations/backend/integrations/bundle/[id]/page.tsx +44 -9
- package/src/modules/integrations/backend/integrations/credential-secret-fields.ts +84 -0
- package/src/modules/integrations/data/validators.ts +12 -2
- package/src/modules/integrations/i18n/de.json +1 -0
- package/src/modules/integrations/i18n/en.json +1 -0
- package/src/modules/integrations/i18n/es.json +1 -0
- package/src/modules/integrations/i18n/ko.json +1 -0
- package/src/modules/integrations/i18n/pl.json +1 -0
- package/src/modules/integrations/lib/credentials-masking.ts +10 -6
- package/src/modules/wms/api/zones/route.ts +16 -0
- package/src/modules/wms/commands/configuration.ts +89 -6
- package/src/modules/wms/commands/shared.ts +8 -0
- package/src/modules/wms/components/backend/WmsConfigurationPage.tsx +65 -8
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { registerCommand } from "@open-mercato/shared/lib/commands";
|
|
2
2
|
import { withAtomicFlush } from "@open-mercato/shared/lib/commands/flush";
|
|
3
|
+
import {
|
|
4
|
+
emitCrudSideEffects,
|
|
5
|
+
emitCrudUndoSideEffects,
|
|
6
|
+
parseWithCustomFields,
|
|
7
|
+
setCustomFieldsIfAny
|
|
8
|
+
} from "@open-mercato/shared/lib/commands/helpers";
|
|
9
|
+
import { buildCustomFieldResetMap, loadCustomFieldSnapshot } from "@open-mercato/shared/lib/commands/customFieldSnapshots";
|
|
3
10
|
import { CrudHttpError, isUniqueViolation } from "@open-mercato/shared/lib/crud/errors";
|
|
4
11
|
import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
|
|
5
12
|
import { findOneWithDecryption, findWithDecryption } from "@open-mercato/shared/lib/encryption/find";
|
|
6
13
|
import { extractUndoPayload } from "@open-mercato/shared/lib/commands/undo";
|
|
14
|
+
import { E } from "../../../generated/entities.ids.generated.js";
|
|
7
15
|
import {
|
|
8
16
|
InventoryLot,
|
|
9
17
|
ProductInventoryProfile,
|
|
@@ -28,7 +36,8 @@ import {
|
|
|
28
36
|
ensureTenantScope,
|
|
29
37
|
normalizeOptionalString,
|
|
30
38
|
requireId,
|
|
31
|
-
toNumericString
|
|
39
|
+
toNumericString,
|
|
40
|
+
warehouseZoneCrudIndexer
|
|
32
41
|
} from "./shared.js";
|
|
33
42
|
import { emitWmsEvent } from "../events.js";
|
|
34
43
|
function resolveScope(ctx, fallback) {
|
|
@@ -141,7 +150,44 @@ function snapshotWarehouseZone(record) {
|
|
|
141
150
|
}
|
|
142
151
|
async function loadWarehouseZoneSnapshot(em, ctx, id) {
|
|
143
152
|
const record = await findOneWithDecryption(em, WarehouseZone, { id }, void 0, resolveScope(ctx));
|
|
144
|
-
|
|
153
|
+
if (!record) return null;
|
|
154
|
+
const snapshot = snapshotWarehouseZone(record);
|
|
155
|
+
snapshot.custom = await loadCustomFieldSnapshot(em, {
|
|
156
|
+
entityId: E.wms.warehouse_zone,
|
|
157
|
+
recordId: record.id,
|
|
158
|
+
tenantId: record.tenantId,
|
|
159
|
+
organizationId: record.organizationId
|
|
160
|
+
});
|
|
161
|
+
return snapshot;
|
|
162
|
+
}
|
|
163
|
+
async function writeZoneCustomFields(ctx, zone, values) {
|
|
164
|
+
if (!values || !Object.keys(values).length) return;
|
|
165
|
+
await setCustomFieldsIfAny({
|
|
166
|
+
dataEngine: ctx.container.resolve("dataEngine"),
|
|
167
|
+
entityId: E.wms.warehouse_zone,
|
|
168
|
+
recordId: zone.id,
|
|
169
|
+
organizationId: zone.organizationId,
|
|
170
|
+
tenantId: zone.tenantId,
|
|
171
|
+
values
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async function emitZoneCrudSideEffects(ctx, action, zone, origin = "write") {
|
|
175
|
+
const options = {
|
|
176
|
+
dataEngine: ctx.container.resolve("dataEngine"),
|
|
177
|
+
action,
|
|
178
|
+
entity: zone,
|
|
179
|
+
identifiers: {
|
|
180
|
+
id: zone.id,
|
|
181
|
+
organizationId: zone.organizationId,
|
|
182
|
+
tenantId: zone.tenantId
|
|
183
|
+
},
|
|
184
|
+
indexer: warehouseZoneCrudIndexer
|
|
185
|
+
};
|
|
186
|
+
if (origin === "undo") {
|
|
187
|
+
await emitCrudUndoSideEffects(options);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
await emitCrudSideEffects(options);
|
|
145
191
|
}
|
|
146
192
|
function snapshotWarehouseLocation(record) {
|
|
147
193
|
const warehouseId = typeof record.warehouse === "string" ? record.warehouse : record.warehouse.id;
|
|
@@ -720,11 +766,12 @@ async function restoreZoneFromSnapshot(em, before) {
|
|
|
720
766
|
record.metadata = before.metadata;
|
|
721
767
|
record.deletedAt = null;
|
|
722
768
|
}
|
|
769
|
+
return record;
|
|
723
770
|
}
|
|
724
771
|
const createWarehouseZoneCommand = {
|
|
725
772
|
id: "wms.zones.create",
|
|
726
773
|
async execute(rawInput, ctx) {
|
|
727
|
-
const parsed = warehouseZoneCreateSchema
|
|
774
|
+
const { parsed, custom } = parseWithCustomFields(warehouseZoneCreateSchema, rawInput ?? {});
|
|
728
775
|
ensureTenantScope(ctx, parsed.tenantId);
|
|
729
776
|
ensureOrganizationScope(ctx, parsed.organizationId);
|
|
730
777
|
const em = resolveEm(ctx);
|
|
@@ -740,6 +787,8 @@ const createWarehouseZoneCommand = {
|
|
|
740
787
|
metadata: toJsonValue(parsed.metadata)
|
|
741
788
|
});
|
|
742
789
|
await em.persist(zone).flush();
|
|
790
|
+
await writeZoneCustomFields(ctx, zone, custom);
|
|
791
|
+
await emitZoneCrudSideEffects(ctx, "created", zone);
|
|
743
792
|
void emitWmsEvent("wms.zone.created", {
|
|
744
793
|
id: zone.id,
|
|
745
794
|
zoneId: zone.id,
|
|
@@ -775,6 +824,8 @@ const createWarehouseZoneCommand = {
|
|
|
775
824
|
ensureOrganizationScope(ctx, record.organizationId);
|
|
776
825
|
record.deletedAt = /* @__PURE__ */ new Date();
|
|
777
826
|
await em.flush();
|
|
827
|
+
await writeZoneCustomFields(ctx, record, buildCustomFieldResetMap(void 0, after.custom));
|
|
828
|
+
await emitZoneCrudSideEffects(ctx, "deleted", record, "undo");
|
|
778
829
|
}
|
|
779
830
|
};
|
|
780
831
|
const updateWarehouseZoneCommand = {
|
|
@@ -786,7 +837,7 @@ const updateWarehouseZoneCommand = {
|
|
|
786
837
|
return before ? { before } : {};
|
|
787
838
|
},
|
|
788
839
|
async execute(rawInput, ctx) {
|
|
789
|
-
const parsed = warehouseZoneUpdateSchema
|
|
840
|
+
const { parsed, custom } = parseWithCustomFields(warehouseZoneUpdateSchema, rawInput ?? {});
|
|
790
841
|
const em = resolveEm(ctx);
|
|
791
842
|
const zone = await loadZone(em, ctx, parsed.id);
|
|
792
843
|
if (parsed.warehouseId !== void 0) {
|
|
@@ -802,6 +853,8 @@ const updateWarehouseZoneCommand = {
|
|
|
802
853
|
if (parsed.priority !== void 0) zone.priority = parsed.priority;
|
|
803
854
|
if (parsed.metadata !== void 0) zone.metadata = toJsonValue(parsed.metadata);
|
|
804
855
|
await em.flush();
|
|
856
|
+
await writeZoneCustomFields(ctx, zone, custom);
|
|
857
|
+
await emitZoneCrudSideEffects(ctx, "updated", zone);
|
|
805
858
|
void emitWmsEvent("wms.zone.updated", {
|
|
806
859
|
id: zone.id,
|
|
807
860
|
zoneId: zone.id,
|
|
@@ -828,8 +881,10 @@ const updateWarehouseZoneCommand = {
|
|
|
828
881
|
const em = resolveEm(ctx);
|
|
829
882
|
ensureTenantScope(ctx, before.tenantId);
|
|
830
883
|
ensureOrganizationScope(ctx, before.organizationId);
|
|
831
|
-
await restoreZoneFromSnapshot(em, before);
|
|
884
|
+
const record = await restoreZoneFromSnapshot(em, before);
|
|
832
885
|
await em.flush();
|
|
886
|
+
await writeZoneCustomFields(ctx, record, buildCustomFieldResetMap(before.custom, payload?.after?.custom));
|
|
887
|
+
await emitZoneCrudSideEffects(ctx, "updated", record, "undo");
|
|
833
888
|
}
|
|
834
889
|
};
|
|
835
890
|
const deleteWarehouseZoneCommand = {
|
|
@@ -846,6 +901,7 @@ const deleteWarehouseZoneCommand = {
|
|
|
846
901
|
const zone = await loadZone(em, ctx, zoneId);
|
|
847
902
|
zone.deletedAt = /* @__PURE__ */ new Date();
|
|
848
903
|
await em.flush();
|
|
904
|
+
await emitZoneCrudSideEffects(ctx, "deleted", zone);
|
|
849
905
|
return { zoneId: zone.id };
|
|
850
906
|
},
|
|
851
907
|
buildLog: async ({ input, result, ctx, snapshots }) => {
|
|
@@ -860,8 +916,10 @@ const deleteWarehouseZoneCommand = {
|
|
|
860
916
|
const em = resolveEm(ctx);
|
|
861
917
|
ensureTenantScope(ctx, before.tenantId);
|
|
862
918
|
ensureOrganizationScope(ctx, before.organizationId);
|
|
863
|
-
await restoreZoneFromSnapshot(em, before);
|
|
919
|
+
const record = await restoreZoneFromSnapshot(em, before);
|
|
864
920
|
await em.flush();
|
|
921
|
+
await writeZoneCustomFields(ctx, record, buildCustomFieldResetMap(before.custom, void 0));
|
|
922
|
+
await emitZoneCrudSideEffects(ctx, "created", record, "undo");
|
|
865
923
|
}
|
|
866
924
|
};
|
|
867
925
|
async function restoreLocationFromSnapshot(em, before) {
|