@endora-commerce/mod-catalog 0.106.0 → 0.108.0
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/admin/components/PackagingUnitsEditor.d.ts +3 -0
- package/dist/admin/components/PackagingUnitsEditor.d.ts.map +1 -1
- package/dist/admin/components/PackagingUnitsEditor.js +51 -5
- package/dist/admin/components/PackagingUnitsEditor.js.map +1 -1
- package/dist/admin/components/ProductOrderRulesCard.d.ts +19 -0
- package/dist/admin/components/ProductOrderRulesCard.d.ts.map +1 -0
- package/dist/admin/components/ProductOrderRulesCard.js +147 -0
- package/dist/admin/components/ProductOrderRulesCard.js.map +1 -0
- package/dist/admin/components/ProductsBulkEditDialog.d.ts.map +1 -1
- package/dist/admin/components/ProductsBulkEditDialog.js +31 -3
- package/dist/admin/components/ProductsBulkEditDialog.js.map +1 -1
- package/dist/admin/pages/CategoriesTree.d.ts.map +1 -1
- package/dist/admin/pages/CategoriesTree.js +21 -4
- package/dist/admin/pages/CategoriesTree.js.map +1 -1
- package/dist/admin/pages/ProductEditor.d.ts.map +1 -1
- package/dist/admin/pages/ProductEditor.js +12 -33
- package/dist/admin/pages/ProductEditor.js.map +1 -1
- package/dist/admin/pages/ProductsList.d.ts.map +1 -1
- package/dist/admin/pages/ProductsList.js +36 -3
- package/dist/admin/pages/ProductsList.js.map +1 -1
- package/dist/backend/admin-search-provider.d.ts +56 -0
- package/dist/backend/admin-search-provider.d.ts.map +1 -0
- package/dist/backend/admin-search-provider.js +109 -0
- package/dist/backend/admin-search-provider.js.map +1 -0
- package/dist/backend/demo/reset.d.ts +1 -1
- package/dist/backend/demo/rows.d.ts +7 -3
- package/dist/backend/demo/rows.d.ts.map +1 -1
- package/dist/backend/demo/rows.js +7 -5
- package/dist/backend/demo/rows.js.map +1 -1
- package/dist/backend/demo/seed.d.ts.map +1 -1
- package/dist/backend/demo/seed.js +1 -4
- package/dist/backend/demo/seed.js.map +1 -1
- package/dist/backend/entities/product-list-saved-view.entity.d.ts +31 -0
- package/dist/backend/entities/product-list-saved-view.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-list-saved-view.entity.js +75 -0
- package/dist/backend/entities/product-list-saved-view.entity.js.map +1 -0
- package/dist/backend/entities/product-packaging-unit.entity.d.ts +7 -1
- package/dist/backend/entities/product-packaging-unit.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-packaging-unit.entity.js +10 -0
- package/dist/backend/entities/product-packaging-unit.entity.js.map +1 -1
- package/dist/backend/entities/product-variant.entity.d.ts +1 -2
- package/dist/backend/entities/product-variant.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-variant.entity.js +0 -5
- package/dist/backend/entities/product-variant.entity.js.map +1 -1
- package/dist/backend/entities/product.entity.d.ts +25 -1
- package/dist/backend/entities/product.entity.d.ts.map +1 -1
- package/dist/backend/entities/product.entity.js +60 -0
- package/dist/backend/entities/product.entity.js.map +1 -1
- package/dist/backend/index.d.ts +5 -5
- package/dist/backend/index.d.ts.map +1 -1
- package/dist/backend/index.js +24 -4
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/plugin.d.ts +7 -2
- package/dist/backend/plugin.d.ts.map +1 -1
- package/dist/backend/plugin.js +4 -0
- package/dist/backend/plugin.js.map +1 -1
- package/dist/backend/routes.admin.d.ts +6 -0
- package/dist/backend/routes.admin.d.ts.map +1 -1
- package/dist/backend/routes.admin.js +68 -2
- package/dist/backend/routes.admin.js.map +1 -1
- package/dist/backend/routes.public.d.ts.map +1 -1
- package/dist/backend/routes.public.js +13 -8
- package/dist/backend/routes.public.js.map +1 -1
- package/dist/backend/saved-view-actor.d.ts +16 -0
- package/dist/backend/saved-view-actor.d.ts.map +1 -0
- package/dist/backend/saved-view-actor.js +24 -0
- package/dist/backend/saved-view-actor.js.map +1 -0
- package/dist/backend/services/catalog-admin-search.service.d.ts +32 -0
- package/dist/backend/services/catalog-admin-search.service.d.ts.map +1 -0
- package/dist/backend/services/catalog-admin-search.service.js +141 -0
- package/dist/backend/services/catalog-admin-search.service.js.map +1 -0
- package/dist/backend/services/catalog-admin.service.d.ts +14 -0
- package/dist/backend/services/catalog-admin.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-admin.service.js +69 -22
- package/dist/backend/services/catalog-admin.service.js.map +1 -1
- package/dist/backend/services/catalog-bulk-update.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-bulk-update.service.js +8 -1
- package/dist/backend/services/catalog-bulk-update.service.js.map +1 -1
- package/dist/backend/services/catalog-org-price-decorator.d.ts +7 -3
- package/dist/backend/services/catalog-org-price-decorator.d.ts.map +1 -1
- package/dist/backend/services/catalog-org-price-decorator.js +32 -23
- package/dist/backend/services/catalog-org-price-decorator.js.map +1 -1
- package/dist/backend/services/catalog-product-read.service.d.ts +52 -3
- package/dist/backend/services/catalog-product-read.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-product-read.service.js +153 -3
- package/dist/backend/services/catalog-product-read.service.js.map +1 -1
- package/dist/backend/services/catalog-query.service.d.ts +19 -3
- package/dist/backend/services/catalog-query.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-query.service.js +416 -89
- package/dist/backend/services/catalog-query.service.js.map +1 -1
- package/dist/backend/services/packaging-unit.service.d.ts.map +1 -1
- package/dist/backend/services/packaging-unit.service.js +39 -4
- package/dist/backend/services/packaging-unit.service.js.map +1 -1
- package/dist/backend/services/product-link.service.d.ts +5 -0
- package/dist/backend/services/product-link.service.d.ts.map +1 -1
- package/dist/backend/services/product-link.service.js +18 -6
- package/dist/backend/services/product-link.service.js.map +1 -1
- package/dist/backend/services/product-list-view-service.d.ts +53 -0
- package/dist/backend/services/product-list-view-service.d.ts.map +1 -0
- package/dist/backend/services/product-list-view-service.js +191 -0
- package/dist/backend/services/product-list-view-service.js.map +1 -0
- package/dist/backend/services/product-value-resolver.service.d.ts +11 -1
- package/dist/backend/services/product-value-resolver.service.d.ts.map +1 -1
- package/dist/backend/services/product-value-resolver.service.js +29 -9
- package/dist/backend/services/product-value-resolver.service.js.map +1 -1
- package/dist/backend/services/storefront-value-overrides.d.ts +31 -0
- package/dist/backend/services/storefront-value-overrides.d.ts.map +1 -0
- package/dist/backend/services/storefront-value-overrides.js +48 -0
- package/dist/backend/services/storefront-value-overrides.js.map +1 -0
- package/dist/manifest.d.ts +6 -2
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +39 -3
- package/dist/manifest.js.map +1 -1
- package/dist/migrations/20261014T170531_catalog_product_list_saved_views.d.ts +22 -0
- package/dist/migrations/20261014T170531_catalog_product_list_saved_views.d.ts.map +1 -0
- package/dist/migrations/20261014T170531_catalog_product_list_saved_views.js +38 -0
- package/dist/migrations/20261014T170531_catalog_product_list_saved_views.js.map +1 -0
- package/dist/migrations/20261016T082008_catalog_order_rules.d.ts +22 -0
- package/dist/migrations/20261016T082008_catalog_order_rules.d.ts.map +1 -0
- package/dist/migrations/20261016T082008_catalog_order_rules.js +48 -0
- package/dist/migrations/20261016T082008_catalog_order_rules.js.map +1 -0
- package/dist/migrations/20261022T111811_catalog_price_fields_removed.d.ts +26 -0
- package/dist/migrations/20261022T111811_catalog_price_fields_removed.d.ts.map +1 -0
- package/dist/migrations/20261022T111811_catalog_price_fields_removed.js +32 -0
- package/dist/migrations/20261022T111811_catalog_price_fields_removed.js.map +1 -0
- package/dist/migrations/20261022T182523_catalog_admin_name_keys.d.ts +38 -0
- package/dist/migrations/20261022T182523_catalog_admin_name_keys.d.ts.map +1 -0
- package/dist/migrations/20261022T182523_catalog_admin_name_keys.js +89 -0
- package/dist/migrations/20261022T182523_catalog_admin_name_keys.js.map +1 -0
- package/dist/migrations/index.d.ts +5 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +9 -1
- package/dist/migrations/index.js.map +1 -1
- package/docs/catalog/attributes.md +11 -6
- package/docs/catalog/packaging-units.md +44 -7
- package/docs/catalog/per-channel-per-language-overrides.md +36 -9
- package/docs/catalog.md +276 -4
- package/i18n/en.json +41 -5
- package/i18n/pl.json +41 -5
- package/package.json +9 -9
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { EntityManager } from '@mikro-orm/postgresql';
|
|
2
|
+
import { type SavedListView } from '@endora-commerce/contracts';
|
|
3
|
+
import type { PlatformLogger } from '@endora-commerce/platform/kernel';
|
|
4
|
+
export interface ProductSavedViewInput {
|
|
5
|
+
name: string;
|
|
6
|
+
shared: boolean;
|
|
7
|
+
filters: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export interface ProductSavedViewPatch {
|
|
10
|
+
name?: string | undefined;
|
|
11
|
+
shared?: boolean | undefined;
|
|
12
|
+
filters?: Record<string, unknown> | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** Who is asking: the admin, and whether they are a platform admin (research R-7). */
|
|
15
|
+
export interface ProductSavedViewActor {
|
|
16
|
+
adminUserId: string;
|
|
17
|
+
isPlatformAdmin: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* ProductListViewService — `specs/147-saved-views/` (US2).
|
|
21
|
+
*
|
|
22
|
+
* Per-admin saved filter presets for the admin product list, on the rules the
|
|
23
|
+
* order list's views follow (FR-013): a caller sees their own views plus every
|
|
24
|
+
* shared view; another admin's private view behaves as absent (404); a shared
|
|
25
|
+
* view is modified or deleted only by its owner or a platform admin (403
|
|
26
|
+
* otherwise). The product list has no sort or column control, so a view
|
|
27
|
+
* stores filters only.
|
|
28
|
+
*
|
|
29
|
+
* Names are stored trimmed, and one owner holds no two views whose names share
|
|
30
|
+
* a key (FR-022). `create` and a key-changing `update` take a
|
|
31
|
+
* transaction-scoped advisory lock keyed on the **view owner** and probe for
|
|
32
|
+
* the key inside the same transaction (research R-5, threat model S-04); the
|
|
33
|
+
* table's unique expression index on `(owner_admin_user_id, lower(name))` is
|
|
34
|
+
* the schema's own guarantee, and a violation of it answers the same 409.
|
|
35
|
+
*
|
|
36
|
+
* Saved views are personal UI configuration, not domain mutations: they do not
|
|
37
|
+
* run through the Command Bus (research R-14). When a platform admin modifies
|
|
38
|
+
* or deletes another admin's view, one structured `info` record is written
|
|
39
|
+
* instead (research R-18, S-11).
|
|
40
|
+
*/
|
|
41
|
+
export declare class ProductListViewService {
|
|
42
|
+
private readonly emFactory;
|
|
43
|
+
private readonly log?;
|
|
44
|
+
constructor(emFactory: () => EntityManager, log?: Pick<PlatformLogger, "info"> | undefined);
|
|
45
|
+
/** The caller's own views plus every shared view, ordered by name. */
|
|
46
|
+
listFor(actor: ProductSavedViewActor): Promise<SavedListView[]>;
|
|
47
|
+
create(actor: ProductSavedViewActor, input: ProductSavedViewInput): Promise<SavedListView>;
|
|
48
|
+
update(id: string, actor: ProductSavedViewActor, patch: ProductSavedViewPatch): Promise<SavedListView>;
|
|
49
|
+
remove(id: string, actor: ProductSavedViewActor): Promise<void>;
|
|
50
|
+
/** One trail line when the actor is not the owner (S-11); none otherwise. */
|
|
51
|
+
private logForeignWrite;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=product-list-view-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-list-view-service.d.ts","sourceRoot":"","sources":["../../../src/backend/services/product-list-view-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAqC,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACnG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAIvE,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC/C;AAED,sFAAsF;AACtF,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAID;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,sBAAsB;IAE/B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;gBADJ,SAAS,EAAE,MAAM,aAAa,EAC9B,GAAG,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,YAAA;IAGrD,sEAAsE;IAChE,OAAO,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAU/D,MAAM,CAAC,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC;IAsB1F,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC;IAqCtG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAWrE,6EAA6E;IAC7E,OAAO,CAAC,eAAe;CAiBxB"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { UniqueConstraintViolationException } from '@mikro-orm/core';
|
|
3
|
+
import { ERROR_CODES, savedListViewNameKey } from '@endora-commerce/contracts';
|
|
4
|
+
import { HttpError } from '@endora-commerce/platform/http';
|
|
5
|
+
import { ProductListSavedView } from '../entities/product-list-saved-view.entity.js';
|
|
6
|
+
const TABLE = 'product_list_saved_views';
|
|
7
|
+
/**
|
|
8
|
+
* ProductListViewService — `specs/147-saved-views/` (US2).
|
|
9
|
+
*
|
|
10
|
+
* Per-admin saved filter presets for the admin product list, on the rules the
|
|
11
|
+
* order list's views follow (FR-013): a caller sees their own views plus every
|
|
12
|
+
* shared view; another admin's private view behaves as absent (404); a shared
|
|
13
|
+
* view is modified or deleted only by its owner or a platform admin (403
|
|
14
|
+
* otherwise). The product list has no sort or column control, so a view
|
|
15
|
+
* stores filters only.
|
|
16
|
+
*
|
|
17
|
+
* Names are stored trimmed, and one owner holds no two views whose names share
|
|
18
|
+
* a key (FR-022). `create` and a key-changing `update` take a
|
|
19
|
+
* transaction-scoped advisory lock keyed on the **view owner** and probe for
|
|
20
|
+
* the key inside the same transaction (research R-5, threat model S-04); the
|
|
21
|
+
* table's unique expression index on `(owner_admin_user_id, lower(name))` is
|
|
22
|
+
* the schema's own guarantee, and a violation of it answers the same 409.
|
|
23
|
+
*
|
|
24
|
+
* Saved views are personal UI configuration, not domain mutations: they do not
|
|
25
|
+
* run through the Command Bus (research R-14). When a platform admin modifies
|
|
26
|
+
* or deletes another admin's view, one structured `info` record is written
|
|
27
|
+
* instead (research R-18, S-11).
|
|
28
|
+
*/
|
|
29
|
+
export class ProductListViewService {
|
|
30
|
+
emFactory;
|
|
31
|
+
log;
|
|
32
|
+
constructor(emFactory, log) {
|
|
33
|
+
this.emFactory = emFactory;
|
|
34
|
+
this.log = log;
|
|
35
|
+
}
|
|
36
|
+
/** The caller's own views plus every shared view, ordered by name. */
|
|
37
|
+
async listFor(actor) {
|
|
38
|
+
const em = this.emFactory();
|
|
39
|
+
const views = await em.find(ProductListSavedView, { $or: [{ ownerAdminUserId: actor.adminUserId }, { shared: true }] }, { orderBy: { name: 'asc' } });
|
|
40
|
+
return views.map((v) => toDto(v, actor));
|
|
41
|
+
}
|
|
42
|
+
async create(actor, input) {
|
|
43
|
+
const name = input.name.trim();
|
|
44
|
+
const view = await refuseDuplicateKey(() => this.emFactory().transactional(async (tx) => {
|
|
45
|
+
await assertNameAvailable(tx, actor.adminUserId, name);
|
|
46
|
+
// command-coverage-ignore: per-admin saved list preset — personal UI
|
|
47
|
+
// configuration, not a domain mutation.
|
|
48
|
+
const created = tx.create(ProductListSavedView, {
|
|
49
|
+
ownerAdminUserId: actor.adminUserId,
|
|
50
|
+
name,
|
|
51
|
+
shared: input.shared,
|
|
52
|
+
filters: input.filters,
|
|
53
|
+
});
|
|
54
|
+
// command-coverage-ignore: per-admin saved list preset — personal UI
|
|
55
|
+
// configuration, not a domain mutation.
|
|
56
|
+
await tx.persistAndFlush(created);
|
|
57
|
+
return created;
|
|
58
|
+
}));
|
|
59
|
+
return toDto(view, actor);
|
|
60
|
+
}
|
|
61
|
+
async update(id, actor, patch) {
|
|
62
|
+
const { view, changed } = await refuseDuplicateKey(() => this.emFactory().transactional(async (tx) => {
|
|
63
|
+
const found = await loadModifiable(tx, id, actor);
|
|
64
|
+
// A PATCH that changes nothing is answered as a read: no write and no
|
|
65
|
+
// trail line (security review SV-4). The gate above still applies.
|
|
66
|
+
let changed = false;
|
|
67
|
+
const name = patch.name?.trim();
|
|
68
|
+
if (name !== undefined && name !== found.name) {
|
|
69
|
+
// Only a change of key can create a conflict; changing a name's case
|
|
70
|
+
// only cannot.
|
|
71
|
+
if (savedListViewNameKey(name) !== savedListViewNameKey(found.name)) {
|
|
72
|
+
// The rule binds the view's owner, never the caller (S-04).
|
|
73
|
+
await assertNameAvailable(tx, found.ownerAdminUserId, name, found.id);
|
|
74
|
+
}
|
|
75
|
+
found.name = name;
|
|
76
|
+
changed = true;
|
|
77
|
+
}
|
|
78
|
+
if (patch.shared !== undefined && patch.shared !== found.shared) {
|
|
79
|
+
found.shared = patch.shared;
|
|
80
|
+
changed = true;
|
|
81
|
+
}
|
|
82
|
+
if (patch.filters !== undefined && !isDeepStrictEqual(patch.filters, found.filters)) {
|
|
83
|
+
found.filters = patch.filters;
|
|
84
|
+
changed = true;
|
|
85
|
+
}
|
|
86
|
+
if (!changed)
|
|
87
|
+
return { view: found, changed };
|
|
88
|
+
// command-coverage-ignore: per-admin saved list preset — personal UI
|
|
89
|
+
// configuration, not a domain mutation.
|
|
90
|
+
await tx.flush();
|
|
91
|
+
return { view: found, changed };
|
|
92
|
+
}));
|
|
93
|
+
if (changed)
|
|
94
|
+
this.logForeignWrite('saved_view.updated', view, actor);
|
|
95
|
+
return toDto(view, actor);
|
|
96
|
+
}
|
|
97
|
+
async remove(id, actor) {
|
|
98
|
+
const view = await this.emFactory().transactional(async (tx) => {
|
|
99
|
+
const found = await loadModifiable(tx, id, actor);
|
|
100
|
+
// command-coverage-ignore: per-admin saved list preset — personal UI
|
|
101
|
+
// configuration, not a domain mutation.
|
|
102
|
+
await tx.removeAndFlush(found);
|
|
103
|
+
return found;
|
|
104
|
+
});
|
|
105
|
+
this.logForeignWrite('saved_view.deleted', view, actor);
|
|
106
|
+
}
|
|
107
|
+
/** One trail line when the actor is not the owner (S-11); none otherwise. */
|
|
108
|
+
logForeignWrite(event, view, actor) {
|
|
109
|
+
if (view.ownerAdminUserId === actor.adminUserId)
|
|
110
|
+
return;
|
|
111
|
+
this.log?.info({
|
|
112
|
+
event,
|
|
113
|
+
list: TABLE,
|
|
114
|
+
viewId: view.id,
|
|
115
|
+
ownerAdminUserId: view.ownerAdminUserId,
|
|
116
|
+
actorAdminUserId: actor.adminUserId,
|
|
117
|
+
}, 'Saved product list view changed by an admin who does not own it.');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function nameTaken() {
|
|
121
|
+
return new HttpError(409, ERROR_CODES.PRODUCT_SAVED_VIEW_NAME_TAKEN, 'You already have a saved view with this name on the product list. Choose a different name.');
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The unique key index is the last word on a duplicate: should a write reach
|
|
125
|
+
* it past the probe, it answers the same 409 the probe does.
|
|
126
|
+
*/
|
|
127
|
+
async function refuseDuplicateKey(write) {
|
|
128
|
+
try {
|
|
129
|
+
return await write();
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
if (err instanceof UniqueConstraintViolationException)
|
|
133
|
+
throw nameTaken();
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Serialise this owner's saves on the product list and refuse a name whose key
|
|
139
|
+
* the owner already uses. Must run inside the caller's transaction: the lock
|
|
140
|
+
* is released when it ends, and both statements go through it.
|
|
141
|
+
*/
|
|
142
|
+
async function assertNameAvailable(tx, ownerAdminUserId, name, excludeId) {
|
|
143
|
+
await tx.execute('select pg_advisory_xact_lock(hashtextextended(?, 0))', [`${TABLE}:${ownerAdminUserId}`]);
|
|
144
|
+
const params = [ownerAdminUserId, name];
|
|
145
|
+
let sql = `select 1 from ${TABLE} where owner_admin_user_id = ? and lower(btrim(name)) = lower(btrim(?))`;
|
|
146
|
+
if (excludeId) {
|
|
147
|
+
sql += ' and id <> ?';
|
|
148
|
+
params.push(excludeId);
|
|
149
|
+
}
|
|
150
|
+
const rows = (await tx.execute(`${sql} limit 1`, params));
|
|
151
|
+
if (rows.length > 0)
|
|
152
|
+
throw nameTaken();
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The shape of a `uuid` column value. A view id that does not have it names no
|
|
156
|
+
* view, so it answers the same 404 as an absent one instead of reaching
|
|
157
|
+
* PostgreSQL, whose `invalid input syntax for type uuid` would surface as a
|
|
158
|
+
* 500. Shape only — deliberately looser than RFC 9562's version and variant
|
|
159
|
+
* bits, which PostgreSQL does not check either.
|
|
160
|
+
*/
|
|
161
|
+
const UUID_SHAPE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
162
|
+
async function loadModifiable(tx, id, actor) {
|
|
163
|
+
if (!UUID_SHAPE.test(id)) {
|
|
164
|
+
throw new HttpError(404, ERROR_CODES.NOT_FOUND, 'Saved view not found.');
|
|
165
|
+
}
|
|
166
|
+
const view = await tx.findOne(ProductListSavedView, { id });
|
|
167
|
+
if (!view)
|
|
168
|
+
throw new HttpError(404, ERROR_CODES.NOT_FOUND, 'Saved view not found.');
|
|
169
|
+
const owns = view.ownerAdminUserId === actor.adminUserId;
|
|
170
|
+
if (!view.shared && !owns) {
|
|
171
|
+
throw new HttpError(404, ERROR_CODES.NOT_FOUND, 'Saved view not found.');
|
|
172
|
+
}
|
|
173
|
+
// A shared view may only be modified or deleted by its owner or a platform admin.
|
|
174
|
+
if (view.shared && !owns && !actor.isPlatformAdmin) {
|
|
175
|
+
throw new HttpError(403, ERROR_CODES.FORBIDDEN, 'Only the owner can modify this shared view.');
|
|
176
|
+
}
|
|
177
|
+
return view;
|
|
178
|
+
}
|
|
179
|
+
function toDto(v, actor) {
|
|
180
|
+
const ownedByCaller = v.ownerAdminUserId === actor.adminUserId;
|
|
181
|
+
return {
|
|
182
|
+
id: v.id,
|
|
183
|
+
name: v.name,
|
|
184
|
+
shared: v.shared,
|
|
185
|
+
ownerAdminUserId: v.ownerAdminUserId,
|
|
186
|
+
ownedByCaller,
|
|
187
|
+
canModify: ownedByCaller || (v.shared && actor.isPlatformAdmin),
|
|
188
|
+
filters: v.filters,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=product-list-view-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-list-view-service.js","sourceRoot":"","sources":["../../../src/backend/services/product-list-view-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,kCAAkC,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAsB,MAAM,4BAA4B,CAAC;AAEnG,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAoBrF,MAAM,KAAK,GAAG,0BAA0B,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,sBAAsB;IAEd;IACA;IAFnB,YACmB,S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AAE,aAAa,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC;QAC/D,OAAO,EAAE,CAAC,CAAC,OAAO;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -2,6 +2,16 @@ import type { EntityManager } from '@mikro-orm/postgresql';
|
|
|
2
2
|
import { type AttributeScope, type OverrideRow, type Resolved, type ResolveAllResult, type LanguageReadPort, type ResolverContext } from '@endora-commerce/contracts';
|
|
3
3
|
import type { Product } from '../entities/product.entity.js';
|
|
4
4
|
import type { CatalogAttributeReadService } from './catalog-attribute-read.service.js';
|
|
5
|
+
/**
|
|
6
|
+
* The one read of `product_value_overrides`: every override row for a set of
|
|
7
|
+
* products, in one statement, bucketed by product id. `channelId` narrows the
|
|
8
|
+
* read to one sales channel's rows — what a storefront read needs (issue #384);
|
|
9
|
+
* without it every channel's rows come back, as the admin scope editor needs.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadOverridesByProduct(em: EntityManager, args: {
|
|
12
|
+
productIds: readonly string[];
|
|
13
|
+
channelId?: string;
|
|
14
|
+
}): Promise<Map<string, OverrideRow[]>>;
|
|
5
15
|
/**
|
|
6
16
|
* Feature 022 — backend wrapper around the pure resolver in
|
|
7
17
|
* `@endora-commerce/contracts`. Handles the EM-side concerns:
|
|
@@ -21,7 +31,7 @@ export declare class ProductValueResolverService {
|
|
|
21
31
|
constructor(emFactory: () => EntityManager, languageService: LanguageReadPort,
|
|
22
32
|
/** Feature 061 — composed attribute read model (scope lookups). */
|
|
23
33
|
attributeRead?: CatalogAttributeReadService | undefined);
|
|
24
|
-
/** Load every override row for a product in one query. */
|
|
34
|
+
/** Load every override row for a product — every channel's — in one query. */
|
|
25
35
|
loadOverrides(productId: string): Promise<OverrideRow[]>;
|
|
26
36
|
/** Resolve the platform's primary admin language. */
|
|
27
37
|
getPrimaryAdminLanguage(): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-value-resolver.service.d.ts","sourceRoot":"","sources":["../../../src/backend/services/product-value-resolver.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAMvF;;;;;;;;;;GAUG;AACH,qBAAa,2BAA2B;IAEpC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,mEAAmE;IACnE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;gBAHd,SAAS,EAAE,MAAM,aAAa,EAC9B,eAAe,EAAE,gBAAgB;IAClD,mEAAmE;IAClD,aAAa,CAAC,EAAE,2BAA2B,YAAA;IAG9D,
|
|
1
|
+
{"version":3,"file":"product-value-resolver.service.d.ts","sourceRoot":"","sources":["../../../src/backend/services/product-value-resolver.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAMvF;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,EAAE,EAAE,aAAa,EACjB,IAAI,EAAE;IAAE,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1D,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,CAkBrC;AAED;;;;;;;;;;GAUG;AACH,qBAAa,2BAA2B;IAEpC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,mEAAmE;IACnE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;gBAHd,SAAS,EAAE,MAAM,aAAa,EAC9B,eAAe,EAAE,gBAAgB;IAClD,mEAAmE;IAClD,aAAa,CAAC,EAAE,2BAA2B,YAAA;IAG9D,8EAA8E;IACxE,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAK9D,qDAAqD;IAC/C,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC;IAOhD;;;OAGG;IACG,WAAW,CACf,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,YAAY,EAAE,MAAM,GAAG,IAAI,GAC1B,OAAO,CAAC,eAAe,CAAC;IAK3B;;;;;;;;;;;;OAYG;IACG,iBAAiB,CACrB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,gBAAgB,CAAC;IA+C5B;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE;QACf,QAAQ,EAAE,OAAO,CAAC;QAClB,SAAS,EAAE,SAAS,WAAW,EAAE,CAAC;QAClC,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,cAAc,CAAC;QACtB,GAAG,EAAE,eAAe,CAAC;KACtB,GAAG,QAAQ;CAGb"}
|
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import { resolveAttribute, resolveAll, } from '@endora-commerce/contracts';
|
|
2
2
|
import { ProductValueOverride } from '../entities/product-value-override.entity.js';
|
|
3
3
|
import { SYSTEM_ATTRIBUTE_SCOPES, } from './system-attribute-scopes.js';
|
|
4
|
+
/**
|
|
5
|
+
* The one read of `product_value_overrides`: every override row for a set of
|
|
6
|
+
* products, in one statement, bucketed by product id. `channelId` narrows the
|
|
7
|
+
* read to one sales channel's rows — what a storefront read needs (issue #384);
|
|
8
|
+
* without it every channel's rows come back, as the admin scope editor needs.
|
|
9
|
+
*/
|
|
10
|
+
export async function loadOverridesByProduct(em, args) {
|
|
11
|
+
const out = new Map();
|
|
12
|
+
if (args.productIds.length === 0)
|
|
13
|
+
return out;
|
|
14
|
+
const rows = await em.find(ProductValueOverride, {
|
|
15
|
+
productId: { $in: [...new Set(args.productIds)] },
|
|
16
|
+
...(args.channelId !== undefined ? { channelId: args.channelId } : {}),
|
|
17
|
+
});
|
|
18
|
+
for (const r of rows) {
|
|
19
|
+
const list = out.get(r.productId) ?? [];
|
|
20
|
+
list.push({
|
|
21
|
+
attributeKey: r.attributeKey,
|
|
22
|
+
channelId: r.channelId,
|
|
23
|
+
languageCode: r.languageCode ?? null,
|
|
24
|
+
value: r.value,
|
|
25
|
+
});
|
|
26
|
+
out.set(r.productId, list);
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
4
30
|
/**
|
|
5
31
|
* Feature 022 — backend wrapper around the pure resolver in
|
|
6
32
|
* `@endora-commerce/contracts`. Handles the EM-side concerns:
|
|
@@ -23,16 +49,10 @@ export class ProductValueResolverService {
|
|
|
23
49
|
this.languageService = languageService;
|
|
24
50
|
this.attributeRead = attributeRead;
|
|
25
51
|
}
|
|
26
|
-
/** Load every override row for a product in one query. */
|
|
52
|
+
/** Load every override row for a product — every channel's — in one query. */
|
|
27
53
|
async loadOverrides(productId) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
return rows.map((r) => ({
|
|
31
|
-
attributeKey: r.attributeKey,
|
|
32
|
-
channelId: r.channelId,
|
|
33
|
-
languageCode: r.languageCode ?? null,
|
|
34
|
-
value: r.value,
|
|
35
|
-
}));
|
|
54
|
+
const byProduct = await loadOverridesByProduct(this.emFactory(), { productIds: [productId] });
|
|
55
|
+
return byProduct.get(productId) ?? [];
|
|
36
56
|
}
|
|
37
57
|
/** Resolve the platform's primary admin language. */
|
|
38
58
|
async getPrimaryAdminLanguage() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-value-resolver.service.js","sourceRoot":"","sources":["../../../src/backend/services/product-value-resolver.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,UAAU,GAQX,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AAEpF,OAAO,EACL,uBAAuB,GAExB,MAAM,8BAA8B,CAAC;AAEtC
|
|
1
|
+
{"version":3,"file":"product-value-resolver.service.js","sourceRoot":"","sources":["../../../src/backend/services/product-value-resolver.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,UAAU,GAQX,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AAEpF,OAAO,EACL,uBAAuB,GAExB,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,EAAiB,EACjB,IAA2D;IAE3D,MAAM,GAAG,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC7C,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAC7C,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE;QAC/C,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE;QACjD,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvE,CAAC,C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,CAAyB,EAAE,CAAC;YAClF,MAAM,QAAQ,GACZ,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;YAC3F,IAAI,CAAC,IAAI,CAAC;gBACR,YAAY,EAAE,MAAM;gBACpB,KAAK,EAAE,uBAAuB,CAAC,MAAM,CAAE;gBACvC,QAAQ;aACT,CAAC,CAAC;QACL,CAAC;QAED,sEAAsE;QACtE,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;YAC/B,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACnC,MAAM,KAAK,GAAmB,GAAG;gBAC/B,CAAC,CAAC,EAAE,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE,cAAc,EAAE,GAAG,CAAC,cAAc,EAAE;gBAC1E,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;YACpD,IAAI,CAAC,IAAI,CAAC;gBACR,YAAY,EAAE,GAAG;gBACjB,KAAK;gBACL,QAAQ,EAAG,OAAO,CAAC,eAA2C,CAAC,GAAG,CAAC;aACpE,CAAC,CAAC;QACL,CAAC;QAED,OAAO,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,IAMV;QACC,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { EntityManager } from '@mikro-orm/postgresql';
|
|
2
|
+
import { type AttributeScope, type OverrideRow, type StorefrontOverrideContext } from '@endora-commerce/contracts';
|
|
3
|
+
/**
|
|
4
|
+
* Issue #384 — what a storefront read needs to show a product's
|
|
5
|
+
* per-(sales channel, language) overrides (features 022/023).
|
|
6
|
+
*
|
|
7
|
+
* The slot choice itself — the language walk, and which override answers —
|
|
8
|
+
* is `@endora-commerce/contracts`' `storefront-value-overrides`, shared with
|
|
9
|
+
* `search`'s result cards so the two modules cannot show one product under two
|
|
10
|
+
* names. Re-exported here so this module's reads name one import. What stays
|
|
11
|
+
* in this file is what only `catalog` can do: read the rows, and map a
|
|
12
|
+
* product's user attributes through their scopes.
|
|
13
|
+
*/
|
|
14
|
+
export { channelOverrideFor, effectiveSystemText, overrideLanguages, type StorefrontOverrideContext, } from '@endora-commerce/contracts';
|
|
15
|
+
/**
|
|
16
|
+
* Every override row the request's sales channel holds for a set of products,
|
|
17
|
+
* in one statement, bucketed by product id. Rows are independent of the
|
|
18
|
+
* viewer, so one fetch serves a whole read section. The one read of the table
|
|
19
|
+
* is `loadOverridesByProduct` in the resolver service; this narrows it to the
|
|
20
|
+
* channel.
|
|
21
|
+
*/
|
|
22
|
+
export declare function loadChannelOverridesByProduct(em: EntityManager, productIds: readonly string[], channelId: string): Promise<Map<string, OverrideRow[]>>;
|
|
23
|
+
/**
|
|
24
|
+
* The product's `attributeValues` with every channel-scoped user attribute
|
|
25
|
+
* replaced by its override for this context — walked over the attribute's own
|
|
26
|
+
* baseline value, so a per-language value stops the walk where it answers. Returns the input record itself
|
|
27
|
+
* when no user-attribute override row exists, so a product without overrides
|
|
28
|
+
* costs no attribute-metadata read and no copy.
|
|
29
|
+
*/
|
|
30
|
+
export declare function effectiveAttributeValues(values: Record<string, unknown>, overrides: readonly OverrideRow[] | undefined, ctx: StorefrontOverrideContext, scopeOf: () => Promise<Map<string, AttributeScope>>): Promise<Record<string, unknown>>;
|
|
31
|
+
//# sourceMappingURL=storefront-value-overrides.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storefront-value-overrides.d.ts","sourceRoot":"","sources":["../../../src/backend/services/storefront-value-overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,yBAAyB,EAC/B,MAAM,4BAA4B,CAAC;AAIpC;;;;;;;;;;GAUG;AACH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,KAAK,yBAAyB,GAC/B,MAAM,4BAA4B,CAAC;AAEpC;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,EAAE,EAAE,aAAa,EACjB,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,CAErC;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,SAAS,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,EAC7C,GAAG,EAAE,yBAAyB,EAC9B,OAAO,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,GAClD,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAclC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SYSTEM_ATTRIBUTE_SCOPES, channelOverrideFor, } from '@endora-commerce/contracts';
|
|
2
|
+
import { loadOverridesByProduct } from './product-value-resolver.service.js';
|
|
3
|
+
/**
|
|
4
|
+
* Issue #384 — what a storefront read needs to show a product's
|
|
5
|
+
* per-(sales channel, language) overrides (features 022/023).
|
|
6
|
+
*
|
|
7
|
+
* The slot choice itself — the language walk, and which override answers —
|
|
8
|
+
* is `@endora-commerce/contracts`' `storefront-value-overrides`, shared with
|
|
9
|
+
* `search`'s result cards so the two modules cannot show one product under two
|
|
10
|
+
* names. Re-exported here so this module's reads name one import. What stays
|
|
11
|
+
* in this file is what only `catalog` can do: read the rows, and map a
|
|
12
|
+
* product's user attributes through their scopes.
|
|
13
|
+
*/
|
|
14
|
+
export { channelOverrideFor, effectiveSystemText, overrideLanguages, } from '@endora-commerce/contracts';
|
|
15
|
+
/**
|
|
16
|
+
* Every override row the request's sales channel holds for a set of products,
|
|
17
|
+
* in one statement, bucketed by product id. Rows are independent of the
|
|
18
|
+
* viewer, so one fetch serves a whole read section. The one read of the table
|
|
19
|
+
* is `loadOverridesByProduct` in the resolver service; this narrows it to the
|
|
20
|
+
* channel.
|
|
21
|
+
*/
|
|
22
|
+
export function loadChannelOverridesByProduct(em, productIds, channelId) {
|
|
23
|
+
return loadOverridesByProduct(em, { productIds, channelId });
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The product's `attributeValues` with every channel-scoped user attribute
|
|
27
|
+
* replaced by its override for this context — walked over the attribute's own
|
|
28
|
+
* baseline value, so a per-language value stops the walk where it answers. Returns the input record itself
|
|
29
|
+
* when no user-attribute override row exists, so a product without overrides
|
|
30
|
+
* costs no attribute-metadata read and no copy.
|
|
31
|
+
*/
|
|
32
|
+
export async function effectiveAttributeValues(values, overrides, ctx, scopeOf) {
|
|
33
|
+
const userRows = (overrides ?? []).filter((o) => !Object.prototype.hasOwnProperty.call(SYSTEM_ATTRIBUTE_SCOPES, o.attributeKey));
|
|
34
|
+
if (userRows.length === 0)
|
|
35
|
+
return values;
|
|
36
|
+
const scopes = await scopeOf();
|
|
37
|
+
const out = { ...values };
|
|
38
|
+
for (const key of new Set(userRows.map((o) => o.attributeKey))) {
|
|
39
|
+
const scope = scopes.get(key);
|
|
40
|
+
if (!scope)
|
|
41
|
+
continue;
|
|
42
|
+
const v = channelOverrideFor(userRows, key, scope, ctx, values[key]);
|
|
43
|
+
if (v !== undefined)
|
|
44
|
+
out[key] = v;
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=storefront-value-overrides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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CAAC,GAAG,kBAAkB,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,KAAK,SAAS;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/manifest.d.ts
CHANGED
|
@@ -118,7 +118,7 @@ export declare const manifest: {
|
|
|
118
118
|
name: string;
|
|
119
119
|
labelKey: string;
|
|
120
120
|
category: string;
|
|
121
|
-
contexts: ("email" | "cms" | "invoice" | "newsletter")[];
|
|
121
|
+
contexts: ("email" | "cms" | "invoice" | "newsletter" | "document")[];
|
|
122
122
|
fields: Record<string, {
|
|
123
123
|
type: "number" | "object" | "array" | "uuid" | "text" | "textarea" | "select" | "radio" | "external" | "richtext";
|
|
124
124
|
label?: string | undefined;
|
|
@@ -134,11 +134,15 @@ export declare const manifest: {
|
|
|
134
134
|
responsiveFields?: string[] | undefined;
|
|
135
135
|
previewIcon?: string | undefined;
|
|
136
136
|
weight?: number | undefined;
|
|
137
|
+
translatable?: {
|
|
138
|
+
path: string;
|
|
139
|
+
format?: "plain" | "tiptap" | "html" | undefined;
|
|
140
|
+
}[] | undefined;
|
|
137
141
|
}[] | undefined;
|
|
138
142
|
blockCategories?: {
|
|
139
143
|
key: string;
|
|
140
144
|
titleKey: string;
|
|
141
|
-
contexts: ("email" | "cms" | "invoice" | "newsletter")[];
|
|
145
|
+
contexts: ("email" | "cms" | "invoice" | "newsletter" | "document")[];
|
|
142
146
|
weight?: number | undefined;
|
|
143
147
|
visible?: boolean | undefined;
|
|
144
148
|
}[] | undefined;
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0qBnB,CAAC;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc;;;;;;CAYzB,CAAC"}
|
package/dist/manifest.js
CHANGED
|
@@ -117,6 +117,10 @@ export const manifest = defineModuleManifest({
|
|
|
117
117
|
// owner is non-deactivatable, so the declaration buys install and migration
|
|
118
118
|
// order rather than a flip-time refusal.
|
|
119
119
|
dependencies: [
|
|
120
|
+
// `_i18n` owns `adminI18nService`, through which global search's Product
|
|
121
|
+
// provider labels a status in the admin's language
|
|
122
|
+
// (`specs/150-admin-global-search/`).
|
|
123
|
+
'_i18n',
|
|
120
124
|
'audit_logs',
|
|
121
125
|
'admin_users',
|
|
122
126
|
'assets_library',
|
|
@@ -267,6 +271,17 @@ export const manifest = defineModuleManifest({
|
|
|
267
271
|
'caught: presence is decided in front of the query, and an unreachable index is an arm ' +
|
|
268
272
|
'of the port\'s return type.',
|
|
269
273
|
},
|
|
274
|
+
{
|
|
275
|
+
moduleId: 'admin_search',
|
|
276
|
+
name: 'adminSearchProviderRegistry',
|
|
277
|
+
kind: 'contributes-to',
|
|
278
|
+
reason: 'A push, from this module’s contribution-only boot hook, of the Product and Category ' +
|
|
279
|
+
'providers for the admin global search, built over its own tables and attribute read. ' +
|
|
280
|
+
'Nothing is read back: the registry enumerates only providers whose module is ' +
|
|
281
|
+
'effectively present, so an absent contributor costs the host nothing and an absent host ' +
|
|
282
|
+
'holds a table nobody walks. Not `dependencies`: this module is non-deactivatable, so ' +
|
|
283
|
+
'that would make `admin_search.enabled` a dead switch.',
|
|
284
|
+
},
|
|
270
285
|
{
|
|
271
286
|
moduleId: 'prompt_actions',
|
|
272
287
|
name: 'promptActionToolRegistry',
|
|
@@ -325,10 +340,11 @@ export const manifest = defineModuleManifest({
|
|
|
325
340
|
'different product, not a reduced one.',
|
|
326
341
|
},
|
|
327
342
|
/**
|
|
328
|
-
* The error codes this module owns — forty-seven from
|
|
343
|
+
* The error codes this module owns, fifty-six in all — forty-seven from
|
|
344
|
+
* feature 090 Phase 3
|
|
329
345
|
* (`specs/090-module-owned-error-codes/contracts/error-code-declaration.md`
|
|
330
|
-
* §1.1)
|
|
331
|
-
* of this block. This is where the sentence for each is looked up from:
|
|
346
|
+
* §1.1), six more from D-129's remaining sweep, MR 4, and three minted by
|
|
347
|
+
* feature 155, both described at the end of this block. This is where the sentence for each is looked up from:
|
|
332
348
|
* `errors.<CODE>` in this module's own `i18n/{en,pl}.json`. Every code with
|
|
333
349
|
* no sentence there is an entry in `check-error-translations.ts`'s
|
|
334
350
|
* `UNTRANSLATED_ERROR_CODES` ledger and stays one — declaring a code writes no
|
|
@@ -410,6 +426,15 @@ export const manifest = defineModuleManifest({
|
|
|
410
426
|
* that pass a `details` object pass `{ maxBatchSize, recommendedSplitInto }`
|
|
411
427
|
* and `{ total, maxSelectionSize }` — neither holds a `code`, which is the
|
|
412
428
|
* only key `refusalToken` reads.
|
|
429
|
+
*
|
|
430
|
+
* **Three were minted by feature 155** (`specs/155-catalog-order-constraints/`
|
|
431
|
+
* `contracts/error-codes.md`): `PRODUCT_BELOW_MINIMUM_QUANTITY`,
|
|
432
|
+
* `PACKAGING_UNIT_BELOW_MINIMUM_QUANTITY` and `PACKAGING_UNIT_MISMATCH`.
|
|
433
|
+
* D-121 T1 again: the minimums are columns on this module's products and
|
|
434
|
+
* packaging units, so the sentence lives here whichever module refuses the
|
|
435
|
+
* line — `carts`, `orders` and `quote_requests` raise them, and none of them
|
|
436
|
+
* owns the noun. Each arrives with its sentence in both bundles. No token:
|
|
437
|
+
* their `details` carry the line's product, minimum and `lines[]`, no `code`.
|
|
413
438
|
*/
|
|
414
439
|
errorCodes: [
|
|
415
440
|
{ code: 'ASSET_KIND_NOT_SUPPORTED' },
|
|
@@ -438,12 +463,17 @@ export const manifest = defineModuleManifest({
|
|
|
438
463
|
{ code: 'MIN_NOT_MET' },
|
|
439
464
|
{ code: 'NESTED_COMPOSITE_NOT_ALLOWED' },
|
|
440
465
|
{ code: 'OPTION_ALREADY_EXISTS' },
|
|
466
|
+
{ code: 'PACKAGING_UNIT_BELOW_MINIMUM_QUANTITY' },
|
|
467
|
+
{ code: 'PACKAGING_UNIT_MISMATCH' },
|
|
441
468
|
{ code: 'PACKAGING_UNIT_NAME_CONFLICT' },
|
|
442
469
|
{ code: 'PACKAGING_UNIT_NOT_FOUND' },
|
|
443
470
|
{ code: 'PACKAGING_UNIT_NOT_SUPPORTED_FOR_TYPE' },
|
|
444
471
|
{ code: 'PRICE_ORDERING_UNAVAILABLE' },
|
|
445
472
|
{ code: 'PRICE_RANGE_INVALID' },
|
|
473
|
+
// Feature 160 (FR-043): a product or variant write naming an old price field.
|
|
474
|
+
{ code: 'PRICE_SET_IN_PRICE_BOOKS' },
|
|
446
475
|
{ code: 'PRODUCT_ARCHIVED' },
|
|
476
|
+
{ code: 'PRODUCT_BELOW_MINIMUM_QUANTITY' },
|
|
447
477
|
{ code: 'PRODUCT_DELETE_BLOCKED' },
|
|
448
478
|
{ code: 'PRODUCT_FEED_CONFIRMATION_REQUIRED' },
|
|
449
479
|
{ code: 'PRODUCT_FEED_DISABLED' },
|
|
@@ -454,6 +484,7 @@ export const manifest = defineModuleManifest({
|
|
|
454
484
|
{ code: 'PRODUCT_LINK_NOT_FOUND' },
|
|
455
485
|
{ code: 'PRODUCT_NOT_FOUND' },
|
|
456
486
|
{ code: 'PRODUCT_NOT_IN_COMPARISON' },
|
|
487
|
+
{ code: 'PRODUCT_SAVED_VIEW_NAME_TAKEN' },
|
|
457
488
|
{ code: 'PRODUCT_TYPE_MISMATCH' },
|
|
458
489
|
{ code: 'PRODUCT_UNMANAGED_STOCK' },
|
|
459
490
|
{ code: 'SELECTION_TOO_LARGE' },
|
|
@@ -592,6 +623,7 @@ export const manifest = defineModuleManifest({
|
|
|
592
623
|
blocks: [
|
|
593
624
|
{
|
|
594
625
|
name: 'catalog.ProductCard',
|
|
626
|
+
translatable: [{ path: 'ctaLabel' }],
|
|
595
627
|
labelKey: 'blocks.productCard.label',
|
|
596
628
|
descriptionKey: 'blocks.productCard.description',
|
|
597
629
|
category: 'catalog',
|
|
@@ -602,6 +634,7 @@ export const manifest = defineModuleManifest({
|
|
|
602
634
|
},
|
|
603
635
|
{
|
|
604
636
|
name: 'catalog.ProductGrid',
|
|
637
|
+
translatable: [],
|
|
605
638
|
labelKey: 'blocks.productGrid.label',
|
|
606
639
|
descriptionKey: 'blocks.productGrid.description',
|
|
607
640
|
category: 'catalog',
|
|
@@ -612,6 +645,7 @@ export const manifest = defineModuleManifest({
|
|
|
612
645
|
},
|
|
613
646
|
{
|
|
614
647
|
name: 'catalog.ProductSlider',
|
|
648
|
+
translatable: [],
|
|
615
649
|
labelKey: 'blocks.productSlider.label',
|
|
616
650
|
descriptionKey: 'blocks.productSlider.description',
|
|
617
651
|
category: 'catalog',
|
|
@@ -622,6 +656,7 @@ export const manifest = defineModuleManifest({
|
|
|
622
656
|
},
|
|
623
657
|
{
|
|
624
658
|
name: 'catalog.CategoryList',
|
|
659
|
+
translatable: [],
|
|
625
660
|
labelKey: 'blocks.categoryList.label',
|
|
626
661
|
descriptionKey: 'blocks.categoryList.description',
|
|
627
662
|
category: 'catalog',
|
|
@@ -632,6 +667,7 @@ export const manifest = defineModuleManifest({
|
|
|
632
667
|
},
|
|
633
668
|
{
|
|
634
669
|
name: 'catalog.CategoryGrid',
|
|
670
|
+
translatable: [],
|
|
635
671
|
labelKey: 'blocks.categoryGrid.label',
|
|
636
672
|
descriptionKey: 'blocks.categoryGrid.description',
|
|
637
673
|
category: 'catalog',
|