@viu/emporix-sdk 1.0.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/CHANGELOG.md +407 -0
- package/LICENSE +21 -0
- package/README.md +115 -0
- package/dist/cart.cjs +214 -0
- package/dist/cart.cjs.map +1 -0
- package/dist/cart.d.cts +1807 -0
- package/dist/cart.d.ts +1807 -0
- package/dist/cart.js +4 -0
- package/dist/cart.js.map +1 -0
- package/dist/category.cjs +97 -0
- package/dist/category.cjs.map +1 -0
- package/dist/category.d.cts +313 -0
- package/dist/category.d.ts +313 -0
- package/dist/category.js +4 -0
- package/dist/category.js.map +1 -0
- package/dist/checkout.cjs +98 -0
- package/dist/checkout.cjs.map +1 -0
- package/dist/checkout.d.cts +252 -0
- package/dist/checkout.d.ts +252 -0
- package/dist/checkout.js +4 -0
- package/dist/checkout.js.map +1 -0
- package/dist/chunk-4BJUCCKJ.js +86 -0
- package/dist/chunk-4BJUCCKJ.js.map +1 -0
- package/dist/chunk-6UNFMCHZ.js +95 -0
- package/dist/chunk-6UNFMCHZ.js.map +1 -0
- package/dist/chunk-B56JZNI7.js +49 -0
- package/dist/chunk-B56JZNI7.js.map +1 -0
- package/dist/chunk-BFQ732VZ.js +11 -0
- package/dist/chunk-BFQ732VZ.js.map +1 -0
- package/dist/chunk-F3WAQH2E.js +120 -0
- package/dist/chunk-F3WAQH2E.js.map +1 -0
- package/dist/chunk-GWJ2U2CP.js +14 -0
- package/dist/chunk-GWJ2U2CP.js.map +1 -0
- package/dist/chunk-HEO34WLO.js +47 -0
- package/dist/chunk-HEO34WLO.js.map +1 -0
- package/dist/chunk-HKPZI7Y5.js +30 -0
- package/dist/chunk-HKPZI7Y5.js.map +1 -0
- package/dist/chunk-IEZHGU7F.js +171 -0
- package/dist/chunk-IEZHGU7F.js.map +1 -0
- package/dist/chunk-KTODT6DV.js +86 -0
- package/dist/chunk-KTODT6DV.js.map +1 -0
- package/dist/chunk-NM7VDXBR.js +57 -0
- package/dist/chunk-NM7VDXBR.js.map +1 -0
- package/dist/chunk-OMYVOOSX.js +57 -0
- package/dist/chunk-OMYVOOSX.js.map +1 -0
- package/dist/chunk-QDABAMVN.js +89 -0
- package/dist/chunk-QDABAMVN.js.map +1 -0
- package/dist/chunk-RXVVFNYN.js +56 -0
- package/dist/chunk-RXVVFNYN.js.map +1 -0
- package/dist/chunk-SKX7KCMH.js +23 -0
- package/dist/chunk-SKX7KCMH.js.map +1 -0
- package/dist/chunk-TLH6SLAF.js +215 -0
- package/dist/chunk-TLH6SLAF.js.map +1 -0
- package/dist/chunk-Z6PNI5VT.js +142 -0
- package/dist/chunk-Z6PNI5VT.js.map +1 -0
- package/dist/companies.cjs +58 -0
- package/dist/companies.cjs.map +1 -0
- package/dist/companies.d.cts +31 -0
- package/dist/companies.d.ts +31 -0
- package/dist/companies.js +3 -0
- package/dist/companies.js.map +1 -0
- package/dist/contacts.cjs +51 -0
- package/dist/contacts.cjs.map +1 -0
- package/dist/contacts.d.cts +28 -0
- package/dist/contacts.d.ts +28 -0
- package/dist/contacts.js +3 -0
- package/dist/contacts.js.map +1 -0
- package/dist/context-vKgzZ-5f.d.cts +329 -0
- package/dist/context-vKgzZ-5f.d.ts +329 -0
- package/dist/customer-groups.cjs +25 -0
- package/dist/customer-groups.cjs.map +1 -0
- package/dist/customer-groups.d.cts +36 -0
- package/dist/customer-groups.d.ts +36 -0
- package/dist/customer-groups.js +3 -0
- package/dist/customer-groups.js.map +1 -0
- package/dist/customer.cjs +262 -0
- package/dist/customer.cjs.map +1 -0
- package/dist/customer.d.cts +386 -0
- package/dist/customer.d.ts +386 -0
- package/dist/customer.js +5 -0
- package/dist/customer.js.map +1 -0
- package/dist/index.cjs +2075 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +218 -0
- package/dist/index.d.ts +218 -0
- package/dist/index.js +791 -0
- package/dist/index.js.map +1 -0
- package/dist/locations.cjs +59 -0
- package/dist/locations.cjs.map +1 -0
- package/dist/locations.d.cts +30 -0
- package/dist/locations.d.ts +30 -0
- package/dist/locations.js +3 -0
- package/dist/locations.js.map +1 -0
- package/dist/media.cjs +123 -0
- package/dist/media.cjs.map +1 -0
- package/dist/media.d.cts +219 -0
- package/dist/media.d.ts +219 -0
- package/dist/media.js +3 -0
- package/dist/media.js.map +1 -0
- package/dist/orders.cjs +98 -0
- package/dist/orders.cjs.map +1 -0
- package/dist/orders.d.cts +167 -0
- package/dist/orders.d.ts +167 -0
- package/dist/orders.js +3 -0
- package/dist/orders.js.map +1 -0
- package/dist/payment.cjs +77 -0
- package/dist/payment.cjs.map +1 -0
- package/dist/payment.d.cts +110 -0
- package/dist/payment.d.ts +110 -0
- package/dist/payment.js +5 -0
- package/dist/payment.js.map +1 -0
- package/dist/price.cjs +88 -0
- package/dist/price.cjs.map +1 -0
- package/dist/price.d.cts +445 -0
- package/dist/price.d.ts +445 -0
- package/dist/price.js +4 -0
- package/dist/price.js.map +1 -0
- package/dist/product.cjs +100 -0
- package/dist/product.cjs.map +1 -0
- package/dist/product.d.cts +400 -0
- package/dist/product.d.ts +400 -0
- package/dist/product.js +4 -0
- package/dist/product.js.map +1 -0
- package/dist/segment.cjs +189 -0
- package/dist/segment.cjs.map +1 -0
- package/dist/segment.d.cts +241 -0
- package/dist/segment.d.ts +241 -0
- package/dist/segment.js +5 -0
- package/dist/segment.js.map +1 -0
- package/dist/types.gen-D1QuqPLs.d.cts +166 -0
- package/dist/types.gen-D1QuqPLs.d.ts +166 -0
- package/package.json +141 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-vKgzZ-5f.cjs';
|
|
2
|
+
import { ProductService } from './product.cjs';
|
|
3
|
+
import { CategoryService } from './category.cjs';
|
|
4
|
+
|
|
5
|
+
type CommonSegment = {
|
|
6
|
+
/**
|
|
7
|
+
* Localized name of the customer segment.
|
|
8
|
+
*/
|
|
9
|
+
name: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Localized description of the customer segment.
|
|
14
|
+
*/
|
|
15
|
+
description?: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Determines the time frame in which the customer segment is valid.
|
|
20
|
+
*/
|
|
21
|
+
validity?: {
|
|
22
|
+
from?: string;
|
|
23
|
+
to?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Determines whether the customer segment is active or not. If not provided the value is set to `INACTIVE`
|
|
27
|
+
*/
|
|
28
|
+
status?: 'ACTIVE' | 'INACTIVE';
|
|
29
|
+
/**
|
|
30
|
+
* Determines for which site the customer segment is available.
|
|
31
|
+
*/
|
|
32
|
+
siteCode: string;
|
|
33
|
+
/**
|
|
34
|
+
* A key-value map of additional attributes.
|
|
35
|
+
*/
|
|
36
|
+
mixins?: {
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
};
|
|
39
|
+
} & {
|
|
40
|
+
metadata?: MetadataCreate;
|
|
41
|
+
};
|
|
42
|
+
type SegmentUpdate = CommonSegment & {
|
|
43
|
+
metadata?: MetadataUpdate;
|
|
44
|
+
};
|
|
45
|
+
type SegmentUpdateBulk = {
|
|
46
|
+
/**
|
|
47
|
+
* Unique identifier of the customer segment.
|
|
48
|
+
*/
|
|
49
|
+
id?: string;
|
|
50
|
+
} & SegmentUpdate;
|
|
51
|
+
type SegmentResponse = SegmentUpdateBulk & {
|
|
52
|
+
metadata?: MetadataResponse;
|
|
53
|
+
};
|
|
54
|
+
type ItemAssignmentUpsert = {
|
|
55
|
+
/**
|
|
56
|
+
* A key-value map of additional attributes.
|
|
57
|
+
*/
|
|
58
|
+
mixins?: {
|
|
59
|
+
[key: string]: unknown;
|
|
60
|
+
};
|
|
61
|
+
} & {
|
|
62
|
+
metadata?: MetadataUpdate;
|
|
63
|
+
};
|
|
64
|
+
type ItemAssignmentResponse = {
|
|
65
|
+
/**
|
|
66
|
+
* Unique identifier of the customer segment.
|
|
67
|
+
*/
|
|
68
|
+
segmentId?: string;
|
|
69
|
+
item?: {
|
|
70
|
+
/**
|
|
71
|
+
* Unique identifier of an existing product/category.
|
|
72
|
+
*/
|
|
73
|
+
id?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Unique code of an existing product/category.
|
|
76
|
+
*/
|
|
77
|
+
code?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Localized name of the product/category
|
|
80
|
+
*/
|
|
81
|
+
name?: {
|
|
82
|
+
[key: string]: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Determines whether item is a `PRODUCT` or `CATEGORY`
|
|
87
|
+
*/
|
|
88
|
+
type?: 'PRODUCT' | 'CATEGORY';
|
|
89
|
+
} & ItemAssignmentUpsert & {
|
|
90
|
+
metadata?: MetadataResponse;
|
|
91
|
+
};
|
|
92
|
+
type CategoryTreeResponse = Array<{
|
|
93
|
+
/**
|
|
94
|
+
* Unique identifier of an existing category.
|
|
95
|
+
*/
|
|
96
|
+
id: string;
|
|
97
|
+
/**
|
|
98
|
+
* Unique code of an existing category.
|
|
99
|
+
*/
|
|
100
|
+
code: string;
|
|
101
|
+
/**
|
|
102
|
+
* Localized name of the category.
|
|
103
|
+
*/
|
|
104
|
+
name: {
|
|
105
|
+
[key: string]: string;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Localized description of the category.
|
|
109
|
+
*/
|
|
110
|
+
localizedDescription?: {
|
|
111
|
+
[key: string]: string;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Localized category name or code without diacritics for the URL.
|
|
115
|
+
*/
|
|
116
|
+
localizedSlug?: {
|
|
117
|
+
[key: string]: string;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* List of external category numbers (ECNs) unique for every category.
|
|
121
|
+
*/
|
|
122
|
+
ecn?: Array<string>;
|
|
123
|
+
/**
|
|
124
|
+
* Indicates the time frame in which the category is valid.
|
|
125
|
+
*/
|
|
126
|
+
validity?: {
|
|
127
|
+
from?: string;
|
|
128
|
+
to?: string;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Category's position, set in relation to the categories on the same level (sharing the same parent) in the tree.
|
|
132
|
+
*/
|
|
133
|
+
position?: number;
|
|
134
|
+
/**
|
|
135
|
+
* Indicates whether the category has been published or not.
|
|
136
|
+
*/
|
|
137
|
+
published?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Indicates if the category is assigned to any segment.
|
|
140
|
+
*/
|
|
141
|
+
isSegmentAssigned: boolean;
|
|
142
|
+
subcategories?: Array<{
|
|
143
|
+
[key: string]: unknown;
|
|
144
|
+
}>;
|
|
145
|
+
}>;
|
|
146
|
+
type MetadataCreate = {
|
|
147
|
+
/**
|
|
148
|
+
* A key-value map, where key is a mixin name and value is a link to the mixin schema.
|
|
149
|
+
*/
|
|
150
|
+
mixins?: {
|
|
151
|
+
[key: string]: unknown;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
type MetadataUpdate = {
|
|
155
|
+
/**
|
|
156
|
+
* The document version number.
|
|
157
|
+
*/
|
|
158
|
+
version?: number;
|
|
159
|
+
} & MetadataCreate;
|
|
160
|
+
type MetadataResponse = {
|
|
161
|
+
/**
|
|
162
|
+
* The creation date.
|
|
163
|
+
*/
|
|
164
|
+
createdAt?: string;
|
|
165
|
+
/**
|
|
166
|
+
* The modification date.
|
|
167
|
+
*/
|
|
168
|
+
modifiedAt?: string;
|
|
169
|
+
} & MetadataUpdate;
|
|
170
|
+
|
|
171
|
+
/** Generated segment types (read shapes — storefront `segment_read_own`). */
|
|
172
|
+
type Segment = SegmentResponse;
|
|
173
|
+
type SegmentItem = ItemAssignmentResponse;
|
|
174
|
+
type SegmentCategoryTree = CategoryTreeResponse;
|
|
175
|
+
type SegmentCategoryTreeNode = CategoryTreeResponse[number];
|
|
176
|
+
/** Cross-service hydrate dependencies, injected from `EmporixClient`. */
|
|
177
|
+
interface SegmentServiceDeps {
|
|
178
|
+
products: ProductService;
|
|
179
|
+
categories: CategoryService;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Customer-segment reads. Every method requires a customer/raw
|
|
183
|
+
* `AuthContext` — the `segment_read_own` scope is on the customer token.
|
|
184
|
+
* The standard product/category endpoints do **not** auto-filter by
|
|
185
|
+
* segment; the storefront uses these reads to discover what to fetch.
|
|
186
|
+
*/
|
|
187
|
+
declare class SegmentService {
|
|
188
|
+
private readonly ctx;
|
|
189
|
+
private readonly deps;
|
|
190
|
+
constructor(ctx: ClientContext, deps: SegmentServiceDeps);
|
|
191
|
+
private base;
|
|
192
|
+
/** Lists segments the caller belongs to (with `segment_read_own`). */
|
|
193
|
+
list(query?: {
|
|
194
|
+
q?: string;
|
|
195
|
+
pageNumber?: number;
|
|
196
|
+
pageSize?: number;
|
|
197
|
+
}, auth?: AuthContext): Promise<Segment[]>;
|
|
198
|
+
/** Fetches a single segment by id. */
|
|
199
|
+
get(segmentId: string, auth?: AuthContext): Promise<Segment>;
|
|
200
|
+
/** Item assignments (PRODUCT + CATEGORY) across all the caller's active segments. */
|
|
201
|
+
listItems(query?: {
|
|
202
|
+
q?: string;
|
|
203
|
+
siteCode?: string;
|
|
204
|
+
legalEntityId?: string;
|
|
205
|
+
onlyActive?: boolean;
|
|
206
|
+
pageNumber?: number;
|
|
207
|
+
pageSize?: number;
|
|
208
|
+
}, auth?: AuthContext): Promise<SegmentItem[]>;
|
|
209
|
+
/** Item assignments of one specific segment. */
|
|
210
|
+
listSegmentItems(segmentId: string, query?: {
|
|
211
|
+
q?: string;
|
|
212
|
+
legalEntityId?: string;
|
|
213
|
+
pageNumber?: number;
|
|
214
|
+
pageSize?: number;
|
|
215
|
+
}, auth?: AuthContext): Promise<SegmentItem[]>;
|
|
216
|
+
/** Category tree built only from the caller's active segments. */
|
|
217
|
+
getCategoryTree(query?: {
|
|
218
|
+
siteCode?: string;
|
|
219
|
+
legalEntityId?: string;
|
|
220
|
+
}, auth?: AuthContext): Promise<SegmentCategoryTree>;
|
|
221
|
+
private pickItemIds;
|
|
222
|
+
/** Product ids assigned to the caller's active segments. */
|
|
223
|
+
listMyProductIds(query?: Parameters<SegmentService["listItems"]>[0], auth?: AuthContext): Promise<string[]>;
|
|
224
|
+
/** Category ids assigned to the caller's active segments. */
|
|
225
|
+
listMyCategoryIds(query?: Parameters<SegmentService["listItems"]>[0], auth?: AuthContext): Promise<string[]>;
|
|
226
|
+
/**
|
|
227
|
+
* Hydrates `listMyProductIds` via `ProductService.get` in parallel.
|
|
228
|
+
* Resolves in the same order as the id list. Any single failure rejects
|
|
229
|
+
* the whole batch (`Promise.all`); use the id-list method + your own
|
|
230
|
+
* tolerance strategy if partial success matters.
|
|
231
|
+
*/
|
|
232
|
+
listMyProducts(query?: Parameters<SegmentService["listItems"]>[0], auth?: AuthContext): Promise<PaginatedItems<Awaited<ReturnType<ProductService["get"]>>>>;
|
|
233
|
+
/**
|
|
234
|
+
* Hydrates a page of the caller's segment CATEGORY assignments into
|
|
235
|
+
* real categories via one bulk `categories.searchByIds` call. Same
|
|
236
|
+
* `hasNextPage` semantic as `listMyProducts`.
|
|
237
|
+
*/
|
|
238
|
+
listMyCategories(query?: Parameters<SegmentService["listItems"]>[0], auth?: AuthContext): Promise<PaginatedItems<Awaited<ReturnType<CategoryService["get"]>>>>;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export { type Segment, type SegmentCategoryTree, type SegmentCategoryTreeNode, type SegmentItem, SegmentService, type SegmentServiceDeps };
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-vKgzZ-5f.js';
|
|
2
|
+
import { ProductService } from './product.js';
|
|
3
|
+
import { CategoryService } from './category.js';
|
|
4
|
+
|
|
5
|
+
type CommonSegment = {
|
|
6
|
+
/**
|
|
7
|
+
* Localized name of the customer segment.
|
|
8
|
+
*/
|
|
9
|
+
name: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Localized description of the customer segment.
|
|
14
|
+
*/
|
|
15
|
+
description?: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Determines the time frame in which the customer segment is valid.
|
|
20
|
+
*/
|
|
21
|
+
validity?: {
|
|
22
|
+
from?: string;
|
|
23
|
+
to?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Determines whether the customer segment is active or not. If not provided the value is set to `INACTIVE`
|
|
27
|
+
*/
|
|
28
|
+
status?: 'ACTIVE' | 'INACTIVE';
|
|
29
|
+
/**
|
|
30
|
+
* Determines for which site the customer segment is available.
|
|
31
|
+
*/
|
|
32
|
+
siteCode: string;
|
|
33
|
+
/**
|
|
34
|
+
* A key-value map of additional attributes.
|
|
35
|
+
*/
|
|
36
|
+
mixins?: {
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
};
|
|
39
|
+
} & {
|
|
40
|
+
metadata?: MetadataCreate;
|
|
41
|
+
};
|
|
42
|
+
type SegmentUpdate = CommonSegment & {
|
|
43
|
+
metadata?: MetadataUpdate;
|
|
44
|
+
};
|
|
45
|
+
type SegmentUpdateBulk = {
|
|
46
|
+
/**
|
|
47
|
+
* Unique identifier of the customer segment.
|
|
48
|
+
*/
|
|
49
|
+
id?: string;
|
|
50
|
+
} & SegmentUpdate;
|
|
51
|
+
type SegmentResponse = SegmentUpdateBulk & {
|
|
52
|
+
metadata?: MetadataResponse;
|
|
53
|
+
};
|
|
54
|
+
type ItemAssignmentUpsert = {
|
|
55
|
+
/**
|
|
56
|
+
* A key-value map of additional attributes.
|
|
57
|
+
*/
|
|
58
|
+
mixins?: {
|
|
59
|
+
[key: string]: unknown;
|
|
60
|
+
};
|
|
61
|
+
} & {
|
|
62
|
+
metadata?: MetadataUpdate;
|
|
63
|
+
};
|
|
64
|
+
type ItemAssignmentResponse = {
|
|
65
|
+
/**
|
|
66
|
+
* Unique identifier of the customer segment.
|
|
67
|
+
*/
|
|
68
|
+
segmentId?: string;
|
|
69
|
+
item?: {
|
|
70
|
+
/**
|
|
71
|
+
* Unique identifier of an existing product/category.
|
|
72
|
+
*/
|
|
73
|
+
id?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Unique code of an existing product/category.
|
|
76
|
+
*/
|
|
77
|
+
code?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Localized name of the product/category
|
|
80
|
+
*/
|
|
81
|
+
name?: {
|
|
82
|
+
[key: string]: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Determines whether item is a `PRODUCT` or `CATEGORY`
|
|
87
|
+
*/
|
|
88
|
+
type?: 'PRODUCT' | 'CATEGORY';
|
|
89
|
+
} & ItemAssignmentUpsert & {
|
|
90
|
+
metadata?: MetadataResponse;
|
|
91
|
+
};
|
|
92
|
+
type CategoryTreeResponse = Array<{
|
|
93
|
+
/**
|
|
94
|
+
* Unique identifier of an existing category.
|
|
95
|
+
*/
|
|
96
|
+
id: string;
|
|
97
|
+
/**
|
|
98
|
+
* Unique code of an existing category.
|
|
99
|
+
*/
|
|
100
|
+
code: string;
|
|
101
|
+
/**
|
|
102
|
+
* Localized name of the category.
|
|
103
|
+
*/
|
|
104
|
+
name: {
|
|
105
|
+
[key: string]: string;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Localized description of the category.
|
|
109
|
+
*/
|
|
110
|
+
localizedDescription?: {
|
|
111
|
+
[key: string]: string;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Localized category name or code without diacritics for the URL.
|
|
115
|
+
*/
|
|
116
|
+
localizedSlug?: {
|
|
117
|
+
[key: string]: string;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* List of external category numbers (ECNs) unique for every category.
|
|
121
|
+
*/
|
|
122
|
+
ecn?: Array<string>;
|
|
123
|
+
/**
|
|
124
|
+
* Indicates the time frame in which the category is valid.
|
|
125
|
+
*/
|
|
126
|
+
validity?: {
|
|
127
|
+
from?: string;
|
|
128
|
+
to?: string;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Category's position, set in relation to the categories on the same level (sharing the same parent) in the tree.
|
|
132
|
+
*/
|
|
133
|
+
position?: number;
|
|
134
|
+
/**
|
|
135
|
+
* Indicates whether the category has been published or not.
|
|
136
|
+
*/
|
|
137
|
+
published?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Indicates if the category is assigned to any segment.
|
|
140
|
+
*/
|
|
141
|
+
isSegmentAssigned: boolean;
|
|
142
|
+
subcategories?: Array<{
|
|
143
|
+
[key: string]: unknown;
|
|
144
|
+
}>;
|
|
145
|
+
}>;
|
|
146
|
+
type MetadataCreate = {
|
|
147
|
+
/**
|
|
148
|
+
* A key-value map, where key is a mixin name and value is a link to the mixin schema.
|
|
149
|
+
*/
|
|
150
|
+
mixins?: {
|
|
151
|
+
[key: string]: unknown;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
type MetadataUpdate = {
|
|
155
|
+
/**
|
|
156
|
+
* The document version number.
|
|
157
|
+
*/
|
|
158
|
+
version?: number;
|
|
159
|
+
} & MetadataCreate;
|
|
160
|
+
type MetadataResponse = {
|
|
161
|
+
/**
|
|
162
|
+
* The creation date.
|
|
163
|
+
*/
|
|
164
|
+
createdAt?: string;
|
|
165
|
+
/**
|
|
166
|
+
* The modification date.
|
|
167
|
+
*/
|
|
168
|
+
modifiedAt?: string;
|
|
169
|
+
} & MetadataUpdate;
|
|
170
|
+
|
|
171
|
+
/** Generated segment types (read shapes — storefront `segment_read_own`). */
|
|
172
|
+
type Segment = SegmentResponse;
|
|
173
|
+
type SegmentItem = ItemAssignmentResponse;
|
|
174
|
+
type SegmentCategoryTree = CategoryTreeResponse;
|
|
175
|
+
type SegmentCategoryTreeNode = CategoryTreeResponse[number];
|
|
176
|
+
/** Cross-service hydrate dependencies, injected from `EmporixClient`. */
|
|
177
|
+
interface SegmentServiceDeps {
|
|
178
|
+
products: ProductService;
|
|
179
|
+
categories: CategoryService;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Customer-segment reads. Every method requires a customer/raw
|
|
183
|
+
* `AuthContext` — the `segment_read_own` scope is on the customer token.
|
|
184
|
+
* The standard product/category endpoints do **not** auto-filter by
|
|
185
|
+
* segment; the storefront uses these reads to discover what to fetch.
|
|
186
|
+
*/
|
|
187
|
+
declare class SegmentService {
|
|
188
|
+
private readonly ctx;
|
|
189
|
+
private readonly deps;
|
|
190
|
+
constructor(ctx: ClientContext, deps: SegmentServiceDeps);
|
|
191
|
+
private base;
|
|
192
|
+
/** Lists segments the caller belongs to (with `segment_read_own`). */
|
|
193
|
+
list(query?: {
|
|
194
|
+
q?: string;
|
|
195
|
+
pageNumber?: number;
|
|
196
|
+
pageSize?: number;
|
|
197
|
+
}, auth?: AuthContext): Promise<Segment[]>;
|
|
198
|
+
/** Fetches a single segment by id. */
|
|
199
|
+
get(segmentId: string, auth?: AuthContext): Promise<Segment>;
|
|
200
|
+
/** Item assignments (PRODUCT + CATEGORY) across all the caller's active segments. */
|
|
201
|
+
listItems(query?: {
|
|
202
|
+
q?: string;
|
|
203
|
+
siteCode?: string;
|
|
204
|
+
legalEntityId?: string;
|
|
205
|
+
onlyActive?: boolean;
|
|
206
|
+
pageNumber?: number;
|
|
207
|
+
pageSize?: number;
|
|
208
|
+
}, auth?: AuthContext): Promise<SegmentItem[]>;
|
|
209
|
+
/** Item assignments of one specific segment. */
|
|
210
|
+
listSegmentItems(segmentId: string, query?: {
|
|
211
|
+
q?: string;
|
|
212
|
+
legalEntityId?: string;
|
|
213
|
+
pageNumber?: number;
|
|
214
|
+
pageSize?: number;
|
|
215
|
+
}, auth?: AuthContext): Promise<SegmentItem[]>;
|
|
216
|
+
/** Category tree built only from the caller's active segments. */
|
|
217
|
+
getCategoryTree(query?: {
|
|
218
|
+
siteCode?: string;
|
|
219
|
+
legalEntityId?: string;
|
|
220
|
+
}, auth?: AuthContext): Promise<SegmentCategoryTree>;
|
|
221
|
+
private pickItemIds;
|
|
222
|
+
/** Product ids assigned to the caller's active segments. */
|
|
223
|
+
listMyProductIds(query?: Parameters<SegmentService["listItems"]>[0], auth?: AuthContext): Promise<string[]>;
|
|
224
|
+
/** Category ids assigned to the caller's active segments. */
|
|
225
|
+
listMyCategoryIds(query?: Parameters<SegmentService["listItems"]>[0], auth?: AuthContext): Promise<string[]>;
|
|
226
|
+
/**
|
|
227
|
+
* Hydrates `listMyProductIds` via `ProductService.get` in parallel.
|
|
228
|
+
* Resolves in the same order as the id list. Any single failure rejects
|
|
229
|
+
* the whole batch (`Promise.all`); use the id-list method + your own
|
|
230
|
+
* tolerance strategy if partial success matters.
|
|
231
|
+
*/
|
|
232
|
+
listMyProducts(query?: Parameters<SegmentService["listItems"]>[0], auth?: AuthContext): Promise<PaginatedItems<Awaited<ReturnType<ProductService["get"]>>>>;
|
|
233
|
+
/**
|
|
234
|
+
* Hydrates a page of the caller's segment CATEGORY assignments into
|
|
235
|
+
* real categories via one bulk `categories.searchByIds` call. Same
|
|
236
|
+
* `hasNextPage` semantic as `listMyProducts`.
|
|
237
|
+
*/
|
|
238
|
+
listMyCategories(query?: Parameters<SegmentService["listItems"]>[0], auth?: AuthContext): Promise<PaginatedItems<Awaited<ReturnType<CategoryService["get"]>>>>;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export { type Segment, type SegmentCategoryTree, type SegmentCategoryTreeNode, type SegmentItem, SegmentService, type SegmentServiceDeps };
|
package/dist/segment.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"segment.js"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-written mirror of the Customer Management Service OpenAPI 0.0.1
|
|
3
|
+
* schemas. The shapes below are taken directly from the documented API
|
|
4
|
+
* (Legal Entities, Contact Assignments, Locations endpoints).
|
|
5
|
+
*
|
|
6
|
+
* **Not generated.** When the OpenAPI input file lands in the repo, this
|
|
7
|
+
* file is replaced by codegen output. Keep the exported names stable so the
|
|
8
|
+
* façade re-exports don't churn.
|
|
9
|
+
*/
|
|
10
|
+
type LegalEntityType = "COMPANY" | "SUBSIDIARY";
|
|
11
|
+
interface AccountLimit {
|
|
12
|
+
currency?: string;
|
|
13
|
+
value?: number;
|
|
14
|
+
}
|
|
15
|
+
interface LegalInfo {
|
|
16
|
+
legalName?: string;
|
|
17
|
+
registrationDate?: string;
|
|
18
|
+
taxRegistrationNumber?: string;
|
|
19
|
+
registrationAgency?: string;
|
|
20
|
+
countryOfRegistration?: string;
|
|
21
|
+
registrationId?: string;
|
|
22
|
+
}
|
|
23
|
+
interface CustomerGroupRef {
|
|
24
|
+
id: string;
|
|
25
|
+
name?: Record<string, string>;
|
|
26
|
+
role?: string;
|
|
27
|
+
}
|
|
28
|
+
interface ResourceId {
|
|
29
|
+
id: string;
|
|
30
|
+
}
|
|
31
|
+
interface Metadata {
|
|
32
|
+
version?: number;
|
|
33
|
+
createdAt?: string;
|
|
34
|
+
modifiedAt?: string;
|
|
35
|
+
mixins?: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
interface LegalEntity {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
type: LegalEntityType;
|
|
41
|
+
parentId?: string;
|
|
42
|
+
accountLimit?: AccountLimit;
|
|
43
|
+
legalInfo?: LegalInfo;
|
|
44
|
+
customerGroups?: CustomerGroupRef[];
|
|
45
|
+
entitiesAddresses?: ResourceId[];
|
|
46
|
+
approvalGroup?: ResourceId[];
|
|
47
|
+
restrictions?: string[];
|
|
48
|
+
metadata?: Metadata;
|
|
49
|
+
mixins?: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
interface LegalEntityCreate {
|
|
52
|
+
id?: string;
|
|
53
|
+
name: string;
|
|
54
|
+
type?: LegalEntityType;
|
|
55
|
+
parentId?: string;
|
|
56
|
+
accountLimit?: AccountLimit;
|
|
57
|
+
legalInfo?: LegalInfo;
|
|
58
|
+
customerGroups?: CustomerGroupRef[];
|
|
59
|
+
entitiesAddresses?: ResourceId[];
|
|
60
|
+
approvalGroup?: ResourceId[];
|
|
61
|
+
restrictions?: string[];
|
|
62
|
+
metadata?: {
|
|
63
|
+
mixins?: Record<string, unknown>;
|
|
64
|
+
};
|
|
65
|
+
mixins?: Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
interface LegalEntityUpdate {
|
|
68
|
+
name?: string;
|
|
69
|
+
parentId?: string;
|
|
70
|
+
accountLimit?: AccountLimit;
|
|
71
|
+
legalInfo?: LegalInfo;
|
|
72
|
+
customerGroups?: CustomerGroupRef[];
|
|
73
|
+
entitiesAddresses?: ResourceId[];
|
|
74
|
+
approvalGroup?: ResourceId[];
|
|
75
|
+
restrictions?: string[];
|
|
76
|
+
metadata?: {
|
|
77
|
+
version: number;
|
|
78
|
+
mixins?: Record<string, unknown>;
|
|
79
|
+
};
|
|
80
|
+
mixins?: Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
type ContactAssignmentType = "PRIMARY" | "BILLING" | "LOGISTICS" | "CONTACT";
|
|
83
|
+
interface ContactAssignment {
|
|
84
|
+
id: string;
|
|
85
|
+
legalEntity?: LegalEntity | {
|
|
86
|
+
id: string;
|
|
87
|
+
};
|
|
88
|
+
customer?: {
|
|
89
|
+
id: string;
|
|
90
|
+
name?: string;
|
|
91
|
+
surname?: string;
|
|
92
|
+
email?: string;
|
|
93
|
+
phone?: string;
|
|
94
|
+
};
|
|
95
|
+
type?: ContactAssignmentType;
|
|
96
|
+
primary?: boolean;
|
|
97
|
+
metadata?: Metadata;
|
|
98
|
+
mixins?: Record<string, unknown>;
|
|
99
|
+
}
|
|
100
|
+
interface ContactAssignmentCreate {
|
|
101
|
+
id?: string;
|
|
102
|
+
legalEntity: {
|
|
103
|
+
id: string;
|
|
104
|
+
};
|
|
105
|
+
customer: {
|
|
106
|
+
id: string;
|
|
107
|
+
};
|
|
108
|
+
type?: ContactAssignmentType;
|
|
109
|
+
primary?: boolean;
|
|
110
|
+
metadata?: {
|
|
111
|
+
mixins?: Record<string, unknown>;
|
|
112
|
+
};
|
|
113
|
+
mixins?: Record<string, unknown>;
|
|
114
|
+
}
|
|
115
|
+
interface ContactAssignmentUpdate {
|
|
116
|
+
type?: ContactAssignmentType;
|
|
117
|
+
primary?: boolean;
|
|
118
|
+
metadata?: {
|
|
119
|
+
version: number;
|
|
120
|
+
mixins?: Record<string, unknown>;
|
|
121
|
+
};
|
|
122
|
+
mixins?: Record<string, unknown>;
|
|
123
|
+
}
|
|
124
|
+
type LocationType = "HEADQUARTER" | "WAREHOUSE" | "OFFICE";
|
|
125
|
+
interface ContactDetails {
|
|
126
|
+
emails?: string[];
|
|
127
|
+
phones?: string[];
|
|
128
|
+
addressLine1?: string;
|
|
129
|
+
addressLine2?: string;
|
|
130
|
+
city?: string;
|
|
131
|
+
state?: string;
|
|
132
|
+
postcode?: string;
|
|
133
|
+
countryCode?: string;
|
|
134
|
+
tags?: string[];
|
|
135
|
+
}
|
|
136
|
+
interface Location {
|
|
137
|
+
id: string;
|
|
138
|
+
name: string;
|
|
139
|
+
type: LocationType;
|
|
140
|
+
contactDetails?: ContactDetails;
|
|
141
|
+
metadata?: Metadata;
|
|
142
|
+
mixins?: Record<string, unknown>;
|
|
143
|
+
}
|
|
144
|
+
interface LocationCreate {
|
|
145
|
+
id?: string;
|
|
146
|
+
legalEntityId: string;
|
|
147
|
+
name: string;
|
|
148
|
+
type: LocationType;
|
|
149
|
+
contactDetails?: ContactDetails;
|
|
150
|
+
metadata?: {
|
|
151
|
+
mixins?: Record<string, unknown>;
|
|
152
|
+
};
|
|
153
|
+
mixins?: Record<string, unknown>;
|
|
154
|
+
}
|
|
155
|
+
interface LocationUpdate {
|
|
156
|
+
name?: string;
|
|
157
|
+
type?: LocationType;
|
|
158
|
+
contactDetails?: ContactDetails;
|
|
159
|
+
metadata?: {
|
|
160
|
+
version: number;
|
|
161
|
+
mixins?: Record<string, unknown>;
|
|
162
|
+
};
|
|
163
|
+
mixins?: Record<string, unknown>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type { AccountLimit as A, ContactAssignment as C, LegalEntity as L, ContactAssignmentCreate as a, ContactAssignmentType as b, ContactAssignmentUpdate as c, ContactDetails as d, CustomerGroupRef as e, LegalEntityCreate as f, LegalEntityType as g, LegalEntityUpdate as h, LegalInfo as i, Location as j, LocationCreate as k, LocationType as l, LocationUpdate as m };
|