@viu/emporix-sdk 2.8.0 → 2.9.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 +64 -0
- package/dist/{chunk-5JHTZBOC.js → chunk-B4UOYJKW.js} +12 -2
- package/dist/chunk-B4UOYJKW.js.map +1 -0
- package/dist/{chunk-SCI7D74B.js → chunk-BK25FDTH.js} +17 -5
- package/dist/chunk-BK25FDTH.js.map +1 -0
- package/dist/{chunk-B56JZNI7.js → chunk-HAEVK6IS.js} +6 -3
- package/dist/chunk-HAEVK6IS.js.map +1 -0
- package/dist/{chunk-6UNFMCHZ.js → chunk-KVBCTXVH.js} +2 -2
- package/dist/chunk-KVBCTXVH.js.map +1 -0
- package/dist/{chunk-NM7VDXBR.js → chunk-LGLFJL3S.js} +6 -3
- package/dist/chunk-LGLFJL3S.js.map +1 -0
- package/dist/chunk-LGOC5XOI.js +40 -0
- package/dist/chunk-LGOC5XOI.js.map +1 -0
- package/dist/{chunk-RXVVFNYN.js → chunk-MM6JF3Z7.js} +6 -3
- package/dist/chunk-MM6JF3Z7.js.map +1 -0
- package/dist/companies.cjs +4 -1
- package/dist/companies.cjs.map +1 -1
- package/dist/companies.d.cts +7 -4
- package/dist/companies.d.ts +7 -4
- package/dist/companies.js +1 -1
- package/dist/contacts.cjs +4 -1
- package/dist/contacts.cjs.map +1 -1
- package/dist/contacts.d.cts +6 -4
- package/dist/contacts.d.ts +6 -4
- package/dist/contacts.js +1 -1
- package/dist/customer-groups.cjs +17 -0
- package/dist/customer-groups.cjs.map +1 -1
- package/dist/customer-groups.d.cts +94 -21
- package/dist/customer-groups.d.ts +94 -21
- package/dist/customer-groups.js +1 -1
- package/dist/index.cjs +63 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +23 -16
- package/dist/index.js.map +1 -1
- package/dist/locations.cjs +4 -1
- package/dist/locations.cjs.map +1 -1
- package/dist/locations.d.cts +7 -4
- package/dist/locations.d.ts +7 -4
- package/dist/locations.js +1 -1
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.d.cts +1726 -80
- package/dist/orders.d.ts +1726 -80
- package/dist/orders.js +1 -1
- package/dist/price.cjs +15 -3
- package/dist/price.cjs.map +1 -1
- package/dist/price.d.cts +23 -4
- package/dist/price.d.ts +23 -4
- package/dist/price.js +1 -1
- package/dist/product.cjs +10 -0
- package/dist/product.cjs.map +1 -1
- package/dist/product.d.cts +10 -0
- package/dist/product.d.ts +10 -0
- package/dist/product.js +1 -1
- package/dist/types.gen-C_wOXYZB.d.cts +455 -0
- package/dist/types.gen-C_wOXYZB.d.ts +455 -0
- package/package.json +1 -1
- package/dist/chunk-5JHTZBOC.js.map +0 -1
- package/dist/chunk-6UNFMCHZ.js.map +0 -1
- package/dist/chunk-B56JZNI7.js.map +0 -1
- package/dist/chunk-NM7VDXBR.js.map +0 -1
- package/dist/chunk-RXVVFNYN.js.map +0 -1
- package/dist/chunk-SCI7D74B.js.map +0 -1
- package/dist/chunk-SKX7KCMH.js +0 -23
- package/dist/chunk-SKX7KCMH.js.map +0 -1
- package/dist/types.gen-D1QuqPLs.d.cts +0 -166
- package/dist/types.gen-D1QuqPLs.d.ts +0 -166
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,69 @@
|
|
|
1
1
|
# @viu/emporix-sdk
|
|
2
2
|
|
|
3
|
+
## 2.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#108](https://github.com/viuteam/emporix-sdk/pull/108) [`056cb62`](https://github.com/viuteam/emporix-sdk/commit/056cb622106fa5854ec9ebbee6e91c4820e62b29) Thanks [@amnael1](https://github.com/amnael1)! - feat(sdk): generate customer-management types from the real OpenAPI spec
|
|
8
|
+
|
|
9
|
+
Replaces the hand-written customer-management mirror (B2B legal-entities /
|
|
10
|
+
contact-assignments / locations) with codegen output from the vendored
|
|
11
|
+
"Customer Management Service" spec, so Companies/Contacts/Locations return the
|
|
12
|
+
real API shape. The `update` methods (and the matching `useUpdateCompany` /
|
|
13
|
+
`useUpdateContactAssignment` / `useUpdateLocation` hooks) now type their PATCH
|
|
14
|
+
body as `Partial<*Update>` to reflect the partial-update endpoint. `LegalEntity.id`
|
|
15
|
+
and sibling ids are optional in the generated shape, matching the wire contract.
|
|
16
|
+
|
|
17
|
+
- [#109](https://github.com/viuteam/emporix-sdk/pull/109) [`f90e05b`](https://github.com/viuteam/emporix-sdk/commit/f90e05b97f6c022660bc36ac3656e2f48bf78e69) Thanks [@amnael1](https://github.com/amnael1)! - feat(sdk): generate IAM types, add group member mutations
|
|
18
|
+
|
|
19
|
+
Replaces the last hand-written `generated/` mirror (`iam`) with codegen from the
|
|
20
|
+
vendored "IAM Service" spec, so `customerGroups.listForCompany` returns the real
|
|
21
|
+
group shape (`GroupsQueryDocument` — note: the wire uses `code`/`userType`, not
|
|
22
|
+
the previously-mirrored `role`, which never existed on the API). Ships the
|
|
23
|
+
previously-deferred group member mutations now that the endpoints are confirmed:
|
|
24
|
+
`customerGroups.addMember` / `removeMember`, plus the `useAddGroupMember` /
|
|
25
|
+
`useRemoveGroupMember` React hooks. No hand-written generated mirrors remain.
|
|
26
|
+
|
|
27
|
+
- [#106](https://github.com/viuteam/emporix-sdk/pull/106) [`04b95ea`](https://github.com/viuteam/emporix-sdk/commit/04b95eab1fbf6b09ca29b0e3a98605e5ef938c6c) Thanks [@amnael1](https://github.com/amnael1)! - feat(sdk): generate order-v2 types from the real OpenAPI spec
|
|
28
|
+
|
|
29
|
+
Replaces the hand-written `order-v2` type mirror (which invented `items`,
|
|
30
|
+
`{amount,currency}` totals and a top-level `orderNumber`) with codegen output
|
|
31
|
+
from the vendored Emporix Order Service spec. `OrdersService` and
|
|
32
|
+
`SalesOrdersService` now return the real API shape:
|
|
33
|
+
- line items are `entries` (not `items`); each entry has `itemYrn`,
|
|
34
|
+
`orderedAmount`/`amount`, and a nested `product`
|
|
35
|
+
- `totalPrice`/`subTotalPrice` are numbers + a top-level `currency`; rich
|
|
36
|
+
net/gross/tax lives in `calculatedPrice`
|
|
37
|
+
- `orderNumber` is under `mixins.generalAttributes`
|
|
38
|
+
- `SalesOrderPatch` is now `Partial<OrderUpdateDto>` (the real PATCH body)
|
|
39
|
+
|
|
40
|
+
Public type surface: `Order`, `OrderEntry`, `OrderStatus`, `SalesOrder`,
|
|
41
|
+
`Transition`, `SalesOrderPatch`. The unused fictional re-exports (`OrderItem`,
|
|
42
|
+
`OrderMoney`, `OrderCustomer`, `OrderAddress`, `OrderPayment`, `OrderDelivery`,
|
|
43
|
+
`OrderTaxLine`, `OrderMetadata`, `OrderTransition`) are removed — they had no
|
|
44
|
+
runtime counterpart.
|
|
45
|
+
|
|
46
|
+
`useReorder` now reads `entries` and re-adds each with its `itemYrn` + price row
|
|
47
|
+
(`priceId`/amounts/currency) — the cart requires a price, so the previous
|
|
48
|
+
`{ product: { id } }` body always failed; reorder now actually works.
|
|
49
|
+
|
|
50
|
+
- [#104](https://github.com/viuteam/emporix-sdk/pull/104) [`2bf31b2`](https://github.com/viuteam/emporix-sdk/commit/2bf31b230bc18c8ce17e3a41110e5b3edcb21f4c) Thanks [@amnael1](https://github.com/amnael1)! - feat(price): expose canonical `itemId` on price-match results + `productIdFromYrn`
|
|
51
|
+
|
|
52
|
+
The deployed Emporix price API returns the matched item under `itemId` (with a
|
|
53
|
+
localized `name`), but the OpenAPI spec/codegen type calls it `itemRef` — so the
|
|
54
|
+
typed field was always `undefined` at runtime. `PriceService.match` /
|
|
55
|
+
`matchByContext` / `matchByContextChunked` now expose `itemId` canonically and
|
|
56
|
+
keep `itemRef` populated (mirrored from `itemId`) but `@deprecated`. Adds a
|
|
57
|
+
`productIdFromYrn(yrn)` helper to extract a product id from an `itemYrn`.
|
|
58
|
+
|
|
59
|
+
- [#107](https://github.com/viuteam/emporix-sdk/pull/107) [`975290c`](https://github.com/viuteam/emporix-sdk/commit/975290c7bd6129754d82e131186cade633394836) Thanks [@amnael1](https://github.com/amnael1)! - feat(product): add searchByName free-text helper + useProductNameSearch
|
|
60
|
+
|
|
61
|
+
`products.searchByName(term)` builds the Emporix `name:(~<term>)` regex filter
|
|
62
|
+
(escaping metacharacters) and delegates to `search`, so consumers no longer
|
|
63
|
+
hand-build the `q` DSL — a bare free-text term otherwise 400s with
|
|
64
|
+
"No value for key …". Adds the `useProductNameSearch` React hook (disabled on
|
|
65
|
+
empty/whitespace).
|
|
66
|
+
|
|
3
67
|
## 2.8.0
|
|
4
68
|
|
|
5
69
|
### Minor Changes
|
|
@@ -56,6 +56,16 @@ var ProductService = class {
|
|
|
56
56
|
});
|
|
57
57
|
return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Free-text product search by name. The product `q` is a `field:value` DSL,
|
|
61
|
+
* so a bare term (e.g. "in time") 400s with "No value for key …". This builds
|
|
62
|
+
* a `name:(~<term>)` regex filter (regex metacharacters escaped) and delegates
|
|
63
|
+
* to {@link search}.
|
|
64
|
+
*/
|
|
65
|
+
async searchByName(query, params = {}, auth = ANON) {
|
|
66
|
+
const escaped = query.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
67
|
+
return this.search(`name:(~${escaped})`, params, auth);
|
|
68
|
+
}
|
|
59
69
|
/**
|
|
60
70
|
* Bulk fetch by id. POSTs `/products/search` with `q="id:(id1,id2,…)"`,
|
|
61
71
|
* chunking when the list is larger than `options.chunkSize` (default
|
|
@@ -148,5 +158,5 @@ var ProductService = class {
|
|
|
148
158
|
};
|
|
149
159
|
|
|
150
160
|
export { ProductService };
|
|
151
|
-
//# sourceMappingURL=chunk-
|
|
152
|
-
//# sourceMappingURL=chunk-
|
|
161
|
+
//# sourceMappingURL=chunk-B4UOYJKW.js.map
|
|
162
|
+
//# sourceMappingURL=chunk-B4UOYJKW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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JKW.js","sourcesContent":["import type { ClientContext, PaginatedItems } from \"../core/context\";\nimport { iterateAll } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n BasicProductWithId,\n BundleProductWithId,\n ParentVariantProductWithId,\n ProductMedia,\n} from \"../generated/product\";\n\nconst ANON: AuthContext = { kind: \"anonymous\" };\n\n/** A product as returned by the Product service (all generated fields). */\nexport type Product = BasicProductWithId | BundleProductWithId | ParentVariantProductWithId;\n\n/** A single product media entry (generated; `ProductMedia` is the list type). */\nexport type Media = ProductMedia[number];\n\n/** Catalog reads. Default auth: anonymous; pass customer for personalized pricing. */\nexport class ProductService {\n constructor(private readonly ctx: ClientContext) {}\n\n /** Fetches one product by id. */\n async get(\n productId: string,\n _opts?: Record<string, never>,\n auth: AuthContext = ANON,\n ): Promise<Product> {\n return this.ctx.http.request<Product>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products/${productId}`,\n auth,\n });\n }\n\n /** Fetches one product by its code. */\n async getByCode(code: string, auth: AuthContext = ANON): Promise<Product> {\n const rows = await this.ctx.http.request<Product[]>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products`,\n query: { q: `code:${code}` },\n auth,\n });\n const first = rows[0];\n if (!first) throw new Error(`No product with code \"${code}\"`);\n return first;\n }\n\n /** One page of products. */\n async list(\n params: { pageNumber?: number; pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Product>> {\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n const items = await this.ctx.http.request<Product[]>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products`,\n query: { pageNumber, pageSize },\n auth,\n });\n return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };\n }\n\n /** Async-iterates every product across pages. */\n listAll(params: { pageSize?: number } = {}, auth: AuthContext = ANON): AsyncIterable<Product> {\n const pageSize = params.pageSize ?? 50;\n return iterateAll<Product>((pageNumber) => this.list({ pageNumber, pageSize }, auth));\n }\n\n /** Searches products by free-text query. */\n async search(\n query: string,\n params: { pageNumber?: number; pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Product>> {\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n const items = await this.ctx.http.request<Product[]>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products`,\n query: { q: query, pageNumber, pageSize },\n auth,\n });\n return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };\n }\n\n /**\n * Free-text product search by name. The product `q` is a `field:value` DSL,\n * so a bare term (e.g. \"in time\") 400s with \"No value for key …\". This builds\n * a `name:(~<term>)` regex filter (regex metacharacters escaped) and delegates\n * to {@link search}.\n */\n async searchByName(\n query: string,\n params: { pageNumber?: number; pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Product>> {\n const escaped = query.trim().replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return this.search(`name:(~${escaped})`, params, auth);\n }\n\n /**\n * Bulk fetch by id. POSTs `/products/search` with `q=\"id:(id1,id2,…)\"`,\n * chunking when the list is larger than `options.chunkSize` (default\n * 100). An empty list short-circuits with no HTTP call. **Order is not\n * guaranteed** across chunks — re-index by `id` if order matters.\n */\n async searchByIds(\n ids: string[],\n options: { chunkSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<Product[]> {\n if (ids.length === 0) return [];\n const chunkSize = options.chunkSize ?? 100;\n const chunks: string[][] = [];\n for (let i = 0; i < ids.length; i += chunkSize) {\n chunks.push(ids.slice(i, i + chunkSize));\n }\n const pages = await Promise.all(\n chunks.map((chunk) =>\n this.ctx.http.request<Product[]>({\n method: \"POST\",\n path: `/product/${this.ctx.tenant}/products/search`,\n query: { pageSize: chunk.length },\n auth,\n body: { q: `id:(${chunk.join(\",\")})` },\n }),\n ),\n );\n return pages.flat();\n }\n\n /**\n * Bulk fetch by code. POSTs `/products/search` with `q=\"code:(c1,c2,…)\"`,\n * chunking when the list is larger than `options.chunkSize` (default 100).\n * Duplicate codes are de-duplicated. Codes containing query-delimiter\n * characters (`(`, `)`, `,`, whitespace, `\"`) are dropped with a logged\n * warning, because the Emporix `q` syntax uses them as delimiters and does\n * not support escaping them in a plain IN-list. An empty list — or one with\n * no safe codes — short-circuits with no HTTP call. **Order is not\n * guaranteed** across chunks — re-index by `code` if order matters.\n */\n async searchByCodes(\n codes: string[],\n options: { chunkSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<Product[]> {\n const unique = [...new Set(codes)];\n const unsafe = /[(),\"\\s]/;\n const safe = unique.filter((c) => !unsafe.test(c));\n const dropped = unique.filter((c) => unsafe.test(c));\n if (dropped.length > 0) {\n this.ctx.logger.warn(\n \"products.searchByCodes: dropped codes containing query-delimiter characters\",\n { dropped },\n );\n }\n if (safe.length === 0) return [];\n const chunkSize = options.chunkSize ?? 100;\n const chunks: string[][] = [];\n for (let i = 0; i < safe.length; i += chunkSize) {\n chunks.push(safe.slice(i, i + chunkSize));\n }\n const pages = await Promise.all(\n chunks.map((chunk) =>\n this.ctx.http.request<Product[]>({\n method: \"POST\",\n path: `/product/${this.ctx.tenant}/products/search`,\n query: { pageSize: chunk.length },\n auth,\n body: { q: `code:(${chunk.join(\",\")})` },\n }),\n ),\n );\n return pages.flat();\n }\n\n /**\n * Streams the VARIANT children of a PARENT_VARIANT product, page by page,\n * via the search query `productType:VARIANT parentVariantId:<id>`. Default\n * pageSize 200. The query syntax (space-separated fields = implicit AND) is\n * encapsulated here so consumers don't build it themselves.\n */\n listVariantChildrenAll(\n parentVariantId: string,\n params: { pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): AsyncIterable<Product> {\n const pageSize = params.pageSize ?? 200;\n const q = `productType:VARIANT parentVariantId:${parentVariantId}`;\n return iterateAll<Product>((pageNumber) => this.search(q, { pageNumber, pageSize }, auth));\n }\n\n /**\n * Resolves ALL VARIANT children of a PARENT_VARIANT product into a flat\n * array (loads every page). Default pageSize 200. Returns `[]` when there are\n * no children — never throws.\n */\n async listVariantChildren(\n parentVariantId: string,\n params: { pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<Product[]> {\n const out: Product[] = [];\n for await (const child of this.listVariantChildrenAll(parentVariantId, params, auth)) {\n out.push(child);\n }\n return out;\n }\n}\n"]}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { EmporixAuthError } from './chunk-KTODT6DV.js';
|
|
2
2
|
|
|
3
3
|
// src/services/price.ts
|
|
4
|
+
function normalizeMatch(raw) {
|
|
5
|
+
const itemId = raw.itemId ?? raw.itemRef;
|
|
6
|
+
const base = raw;
|
|
7
|
+
if (!itemId) return base;
|
|
8
|
+
const itemRef = {
|
|
9
|
+
...itemId.itemType !== void 0 ? { itemType: itemId.itemType } : {},
|
|
10
|
+
...itemId.id !== void 0 ? { id: itemId.id } : {}
|
|
11
|
+
};
|
|
12
|
+
return { ...base, itemId, itemRef };
|
|
13
|
+
}
|
|
4
14
|
var ANON = { kind: "anonymous" };
|
|
5
15
|
var SERVICE = { kind: "service" };
|
|
6
16
|
function requireContextAuth(auth) {
|
|
@@ -21,24 +31,26 @@ var PriceService = class {
|
|
|
21
31
|
* anonymous; pass a customer/raw context for personalized pricing.
|
|
22
32
|
*/
|
|
23
33
|
async matchByContext(input, auth) {
|
|
24
|
-
|
|
34
|
+
const rows = await this.ctx.http.request({
|
|
25
35
|
method: "POST",
|
|
26
36
|
path: `/price/${this.ctx.tenant}/match-prices-by-context`,
|
|
27
37
|
auth: requireContextAuth(auth),
|
|
28
38
|
body: input
|
|
29
39
|
});
|
|
40
|
+
return rows.map(normalizeMatch);
|
|
30
41
|
}
|
|
31
42
|
/**
|
|
32
43
|
* Resolves prices from an explicit context. Default auth: service
|
|
33
44
|
* (requires `price.price_read` / `price.price_manage`).
|
|
34
45
|
*/
|
|
35
46
|
async match(input, auth = SERVICE) {
|
|
36
|
-
|
|
47
|
+
const rows = await this.ctx.http.request({
|
|
37
48
|
method: "POST",
|
|
38
49
|
path: `/price/${this.ctx.tenant}/match-prices`,
|
|
39
50
|
auth,
|
|
40
51
|
body: input
|
|
41
52
|
});
|
|
53
|
+
return rows.map(normalizeMatch);
|
|
42
54
|
}
|
|
43
55
|
/**
|
|
44
56
|
* Chunked variant of {@link matchByContext} for large `items` arrays. The
|
|
@@ -51,7 +63,7 @@ var PriceService = class {
|
|
|
51
63
|
* `throwOnAnyChunkError: true` to reject on the first failure instead.
|
|
52
64
|
*
|
|
53
65
|
* **Result order is not guaranteed** — match entries back to your items by
|
|
54
|
-
* `priceId` / `
|
|
66
|
+
* `priceId` / `itemId.id`.
|
|
55
67
|
*/
|
|
56
68
|
async matchByContextChunked(input, opts = {}, auth) {
|
|
57
69
|
const chunkSize = opts.chunkSize ?? 50;
|
|
@@ -87,5 +99,5 @@ var PriceService = class {
|
|
|
87
99
|
};
|
|
88
100
|
|
|
89
101
|
export { PriceService };
|
|
90
|
-
//# sourceMappingURL=chunk-
|
|
91
|
-
//# sourceMappingURL=chunk-
|
|
102
|
+
//# sourceMappingURL=chunk-BK25FDTH.js.map
|
|
103
|
+
//# sourceMappingURL=chunk-BK25FDTH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/price.ts"],"names":[],"mappings":";;;AAuCA,SAAS,eAAe,GAAA,EAAgC;AACtD,EAAA,MAAM,MAAA,GAAU,GAAA,CAAuD,MAAA,IAAU,GAAA,CAAI,OAAA;AACrF,EAAA,MAAM,IAAA,GAAO,GAAA;AACb,EAAA,IAAI,CAAC,QAAQ,OAAO,IAAA;AAGpB,EAAA,MAAM,OAAA,GAA6B;AAAA,IACjC,GAAI,OAAO,QAAA,KAAa,MAAA,GAAY,EAAE,QAAA,EAAU,MAAA,CAAO,QAAA,EAAS,GAAI,EAAC;AAAA,IACrE,GAAI,OAAO,EAAA,KAAO,MAAA,GAAY,EAAE,EAAA,EAAI,MAAA,CAAO,EAAA,EAAG,GAAI;AAAC,GACrD;AACA,EAAA,OAAO,EAAE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,GAAG,CAAA;AACxB,QAAA,IAAI,UAAU,MAAA,EAAW;AACzB,QAAA,IAAI;AACF,UAAA,OAAA,CAAQ,GAAG,CAAA,GAAI,MAAM,IAAA,CAAK,cAAA,CAAe,OAAO,IAAI,CAAA;AAAA,QACtD,SAAS,GAAA,EAAK;AACZ,UAAA,IAAI,IAAA,CAAK,sBAAsB,MAAM,GAAA;AACrC,UAAA,OAAA,CAAQ,GAAG,IAAI,EAAC;AAChB,UAAA,IAAA,CAAK,YAAA,GAAe,KAAK,GAAG,CAAA;AAAA,QAC9B;AAAA,MACF;AAAA,IACF,CAAA;AAEA,IAAA,MAAM,WAAA,GAAc,IAAA,CAAK,GAAA,CAAI,WAAA,EAAa,OAAO,MAAM,CAAA;AACvD,IAAA,MAAM,OAAA,CAAQ,GAAA,CAAI,KAAA,CAAM,IAAA,CAAK,EAAE,MAAA,EAAQ,WAAA,EAAY,EAAG,MAAM,MAAA,EAAQ,CAAC,CAAA;AAErE,IAAA,OAAO,QAAQ,IAAA,EAAK;AAAA,EACtB;AACF","file":"chunk-BK25FDTH.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixAuthError } from \"../core/errors\";\nimport type { Match, MatchByContext, MatchResponse } from \"../generated/price\";\n\n/** Session-context match request body (generated). */\nexport type PriceMatchByContextInput = MatchByContext;\n\n/** Explicit-context match request body (generated). */\nexport type PriceMatchInput = Match;\n\n/** Item (product or price) a price was matched for. */\nexport interface PriceMatchItemRef {\n itemType?: string;\n id?: string;\n /** Localized (or plain) product name — present on the live API, absent from the OpenAPI doc. */\n name?: Record<string, string> | string;\n}\n\n/**\n * A resolved price. Superset of the generated match-response schema: the\n * deployed API returns the matched item under `itemId` (with a localized\n * `name`), while the OpenAPI doc/codegen call it `itemRef`.\n */\nexport type PriceMatch = Omit<MatchResponse, \"itemRef\"> & {\n /** Item the price was matched for, as returned by the API. */\n itemId?: PriceMatchItemRef;\n /**\n * @deprecated The OpenAPI doc names this `itemRef`, but the deployed API\n * returns `itemId`. Mirrored from `itemId` for back-compat — prefer `itemId`.\n */\n itemRef?: PriceMatchItemRef;\n};\n\n/**\n * Normalizes a raw match row: the deployed API returns `itemId`, while the\n * codegen type calls it `itemRef`. Expose `itemId` canonically and mirror it\n * to the deprecated `itemRef` so existing consumers keep working.\n */\nfunction normalizeMatch(raw: MatchResponse): PriceMatch {\n const itemId = (raw as MatchResponse & { itemId?: PriceMatchItemRef }).itemId ?? raw.itemRef;\n const base = raw as PriceMatch;\n if (!itemId) return base;\n // Mirror only id/type into the deprecated itemRef (drop name); build without\n // explicit `undefined` for exactOptionalPropertyTypes.\n const itemRef: PriceMatchItemRef = {\n ...(itemId.itemType !== undefined ? { itemType: itemId.itemType } : {}),\n ...(itemId.id !== undefined ? { id: itemId.id } : {}),\n };\n return { ...base, itemId, itemRef };\n}\n\n/** Options for {@link PriceService.matchByContextChunked}. */\nexport interface MatchByContextChunkedOptions {\n /** Items per request. Default 50. Must be >= 1. */\n chunkSize?: number;\n /** Maximum number of requests in flight at once. Default 4. Must be >= 1. */\n concurrency?: number;\n /** Invoked once per failed chunk (default mode only — not when throwing). */\n onChunkError?: (err: unknown, chunkIndex: number) => void;\n /** When true, the first failing chunk rejects the whole call. Default false. */\n throwOnAnyChunkError?: boolean;\n}\n\nconst ANON: AuthContext = { kind: \"anonymous\" };\nconst SERVICE: AuthContext = { kind: \"service\" };\n\nfunction requireContextAuth(auth: AuthContext | undefined): AuthContext {\n const a = auth ?? ANON;\n if (a.kind === \"anonymous\" || a.kind === \"customer\" || a.kind === \"raw\") return a;\n throw new EmporixAuthError(\n \"match-prices-by-context requires an anonymous, customer, or raw AuthContext\",\n );\n}\n\n/**\n * Price matching. The Cart service does not resolve prices — call this\n * explicitly before rendering money and again right before placing an order.\n * The SDK is stateless: it never caches or revalidates prices.\n */\nexport class PriceService {\n constructor(private readonly ctx: ClientContext) {}\n\n /**\n * Resolves prices using the session context bound to the bearer token\n * (currency/site/country were set at anonymous-login time). Default auth:\n * anonymous; pass a customer/raw context for personalized pricing.\n */\n async matchByContext(\n input: PriceMatchByContextInput,\n auth?: AuthContext,\n ): Promise<PriceMatch[]> {\n const rows = await this.ctx.http.request<MatchResponse[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/match-prices-by-context`,\n auth: requireContextAuth(auth),\n body: input,\n });\n return rows.map(normalizeMatch);\n }\n\n /**\n * Resolves prices from an explicit context. Default auth: service\n * (requires `price.price_read` / `price.price_manage`).\n */\n async match(input: PriceMatchInput, auth: AuthContext = SERVICE): Promise<PriceMatch[]> {\n const rows = await this.ctx.http.request<MatchResponse[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/match-prices`,\n auth,\n body: input,\n });\n return rows.map(normalizeMatch);\n }\n\n /**\n * Chunked variant of {@link matchByContext} for large `items` arrays. The\n * Emporix backend handles only a limited number of items per request\n * (production limit ~50), so this splits `input.items` into chunks and runs\n * `matchByContext` with bounded concurrency.\n *\n * By default a failing chunk is skipped (its items are absent from the\n * result) and `opts.onChunkError` is called once for it; pass\n * `throwOnAnyChunkError: true` to reject on the first failure instead.\n *\n * **Result order is not guaranteed** — match entries back to your items by\n * `priceId` / `itemId.id`.\n */\n async matchByContextChunked(\n input: PriceMatchByContextInput,\n opts: MatchByContextChunkedOptions = {},\n auth?: AuthContext,\n ): Promise<PriceMatch[]> {\n const chunkSize = opts.chunkSize ?? 50;\n const concurrency = opts.concurrency ?? 4;\n if (chunkSize < 1) throw new Error(\"chunkSize must be >= 1\");\n if (concurrency < 1) throw new Error(\"concurrency must be >= 1\");\n\n const items = input.items ?? [];\n if (items.length === 0) return [];\n\n const chunks: PriceMatchByContextInput[] = [];\n for (let i = 0; i < items.length; i += chunkSize) {\n chunks.push({ ...input, items: items.slice(i, i + chunkSize) });\n }\n\n const results: PriceMatch[][] = new Array(chunks.length);\n let cursor = 0;\n\n const worker = async (): Promise<void> => {\n for (;;) {\n const idx = cursor++;\n const chunk = chunks[idx];\n if (chunk === undefined) return; // past the end\n try {\n results[idx] = await this.matchByContext(chunk, auth);\n } catch (err) {\n if (opts.throwOnAnyChunkError) throw err;\n results[idx] = [];\n opts.onChunkError?.(err, idx);\n }\n }\n };\n\n const workerCount = Math.min(concurrency, chunks.length);\n await Promise.all(Array.from({ length: workerCount }, () => worker()));\n\n return results.flat();\n }\n}\n"]}
|
|
@@ -25,7 +25,10 @@ var ContactsService = class {
|
|
|
25
25
|
body: input
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Patches a contact assignment. PATCH endpoint, so the body is a partial of
|
|
30
|
+
* the generated `ContactAssignmentUpdate` shape.
|
|
31
|
+
*/
|
|
29
32
|
async update(contactAssignmentId, patch, auth) {
|
|
30
33
|
return this.ctx.http.request({
|
|
31
34
|
method: "PATCH",
|
|
@@ -45,5 +48,5 @@ var ContactsService = class {
|
|
|
45
48
|
};
|
|
46
49
|
|
|
47
50
|
export { ContactsService };
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
51
|
+
//# sourceMappingURL=chunk-HAEVK6IS.js.map
|
|
52
|
+
//# sourceMappingURL=chunk-HAEVK6IS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/contacts.ts"],"names":[],"mappings":";AAeO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAErB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,qBAAA,EAAwB,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,oBAAA,CAAA;AAAA,EAChD;AAAA;AAAA,EAGA,MAAM,cAAA,CAAe,aAAA,EAAuB,IAAA,EAAiD;AAC3F,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA6B;AAAA,MAChD,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,KAAK,IAAA,EAAK;AAAA,MAChB,KAAA,EAAO,EAAE,aAAA,EAAc;AAAA,MACvB;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,MAAA,CAAO,KAAA,EAAgC,IAAA,EAA4C;AACvF,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAwB;AAAA,MAC3C,MAAA,EAAQ,MAAA;AAAA,MACR,IAAA,EAAM,KAAK,IAAA,EAAK;AAAA,MAChB,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,MAAA,CACJ,mBAAA,EACA,KAAA,EACA,IAAA,EAC4B;AAC5B,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA2B;AAAA,MAC9C,MAAA,EAAQ,OAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,mBAAmB,CAAA,CAAA;AAAA,MAC3C,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,QAAA,CAAS,mBAAA,EAA6B,IAAA,EAAkC;AAC5E,IAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,MAChC,MAAA,EAAQ,QAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,mBAAmB,CAAA,CAAA;AAAA,MAC3C;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-HAEVK6IS.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n ContactAssignment,\n ContactAssignmentCreate,\n ContactAssignmentUpdate,\n} from \"../generated/customer-management\";\n\n/**\n * Manages contact assignments linking customers to legal entities.\n *\n * `listForCompany` requires `customermanagement.contactassignment_read`;\n * `assign`/`update`/`unassign` require `_manage`. The query param\n * `legalEntityId` scopes the list to one company.\n */\nexport class ContactsService {\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/customer-management/${this.ctx.tenant}/contact-assignments`;\n }\n\n /** Lists contact assignments for one legal entity. */\n async listForCompany(legalEntityId: string, auth: AuthContext): Promise<ContactAssignment[]> {\n return this.ctx.http.request<ContactAssignment[]>({\n method: \"GET\",\n path: this.base(),\n query: { legalEntityId },\n auth,\n });\n }\n\n /** Creates a contact assignment. */\n async assign(input: ContactAssignmentCreate, auth: AuthContext): Promise<{ id: string }> {\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: input,\n });\n }\n\n /**\n * Patches a contact assignment. PATCH endpoint, so the body is a partial of\n * the generated `ContactAssignmentUpdate` shape.\n */\n async update(\n contactAssignmentId: string,\n patch: Partial<ContactAssignmentUpdate>,\n auth: AuthContext,\n ): Promise<ContactAssignment> {\n return this.ctx.http.request<ContactAssignment>({\n method: \"PATCH\",\n path: `${this.base()}/${contactAssignmentId}`,\n auth,\n body: patch,\n });\n }\n\n /** Deletes a contact assignment. */\n async unassign(contactAssignmentId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${contactAssignmentId}`,\n auth,\n });\n }\n}\n"]}
|
|
@@ -91,5 +91,5 @@ var SalesOrdersService = class {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
export { OrdersService, SalesOrdersService };
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
95
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-KVBCTXVH.js.map
|
|
95
|
+
//# sourceMappingURL=chunk-KVBCTXVH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/orders.ts"],"names":[],"mappings":";AA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ClientContext, PaginatedItems } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type { Order, OrderStatus, OrderUpdateDto } from \"../generated/order-v2\";\n\n/**\n * Salesorder PATCH body. The generated `orderUpdateDto` models a full order\n * (it requires `entries`/`customer`), but `PATCH /salesorders/{id}` accepts a\n * subset — so the SDK exposes a partial of it.\n */\nexport type SalesOrderPatch = Partial<OrderUpdateDto>;\n\n/** Optional fields supported by the order-v2 list endpoint. */\nexport interface ListMyOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n status?: OrderStatus;\n legalEntityId?: string;\n siteCode?: string;\n saasToken?: string;\n}\n\n/** Options for single-order reads (saas-token only). */\nexport interface GetOrderOptions {\n saasToken?: string;\n}\n\n/** Options for status transitions. */\nexport interface OrderTransitionOptions {\n saasToken?: string;\n comment?: string;\n}\n\n/** Options for `salesOrders.update`. */\nexport interface UpdateSalesOrderOptions {\n /** Forwarded as `?recalculate=`. Omit to use the server default (true). */\n recalculate?: boolean;\n}\n\nfunction setIfDefined<V>(\n q: Record<string, string | number | undefined>,\n key: string,\n value: V | undefined,\n): void {\n if (value !== undefined && value !== \"\") {\n q[key] = value as unknown as string | number;\n }\n}\n\n/**\n * Storefront-customer access to Order-v2's customer endpoints.\n *\n * `listMine`/`get` require `order.order_read_own`; transitions require\n * `order.order_manage_own`. All methods accept an optional `saasToken` that\n * is passed as the `saas-token` header (mirrors `checkout.placeOrder`).\n */\nexport class OrdersService {\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/order-v2/${this.ctx.tenant}/orders`;\n }\n\n private saasHeader(saasToken: string | undefined): Record<string, string> | undefined {\n return saasToken ? { \"saas-token\": saasToken } : undefined;\n }\n\n /** Lists the calling customer's orders. */\n async listMine(\n auth: AuthContext,\n opts: ListMyOrdersOptions = {},\n ): Promise<PaginatedItems<Order>> {\n const query: Record<string, string | number | undefined> = {};\n setIfDefined(query, \"pageNumber\", opts.pageNumber);\n setIfDefined(query, \"pageSize\", opts.pageSize);\n setIfDefined(query, \"status\", opts.status);\n setIfDefined(query, \"legalEntityId\", opts.legalEntityId);\n setIfDefined(query, \"siteCode\", opts.siteCode);\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<PaginatedItems<Order>>({\n method: \"GET\",\n path: this.base(),\n query,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Fetches one of the calling customer's orders by id. */\n async get(\n orderId: string,\n auth: AuthContext,\n opts: GetOrderOptions = {},\n ): Promise<Order> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<Order>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Transitions an order to a new status. Server enforces legal transitions. */\n async transition(\n orderId: string,\n status: OrderStatus,\n auth: AuthContext,\n opts: OrderTransitionOptions = {},\n ): Promise<void> {\n const body: { status: OrderStatus; comment?: string } = { status };\n if (opts.comment !== undefined) body.comment = opts.comment;\n const headers = this.saasHeader(opts.saasToken);\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/transitions`,\n auth,\n body,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Convenience: transitions to `DECLINED` (customer cancel). */\n async cancel(\n orderId: string,\n auth: AuthContext,\n opts: { saasToken?: string } = {},\n ): Promise<void> {\n await this.transition(orderId, \"DECLINED\", auth, opts);\n }\n}\n\n/**\n * Backend / service-account access to the merchant-facing\n * `/salesorders/{id}` resource. Requires `order.order_read` (read) /\n * `order.order_manage` (update) scopes on a service token.\n *\n * The full admin list + filter surface is deferred to a follow-up\n * sub-spec. This service ships only single-resource read + patch — the\n * common backend use case (e.g. mixin updates after fulfilment).\n */\nexport class SalesOrdersService {\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/order-v2/${this.ctx.tenant}/salesorders`;\n }\n\n /** Fetches a single sales-order by id. */\n async get(orderId: string, auth: AuthContext): Promise<Order> {\n return this.ctx.http.request<Order>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n });\n }\n\n /** Patches an existing order (status, mixins, customAttributes, metadata). */\n async update(\n orderId: string,\n patch: SalesOrderPatch,\n auth: AuthContext,\n opts: UpdateSalesOrderOptions = {},\n ): Promise<Order> {\n const query: Record<string, string> = {};\n if (opts.recalculate === false) query.recalculate = \"false\";\n return this.ctx.http.request<Order>({\n method: \"PATCH\",\n path: `${this.base()}/${orderId}`,\n auth,\n ...(Object.keys(query).length > 0 ? { query } : {}),\n body: patch,\n });\n }\n}\n"]}
|
|
@@ -33,7 +33,10 @@ var LocationsService = class {
|
|
|
33
33
|
body: input
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Patches a location. PATCH endpoint, so the body is a partial of the
|
|
38
|
+
* generated `LocationUpdate` shape.
|
|
39
|
+
*/
|
|
37
40
|
async update(locationId, patch, auth) {
|
|
38
41
|
return this.ctx.http.request({
|
|
39
42
|
method: "PATCH",
|
|
@@ -53,5 +56,5 @@ var LocationsService = class {
|
|
|
53
56
|
};
|
|
54
57
|
|
|
55
58
|
export { LocationsService };
|
|
56
|
-
//# sourceMappingURL=chunk-
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
59
|
+
//# sourceMappingURL=chunk-LGLFJL3S.js.map
|
|
60
|
+
//# sourceMappingURL=chunk-LGLFJL3S.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/locations.ts"],"names":[],"mappings":";AAeO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAErB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,qBAAA,EAAwB,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,UAAA,CAAA;AAAA,EAChD;AAAA;AAAA,EAGA,MAAM,cAAA,CAAe,a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I,IAAA,CAAK,OAAA,CAAc;AAAA,MAChC,MAAA,EAAQ,QAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,UAAU,CAAA,CAAA;AAAA,MAClC;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-LGLFJL3S.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n Location,\n LocationCreate,\n LocationUpdate,\n} from \"../generated/customer-management\";\n\n/**\n * Manages locations owned by a legal entity. Three types are supported:\n * HEADQUARTER, WAREHOUSE, OFFICE.\n *\n * Reads require `customermanagement.location_read`; mutations require\n * `_manage`.\n */\nexport class LocationsService {\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/customer-management/${this.ctx.tenant}/locations`;\n }\n\n /** Lists locations owned by one legal entity. */\n async listForCompany(legalEntityId: string, auth: AuthContext): Promise<Location[]> {\n return this.ctx.http.request<Location[]>({\n method: \"GET\",\n path: this.base(),\n query: { legalEntityId },\n auth,\n });\n }\n\n /** Fetches one location by id. */\n async get(locationId: string, auth: AuthContext): Promise<Location> {\n return this.ctx.http.request<Location>({\n method: \"GET\",\n path: `${this.base()}/${locationId}`,\n auth,\n });\n }\n\n /** Creates a location for a legal entity. */\n async create(input: LocationCreate, auth: AuthContext): Promise<{ id: string }> {\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: input,\n });\n }\n\n /**\n * Patches a location. PATCH endpoint, so the body is a partial of the\n * generated `LocationUpdate` shape.\n */\n async update(\n locationId: string,\n patch: Partial<LocationUpdate>,\n auth: AuthContext,\n ): Promise<Location> {\n return this.ctx.http.request<Location>({\n method: \"PATCH\",\n path: `${this.base()}/${locationId}`,\n auth,\n body: patch,\n });\n }\n\n /** Deletes a location. */\n async delete(locationId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${locationId}`,\n auth,\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/services/customer-groups.ts
|
|
2
|
+
var CustomerGroupsService = class {
|
|
3
|
+
constructor(ctx) {
|
|
4
|
+
this.ctx = ctx;
|
|
5
|
+
}
|
|
6
|
+
ctx;
|
|
7
|
+
base() {
|
|
8
|
+
return `/iam/${this.ctx.tenant}/groups`;
|
|
9
|
+
}
|
|
10
|
+
/** Lists customer groups belonging to one legal entity. */
|
|
11
|
+
async listForCompany(legalEntityId, auth) {
|
|
12
|
+
return this.ctx.http.request({
|
|
13
|
+
method: "GET",
|
|
14
|
+
path: this.base(),
|
|
15
|
+
query: { "b2b.legalEntityId": legalEntityId },
|
|
16
|
+
auth
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/** Adds a user (customer or employee) to a group. */
|
|
20
|
+
async addMember(groupId, member, auth) {
|
|
21
|
+
return this.ctx.http.request({
|
|
22
|
+
method: "POST",
|
|
23
|
+
path: `${this.base()}/${groupId}/users`,
|
|
24
|
+
auth,
|
|
25
|
+
body: member
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Removes a user from a group. */
|
|
29
|
+
async removeMember(groupId, userId, auth) {
|
|
30
|
+
await this.ctx.http.request({
|
|
31
|
+
method: "DELETE",
|
|
32
|
+
path: `${this.base()}/${groupId}/users/${userId}`,
|
|
33
|
+
auth
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { CustomerGroupsService };
|
|
39
|
+
//# sourceMappingURL=chunk-LGOC5XOI.js.map
|
|
40
|
+
//# sourceMappingURL=chunk-LGOC5XOI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/customer-groups.ts"],"names":[],"mappings":";AAeO,IAAM,wBAAN,MAA4B;AAAA,EACjC,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAErB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,KAAA,EAAQ,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,OAAA,CAAA;AAAA,EAChC;AAAA;AAAA,EAGA,MAAM,cAAA,CAAe,aAAA,EAAuB,IAAA,EAAmD;AAC7F,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA+B;AAAA,MAClD,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,KAAK,IAAA,EAAK;AAAA,MAChB,KAAA,EAAO,EAAE,mBAAA,EAAqB,aAAA,EAAc;AAAA,MAC5C;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,SAAA,CACJ,OAAA,EACA,MAAA,EACA,IAAA,EACyB;AACzB,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAwB;AAAA,MAC3C,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,MAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,YAAA,CAAa,OAAA,EAAiB,MAAA,EAAgB,IAAA,EAAkC;AACpF,IAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,MAChC,MAAA,EAAQ,QAAA;AAAA,MACR,IAAA,EAAM,GAAG,IAAA,CAAK,IAAA,EAAM,CAAA,CAAA,EAAI,OAAO,UAAU,MAAM,CAAA,CAAA;AAAA,MAC/C;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-LGOC5XOI.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n GroupsQueryDocument,\n AssignmentCreateRequest,\n} from \"../generated/iam\";\n\n/**\n * Access to IAM customer groups for a legal entity.\n *\n * `listForCompany` requires `iam.group_read`; the member mutations\n * (`addMember`/`removeMember`) require `iam.group_manage` — typically only\n * granted to Admin-group customers; a 403 surfaces as\n * `EmporixInsufficientScopeError`.\n */\nexport class CustomerGroupsService {\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/iam/${this.ctx.tenant}/groups`;\n }\n\n /** Lists customer groups belonging to one legal entity. */\n async listForCompany(legalEntityId: string, auth: AuthContext): Promise<GroupsQueryDocument[]> {\n return this.ctx.http.request<GroupsQueryDocument[]>({\n method: \"GET\",\n path: this.base(),\n query: { \"b2b.legalEntityId\": legalEntityId },\n auth,\n });\n }\n\n /** Adds a user (customer or employee) to a group. */\n async addMember(\n groupId: string,\n member: AssignmentCreateRequest,\n auth: AuthContext,\n ): Promise<{ id: string }> {\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: `${this.base()}/${groupId}/users`,\n auth,\n body: member,\n });\n }\n\n /** Removes a user from a group. */\n async removeMember(groupId: string, userId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${groupId}/users/${userId}`,\n auth,\n });\n }\n}\n"]}
|
|
@@ -32,7 +32,10 @@ var CompaniesService = class {
|
|
|
32
32
|
body: input
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Patches a legal entity. The endpoint is a PATCH, so the body is a partial
|
|
37
|
+
* of the generated `LegalEntityUpdate` (full-replace) shape.
|
|
38
|
+
*/
|
|
36
39
|
async update(legalEntityId, patch, auth) {
|
|
37
40
|
return this.ctx.http.request({
|
|
38
41
|
method: "PATCH",
|
|
@@ -52,5 +55,5 @@ var CompaniesService = class {
|
|
|
52
55
|
};
|
|
53
56
|
|
|
54
57
|
export { CompaniesService };
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
56
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingUR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,aAAA,EACA,KAAA,EACA,IAAA,EACsB;AACtB,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAqB;AAAA,MACxC,MAAA,EAAQ,OAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,aAAa,CAAA,CAAA;AAAA,MACrC,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,MAAA,CAAO,aAAA,EAAuB,IAAA,EAAkC;AACpE,IAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,MAChC,MAAA,EAAQ,QAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,aAAa,CAAA,CAAA;AAAA,MACrC;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-MM6JF3Z7.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n LegalEntity,\n LegalEntityCreate,\n LegalEntityUpdate,\n} from \"../generated/customer-management\";\n\n/**\n * Storefront-customer access to Legal Entities.\n *\n * `listMine`/`get` require `customermanagement.legalentity_read_own` on the\n * customer token. `create`/`update`/`delete` require the corresponding\n * `_manage` scopes — typically only granted to Admin-group customers; a 403\n * surfaces as `EmporixInsufficientScopeError`.\n */\nexport class CompaniesService {\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/customer-management/${this.ctx.tenant}/legal-entities`;\n }\n\n /** Lists the legal entities the calling customer is assigned to. */\n async listMine(auth: AuthContext): Promise<LegalEntity[]> {\n return this.ctx.http.request<LegalEntity[]>({\n method: \"GET\",\n path: this.base(),\n auth,\n });\n }\n\n /** Fetches a single legal entity by id. */\n async get(legalEntityId: string, auth: AuthContext): Promise<LegalEntity> {\n return this.ctx.http.request<LegalEntity>({\n method: \"GET\",\n path: `${this.base()}/${legalEntityId}`,\n auth,\n });\n }\n\n /** Creates a legal entity. Requires `customermanagement.legalentity_manage`. */\n async create(input: LegalEntityCreate, auth: AuthContext): Promise<{ id: string }> {\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: input,\n });\n }\n\n /**\n * Patches a legal entity. The endpoint is a PATCH, so the body is a partial\n * of the generated `LegalEntityUpdate` (full-replace) shape.\n */\n async update(\n legalEntityId: string,\n patch: Partial<LegalEntityUpdate>,\n auth: AuthContext,\n ): Promise<LegalEntity> {\n return this.ctx.http.request<LegalEntity>({\n method: \"PATCH\",\n path: `${this.base()}/${legalEntityId}`,\n auth,\n body: patch,\n });\n }\n\n /** Deletes a legal entity (async cascade on the server). */\n async delete(legalEntityId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${legalEntityId}`,\n auth,\n });\n }\n}\n"]}
|
package/dist/companies.cjs
CHANGED
|
@@ -34,7 +34,10 @@ var CompaniesService = class {
|
|
|
34
34
|
body: input
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Patches a legal entity. The endpoint is a PATCH, so the body is a partial
|
|
39
|
+
* of the generated `LegalEntityUpdate` (full-replace) shape.
|
|
40
|
+
*/
|
|
38
41
|
async update(legalEntityId, patch, auth) {
|
|
39
42
|
return this.ctx.http.request({
|
|
40
43
|
method: "PATCH",
|
package/dist/companies.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/services/companies.ts"],"names":[],"mappings":";;;AAgBO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAErB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,qBAAA,EAAwB,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,eA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AAAA,MACrC;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"companies.cjs","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n LegalEntity,\n LegalEntityCreate,\n LegalEntityUpdate,\n} from \"../generated/customer-management\";\n\n/**\n * Storefront-customer access to Legal Entities.\n *\n * `listMine`/`get` require `customermanagement.legalentity_read_own` on the\n * customer token. `create`/`update`/`delete` require the corresponding\n * `_manage` scopes — typically only granted to Admin-group customers; a 403\n * surfaces as `EmporixInsufficientScopeError`.\n */\nexport class CompaniesService {\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/customer-management/${this.ctx.tenant}/legal-entities`;\n }\n\n /** Lists the legal entities the calling customer is assigned to. */\n async listMine(auth: AuthContext): Promise<LegalEntity[]> {\n return this.ctx.http.request<LegalEntity[]>({\n method: \"GET\",\n path: this.base(),\n auth,\n });\n }\n\n /** Fetches a single legal entity by id. */\n async get(legalEntityId: string, auth: AuthContext): Promise<LegalEntity> {\n return this.ctx.http.request<LegalEntity>({\n method: \"GET\",\n path: `${this.base()}/${legalEntityId}`,\n auth,\n });\n }\n\n /** Creates a legal entity. Requires `customermanagement.legalentity_manage`. */\n async create(input: LegalEntityCreate, auth: AuthContext): Promise<{ id: string }> {\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: input,\n });\n }\n\n /**\n * Patches a legal entity. The endpoint is a PATCH, so the body is a partial\n * of the generated `LegalEntityUpdate` (full-replace) shape.\n */\n async update(\n legalEntityId: string,\n patch: Partial<LegalEntityUpdate>,\n auth: AuthContext,\n ): Promise<LegalEntity> {\n return this.ctx.http.request<LegalEntity>({\n method: \"PATCH\",\n path: `${this.base()}/${legalEntityId}`,\n auth,\n body: patch,\n });\n }\n\n /** Deletes a legal entity (async cascade on the server). */\n async delete(legalEntityId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${legalEntityId}`,\n auth,\n });\n }\n}\n"]}
|
package/dist/companies.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as ClientContext, b as AuthContext } from './context-DJDTlhLW.cjs';
|
|
2
|
-
import { L as LegalEntity,
|
|
3
|
-
export { A as AccountLimit,
|
|
2
|
+
import { L as LegalEntity, e as LegalEntityCreate, f as LegalEntityUpdate } from './types.gen-C_wOXYZB.cjs';
|
|
3
|
+
export { A as AccountLimit, d as CustomerGroup, g as LegalInfo } from './types.gen-C_wOXYZB.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Storefront-customer access to Legal Entities.
|
|
@@ -22,8 +22,11 @@ declare class CompaniesService {
|
|
|
22
22
|
create(input: LegalEntityCreate, auth: AuthContext): Promise<{
|
|
23
23
|
id: string;
|
|
24
24
|
}>;
|
|
25
|
-
/**
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Patches a legal entity. The endpoint is a PATCH, so the body is a partial
|
|
27
|
+
* of the generated `LegalEntityUpdate` (full-replace) shape.
|
|
28
|
+
*/
|
|
29
|
+
update(legalEntityId: string, patch: Partial<LegalEntityUpdate>, auth: AuthContext): Promise<LegalEntity>;
|
|
27
30
|
/** Deletes a legal entity (async cascade on the server). */
|
|
28
31
|
delete(legalEntityId: string, auth: AuthContext): Promise<void>;
|
|
29
32
|
}
|
package/dist/companies.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as ClientContext, b as AuthContext } from './context-DJDTlhLW.js';
|
|
2
|
-
import { L as LegalEntity,
|
|
3
|
-
export { A as AccountLimit,
|
|
2
|
+
import { L as LegalEntity, e as LegalEntityCreate, f as LegalEntityUpdate } from './types.gen-C_wOXYZB.js';
|
|
3
|
+
export { A as AccountLimit, d as CustomerGroup, g as LegalInfo } from './types.gen-C_wOXYZB.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Storefront-customer access to Legal Entities.
|
|
@@ -22,8 +22,11 @@ declare class CompaniesService {
|
|
|
22
22
|
create(input: LegalEntityCreate, auth: AuthContext): Promise<{
|
|
23
23
|
id: string;
|
|
24
24
|
}>;
|
|
25
|
-
/**
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Patches a legal entity. The endpoint is a PATCH, so the body is a partial
|
|
27
|
+
* of the generated `LegalEntityUpdate` (full-replace) shape.
|
|
28
|
+
*/
|
|
29
|
+
update(legalEntityId: string, patch: Partial<LegalEntityUpdate>, auth: AuthContext): Promise<LegalEntity>;
|
|
27
30
|
/** Deletes a legal entity (async cascade on the server). */
|
|
28
31
|
delete(legalEntityId: string, auth: AuthContext): Promise<void>;
|
|
29
32
|
}
|
package/dist/companies.js
CHANGED
package/dist/contacts.cjs
CHANGED
|
@@ -27,7 +27,10 @@ var ContactsService = class {
|
|
|
27
27
|
body: input
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Patches a contact assignment. PATCH endpoint, so the body is a partial of
|
|
32
|
+
* the generated `ContactAssignmentUpdate` shape.
|
|
33
|
+
*/
|
|
31
34
|
async update(contactAssignmentId, patch, auth) {
|
|
32
35
|
return this.ctx.http.request({
|
|
33
36
|
method: "PATCH",
|
package/dist/contacts.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/services/contacts.ts"],"names":[],"mappings":";;;AAeO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAErB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,qBAAA,EAAwB,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,oBAAA,CAAA;AAAA,EAChD;AAAA;AAAA,EAGA,MAAM,cAAA,CAAe,aAAA,EAAuB,IAAA,EAAiD;AAC3F,IAAA,OAAO,IAAA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EAAQ,MAAA;AAAA,MACR,IAAA,EAAM,KAAK,IAAA,EAAK;AAAA,MAChB,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,MAAA,CACJ,mBAAA,EACA,KAAA,EACA,IAAA,EAC4B;AAC5B,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA2B;AAAA,MAC9C,MAAA,EAAQ,OAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,mBAAmB,CAAA,CAAA;AAAA,MAC3C,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,QAAA,CAAS,mBAAA,EAA6B,IAAA,EAAkC;AAC5E,IAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,MAChC,MAAA,EAAQ,QAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,mBAAmB,CAAA,CAAA;AAAA,MAC3C;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"contacts.cjs","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n ContactAssignment,\n ContactAssignmentCreate,\n ContactAssignmentUpdate,\n} from \"../generated/customer-management\";\n\n/**\n * Manages contact assignments linking customers to legal entities.\n *\n * `listForCompany` requires `customermanagement.contactassignment_read`;\n * `assign`/`update`/`unassign` require `_manage`. The query param\n * `legalEntityId` scopes the list to one company.\n */\nexport class ContactsService {\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/customer-management/${this.ctx.tenant}/contact-assignments`;\n }\n\n /** Lists contact assignments for one legal entity. */\n async listForCompany(legalEntityId: string, auth: AuthContext): Promise<ContactAssignment[]> {\n return this.ctx.http.request<ContactAssignment[]>({\n method: \"GET\",\n path: this.base(),\n query: { legalEntityId },\n auth,\n });\n }\n\n /** Creates a contact assignment. */\n async assign(input: ContactAssignmentCreate, auth: AuthContext): Promise<{ id: string }> {\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: input,\n });\n }\n\n /**\n * Patches a contact assignment. PATCH endpoint, so the body is a partial of\n * the generated `ContactAssignmentUpdate` shape.\n */\n async update(\n contactAssignmentId: string,\n patch: Partial<ContactAssignmentUpdate>,\n auth: AuthContext,\n ): Promise<ContactAssignment> {\n return this.ctx.http.request<ContactAssignment>({\n method: \"PATCH\",\n path: `${this.base()}/${contactAssignmentId}`,\n auth,\n body: patch,\n });\n }\n\n /** Deletes a contact assignment. */\n async unassign(contactAssignmentId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${contactAssignmentId}`,\n auth,\n });\n }\n}\n"]}
|
package/dist/contacts.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { C as ClientContext, b as AuthContext } from './context-DJDTlhLW.cjs';
|
|
2
|
-
import { C as ContactAssignment, a as ContactAssignmentCreate,
|
|
3
|
-
export { b as ContactAssignmentType } from './types.gen-D1QuqPLs.cjs';
|
|
2
|
+
import { C as ContactAssignment, a as ContactAssignmentCreate, b as ContactAssignmentUpdate } from './types.gen-C_wOXYZB.cjs';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Manages contact assignments linking customers to legal entities.
|
|
@@ -19,8 +18,11 @@ declare class ContactsService {
|
|
|
19
18
|
assign(input: ContactAssignmentCreate, auth: AuthContext): Promise<{
|
|
20
19
|
id: string;
|
|
21
20
|
}>;
|
|
22
|
-
/**
|
|
23
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Patches a contact assignment. PATCH endpoint, so the body is a partial of
|
|
23
|
+
* the generated `ContactAssignmentUpdate` shape.
|
|
24
|
+
*/
|
|
25
|
+
update(contactAssignmentId: string, patch: Partial<ContactAssignmentUpdate>, auth: AuthContext): Promise<ContactAssignment>;
|
|
24
26
|
/** Deletes a contact assignment. */
|
|
25
27
|
unassign(contactAssignmentId: string, auth: AuthContext): Promise<void>;
|
|
26
28
|
}
|
package/dist/contacts.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { C as ClientContext, b as AuthContext } from './context-DJDTlhLW.js';
|
|
2
|
-
import { C as ContactAssignment, a as ContactAssignmentCreate,
|
|
3
|
-
export { b as ContactAssignmentType } from './types.gen-D1QuqPLs.js';
|
|
2
|
+
import { C as ContactAssignment, a as ContactAssignmentCreate, b as ContactAssignmentUpdate } from './types.gen-C_wOXYZB.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Manages contact assignments linking customers to legal entities.
|
|
@@ -19,8 +18,11 @@ declare class ContactsService {
|
|
|
19
18
|
assign(input: ContactAssignmentCreate, auth: AuthContext): Promise<{
|
|
20
19
|
id: string;
|
|
21
20
|
}>;
|
|
22
|
-
/**
|
|
23
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Patches a contact assignment. PATCH endpoint, so the body is a partial of
|
|
23
|
+
* the generated `ContactAssignmentUpdate` shape.
|
|
24
|
+
*/
|
|
25
|
+
update(contactAssignmentId: string, patch: Partial<ContactAssignmentUpdate>, auth: AuthContext): Promise<ContactAssignment>;
|
|
24
26
|
/** Deletes a contact assignment. */
|
|
25
27
|
unassign(contactAssignmentId: string, auth: AuthContext): Promise<void>;
|
|
26
28
|
}
|
package/dist/contacts.js
CHANGED
package/dist/customer-groups.cjs
CHANGED
|
@@ -18,6 +18,23 @@ var CustomerGroupsService = class {
|
|
|
18
18
|
auth
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
+
/** Adds a user (customer or employee) to a group. */
|
|
22
|
+
async addMember(groupId, member, auth) {
|
|
23
|
+
return this.ctx.http.request({
|
|
24
|
+
method: "POST",
|
|
25
|
+
path: `${this.base()}/${groupId}/users`,
|
|
26
|
+
auth,
|
|
27
|
+
body: member
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** Removes a user from a group. */
|
|
31
|
+
async removeMember(groupId, userId, auth) {
|
|
32
|
+
await this.ctx.http.request({
|
|
33
|
+
method: "DELETE",
|
|
34
|
+
path: `${this.base()}/${groupId}/users/${userId}`,
|
|
35
|
+
auth
|
|
36
|
+
});
|
|
37
|
+
}
|
|
21
38
|
};
|
|
22
39
|
|
|
23
40
|
exports.CustomerGroupsService = CustomerGroupsService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/services/customer-groups.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/services/customer-groups.ts"],"names":[],"mappings":";;;AAeO,IAAM,wBAAN,MAA4B;AAAA,EACjC,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAErB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,KAAA,EAAQ,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,OAAA,CAAA;AAAA,EAChC;AAAA;AAAA,EAGA,MAAM,cAAA,CAAe,aAAA,EAAuB,IAAA,EAAmD;AAC7F,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA+B;AAAA,MAClD,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,KAAK,IAAA,EAAK;AAAA,MAChB,KAAA,EAAO,EAAE,mBAAA,EAAqB,aAAA,EAAc;AAAA,MAC5C;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,SAAA,CACJ,OAAA,EACA,MAAA,EACA,IAAA,EACyB;AACzB,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAwB;AAAA,MAC3C,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,MAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,YAAA,CAAa,OAAA,EAAiB,MAAA,EAAgB,IAAA,EAAkC;AACpF,IAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,MAChC,MAAA,EAAQ,QAAA;AAAA,MACR,IAAA,EAAM,GAAG,IAAA,CAAK,IAAA,EAAM,CAAA,CAAA,EAAI,OAAO,UAAU,MAAM,CAAA,CAAA;AAAA,MAC/C;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"customer-groups.cjs","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n GroupsQueryDocument,\n AssignmentCreateRequest,\n} from \"../generated/iam\";\n\n/**\n * Access to IAM customer groups for a legal entity.\n *\n * `listForCompany` requires `iam.group_read`; the member mutations\n * (`addMember`/`removeMember`) require `iam.group_manage` — typically only\n * granted to Admin-group customers; a 403 surfaces as\n * `EmporixInsufficientScopeError`.\n */\nexport class CustomerGroupsService {\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/iam/${this.ctx.tenant}/groups`;\n }\n\n /** Lists customer groups belonging to one legal entity. */\n async listForCompany(legalEntityId: string, auth: AuthContext): Promise<GroupsQueryDocument[]> {\n return this.ctx.http.request<GroupsQueryDocument[]>({\n method: \"GET\",\n path: this.base(),\n query: { \"b2b.legalEntityId\": legalEntityId },\n auth,\n });\n }\n\n /** Adds a user (customer or employee) to a group. */\n async addMember(\n groupId: string,\n member: AssignmentCreateRequest,\n auth: AuthContext,\n ): Promise<{ id: string }> {\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: `${this.base()}/${groupId}/users`,\n auth,\n body: member,\n });\n }\n\n /** Removes a user from a group. */\n async removeMember(groupId: string, userId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${groupId}/users/${userId}`,\n auth,\n });\n }\n}\n"]}
|