@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.
Files changed (68) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/{chunk-5JHTZBOC.js → chunk-B4UOYJKW.js} +12 -2
  3. package/dist/chunk-B4UOYJKW.js.map +1 -0
  4. package/dist/{chunk-SCI7D74B.js → chunk-BK25FDTH.js} +17 -5
  5. package/dist/chunk-BK25FDTH.js.map +1 -0
  6. package/dist/{chunk-B56JZNI7.js → chunk-HAEVK6IS.js} +6 -3
  7. package/dist/chunk-HAEVK6IS.js.map +1 -0
  8. package/dist/{chunk-6UNFMCHZ.js → chunk-KVBCTXVH.js} +2 -2
  9. package/dist/chunk-KVBCTXVH.js.map +1 -0
  10. package/dist/{chunk-NM7VDXBR.js → chunk-LGLFJL3S.js} +6 -3
  11. package/dist/chunk-LGLFJL3S.js.map +1 -0
  12. package/dist/chunk-LGOC5XOI.js +40 -0
  13. package/dist/chunk-LGOC5XOI.js.map +1 -0
  14. package/dist/{chunk-RXVVFNYN.js → chunk-MM6JF3Z7.js} +6 -3
  15. package/dist/chunk-MM6JF3Z7.js.map +1 -0
  16. package/dist/companies.cjs +4 -1
  17. package/dist/companies.cjs.map +1 -1
  18. package/dist/companies.d.cts +7 -4
  19. package/dist/companies.d.ts +7 -4
  20. package/dist/companies.js +1 -1
  21. package/dist/contacts.cjs +4 -1
  22. package/dist/contacts.cjs.map +1 -1
  23. package/dist/contacts.d.cts +6 -4
  24. package/dist/contacts.d.ts +6 -4
  25. package/dist/contacts.js +1 -1
  26. package/dist/customer-groups.cjs +17 -0
  27. package/dist/customer-groups.cjs.map +1 -1
  28. package/dist/customer-groups.d.cts +94 -21
  29. package/dist/customer-groups.d.ts +94 -21
  30. package/dist/customer-groups.js +1 -1
  31. package/dist/index.cjs +63 -7
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +13 -5
  34. package/dist/index.d.ts +13 -5
  35. package/dist/index.js +23 -16
  36. package/dist/index.js.map +1 -1
  37. package/dist/locations.cjs +4 -1
  38. package/dist/locations.cjs.map +1 -1
  39. package/dist/locations.d.cts +7 -4
  40. package/dist/locations.d.ts +7 -4
  41. package/dist/locations.js +1 -1
  42. package/dist/orders.cjs.map +1 -1
  43. package/dist/orders.d.cts +1726 -80
  44. package/dist/orders.d.ts +1726 -80
  45. package/dist/orders.js +1 -1
  46. package/dist/price.cjs +15 -3
  47. package/dist/price.cjs.map +1 -1
  48. package/dist/price.d.cts +23 -4
  49. package/dist/price.d.ts +23 -4
  50. package/dist/price.js +1 -1
  51. package/dist/product.cjs +10 -0
  52. package/dist/product.cjs.map +1 -1
  53. package/dist/product.d.cts +10 -0
  54. package/dist/product.d.ts +10 -0
  55. package/dist/product.js +1 -1
  56. package/dist/types.gen-C_wOXYZB.d.cts +455 -0
  57. package/dist/types.gen-C_wOXYZB.d.ts +455 -0
  58. package/package.json +1 -1
  59. package/dist/chunk-5JHTZBOC.js.map +0 -1
  60. package/dist/chunk-6UNFMCHZ.js.map +0 -1
  61. package/dist/chunk-B56JZNI7.js.map +0 -1
  62. package/dist/chunk-NM7VDXBR.js.map +0 -1
  63. package/dist/chunk-RXVVFNYN.js.map +0 -1
  64. package/dist/chunk-SCI7D74B.js.map +0 -1
  65. package/dist/chunk-SKX7KCMH.js +0 -23
  66. package/dist/chunk-SKX7KCMH.js.map +0 -1
  67. package/dist/types.gen-D1QuqPLs.d.cts +0 -166
  68. package/dist/types.gen-D1QuqPLs.d.ts +0 -166
@@ -1,36 +1,109 @@
1
1
  import { C as ClientContext, b as AuthContext } from './context-DJDTlhLW.cjs';
2
2
 
3
+ type AssignmentCreateRequest = {
4
+ /**
5
+ * User unique identifier generated when the user is created. Might be customer ID or Management Dashboard user ID.
6
+ */
7
+ userId: string;
8
+ /**
9
+ * Assignment type, possible values: CUSTOMER, EMPLOYEE
10
+ */
11
+ userType?: 'CUSTOMER' | 'EMPLOYEE';
12
+ };
3
13
  /**
4
- * Hand-written mirror of the minimal IAM Service group shape needed for
5
- * B2B foundation reads. The Emporix IAM API exposes groups keyed by
6
- * `b2b.legalEntityId`. Membership-mutation endpoints exist on the server
7
- * but their exact path/body shape is not in the current SDK input set —
8
- * `customer-groups.ts` ships read-only here; mutations follow in a small
9
- * follow-up plan once the API reference is confirmed.
14
+ * Group metadata.
10
15
  */
11
- interface IamGroupB2B {
12
- legalEntityId?: string;
13
- }
14
- interface IamGroup {
15
- id: string;
16
- name?: Record<string, string>;
17
- role?: string;
18
- b2b?: IamGroupB2B;
19
- }
16
+ type GroupsMetadataQueryDocument = {
17
+ /**
18
+ * Group document version.
19
+ */
20
+ version: number;
21
+ /**
22
+ * Timestamp indicating when the group was created.
23
+ */
24
+ createdAt: string;
25
+ /**
26
+ * Timestamp indicating when the group was last modified.
27
+ */
28
+ modifiedAt?: string;
29
+ };
30
+ /**
31
+ * Definition of groups
32
+ */
33
+ type GroupsQueryDocument = {
34
+ /**
35
+ * Group unique identifier generated when the group is created.
36
+ */
37
+ id?: string;
38
+ /**
39
+ * Localized group name in the form of a map of translations.
40
+ */
41
+ name?: {
42
+ [key: string]: string;
43
+ };
44
+ /**
45
+ * Localized group description in the form of a map of translations.
46
+ */
47
+ description?: {
48
+ [key: string]: string;
49
+ };
50
+ /**
51
+ * An identifier of a vendor to whom the group belongs. Can only be set during creation and is immutable thereafter. A group with vendorId can only be assigned to users of type `EMPLOYEE`
52
+ */
53
+ readonly vendorId?: string;
54
+ /**
55
+ * Access control unique identifiers associated with this group.
56
+ */
57
+ accessControls?: Array<string>;
58
+ /**
59
+ * Template unique identifiers associated with this group.
60
+ */
61
+ templates?: Array<string>;
62
+ code?: string;
63
+ /**
64
+ * The group type determines if the group can consist of users of the `CUSTOMER` or the `EMPLOYEE` type.
65
+ */
66
+ userType?: string;
67
+ /**
68
+ * additional properties for B2B
69
+ */
70
+ b2b?: {
71
+ /**
72
+ * identifier of the assigned legal entity
73
+ */
74
+ legalEntityId?: string;
75
+ };
76
+ restrictions?: Restrictions;
77
+ /**
78
+ * Custom group attributes that need to be included directly in the `mixins` object.
79
+ */
80
+ mixins?: {
81
+ [key: string]: string;
82
+ };
83
+ metadata?: GroupsMetadataQueryDocument;
84
+ };
85
+ type Restrictions = Array<string>;
20
86
 
21
87
  /**
22
- * Read-only access to IAM customer groups for a legal entity.
88
+ * Access to IAM customer groups for a legal entity.
23
89
  *
24
- * Member-management endpoints (`addMember`/`removeMember`) are deferred —
25
- * the exact IAM path/body shape isn't in the SDK input set yet. They will
26
- * land in a small follow-up plan once the API reference is confirmed.
90
+ * `listForCompany` requires `iam.group_read`; the member mutations
91
+ * (`addMember`/`removeMember`) require `iam.group_manage` — typically only
92
+ * granted to Admin-group customers; a 403 surfaces as
93
+ * `EmporixInsufficientScopeError`.
27
94
  */
28
95
  declare class CustomerGroupsService {
29
96
  private readonly ctx;
30
97
  constructor(ctx: ClientContext);
31
98
  private base;
32
99
  /** Lists customer groups belonging to one legal entity. */
33
- listForCompany(legalEntityId: string, auth: AuthContext): Promise<IamGroup[]>;
100
+ listForCompany(legalEntityId: string, auth: AuthContext): Promise<GroupsQueryDocument[]>;
101
+ /** Adds a user (customer or employee) to a group. */
102
+ addMember(groupId: string, member: AssignmentCreateRequest, auth: AuthContext): Promise<{
103
+ id: string;
104
+ }>;
105
+ /** Removes a user from a group. */
106
+ removeMember(groupId: string, userId: string, auth: AuthContext): Promise<void>;
34
107
  }
35
108
 
36
- export { CustomerGroupsService, type IamGroup, type IamGroupB2B };
109
+ export { CustomerGroupsService, type GroupsQueryDocument as IamGroup, type AssignmentCreateRequest as IamGroupMemberAssignment };
@@ -1,36 +1,109 @@
1
1
  import { C as ClientContext, b as AuthContext } from './context-DJDTlhLW.js';
2
2
 
3
+ type AssignmentCreateRequest = {
4
+ /**
5
+ * User unique identifier generated when the user is created. Might be customer ID or Management Dashboard user ID.
6
+ */
7
+ userId: string;
8
+ /**
9
+ * Assignment type, possible values: CUSTOMER, EMPLOYEE
10
+ */
11
+ userType?: 'CUSTOMER' | 'EMPLOYEE';
12
+ };
3
13
  /**
4
- * Hand-written mirror of the minimal IAM Service group shape needed for
5
- * B2B foundation reads. The Emporix IAM API exposes groups keyed by
6
- * `b2b.legalEntityId`. Membership-mutation endpoints exist on the server
7
- * but their exact path/body shape is not in the current SDK input set —
8
- * `customer-groups.ts` ships read-only here; mutations follow in a small
9
- * follow-up plan once the API reference is confirmed.
14
+ * Group metadata.
10
15
  */
11
- interface IamGroupB2B {
12
- legalEntityId?: string;
13
- }
14
- interface IamGroup {
15
- id: string;
16
- name?: Record<string, string>;
17
- role?: string;
18
- b2b?: IamGroupB2B;
19
- }
16
+ type GroupsMetadataQueryDocument = {
17
+ /**
18
+ * Group document version.
19
+ */
20
+ version: number;
21
+ /**
22
+ * Timestamp indicating when the group was created.
23
+ */
24
+ createdAt: string;
25
+ /**
26
+ * Timestamp indicating when the group was last modified.
27
+ */
28
+ modifiedAt?: string;
29
+ };
30
+ /**
31
+ * Definition of groups
32
+ */
33
+ type GroupsQueryDocument = {
34
+ /**
35
+ * Group unique identifier generated when the group is created.
36
+ */
37
+ id?: string;
38
+ /**
39
+ * Localized group name in the form of a map of translations.
40
+ */
41
+ name?: {
42
+ [key: string]: string;
43
+ };
44
+ /**
45
+ * Localized group description in the form of a map of translations.
46
+ */
47
+ description?: {
48
+ [key: string]: string;
49
+ };
50
+ /**
51
+ * An identifier of a vendor to whom the group belongs. Can only be set during creation and is immutable thereafter. A group with vendorId can only be assigned to users of type `EMPLOYEE`
52
+ */
53
+ readonly vendorId?: string;
54
+ /**
55
+ * Access control unique identifiers associated with this group.
56
+ */
57
+ accessControls?: Array<string>;
58
+ /**
59
+ * Template unique identifiers associated with this group.
60
+ */
61
+ templates?: Array<string>;
62
+ code?: string;
63
+ /**
64
+ * The group type determines if the group can consist of users of the `CUSTOMER` or the `EMPLOYEE` type.
65
+ */
66
+ userType?: string;
67
+ /**
68
+ * additional properties for B2B
69
+ */
70
+ b2b?: {
71
+ /**
72
+ * identifier of the assigned legal entity
73
+ */
74
+ legalEntityId?: string;
75
+ };
76
+ restrictions?: Restrictions;
77
+ /**
78
+ * Custom group attributes that need to be included directly in the `mixins` object.
79
+ */
80
+ mixins?: {
81
+ [key: string]: string;
82
+ };
83
+ metadata?: GroupsMetadataQueryDocument;
84
+ };
85
+ type Restrictions = Array<string>;
20
86
 
21
87
  /**
22
- * Read-only access to IAM customer groups for a legal entity.
88
+ * Access to IAM customer groups for a legal entity.
23
89
  *
24
- * Member-management endpoints (`addMember`/`removeMember`) are deferred —
25
- * the exact IAM path/body shape isn't in the SDK input set yet. They will
26
- * land in a small follow-up plan once the API reference is confirmed.
90
+ * `listForCompany` requires `iam.group_read`; the member mutations
91
+ * (`addMember`/`removeMember`) require `iam.group_manage` — typically only
92
+ * granted to Admin-group customers; a 403 surfaces as
93
+ * `EmporixInsufficientScopeError`.
27
94
  */
28
95
  declare class CustomerGroupsService {
29
96
  private readonly ctx;
30
97
  constructor(ctx: ClientContext);
31
98
  private base;
32
99
  /** Lists customer groups belonging to one legal entity. */
33
- listForCompany(legalEntityId: string, auth: AuthContext): Promise<IamGroup[]>;
100
+ listForCompany(legalEntityId: string, auth: AuthContext): Promise<GroupsQueryDocument[]>;
101
+ /** Adds a user (customer or employee) to a group. */
102
+ addMember(groupId: string, member: AssignmentCreateRequest, auth: AuthContext): Promise<{
103
+ id: string;
104
+ }>;
105
+ /** Removes a user from a group. */
106
+ removeMember(groupId: string, userId: string, auth: AuthContext): Promise<void>;
34
107
  }
35
108
 
36
- export { CustomerGroupsService, type IamGroup, type IamGroupB2B };
109
+ export { CustomerGroupsService, type GroupsQueryDocument as IamGroup, type AssignmentCreateRequest as IamGroupMemberAssignment };
@@ -1,3 +1,3 @@
1
- export { CustomerGroupsService } from './chunk-SKX7KCMH.js';
1
+ export { CustomerGroupsService } from './chunk-LGOC5XOI.js';
2
2
  //# sourceMappingURL=customer-groups.js.map
3
3
  //# sourceMappingURL=customer-groups.js.map
package/dist/index.cjs CHANGED
@@ -1001,6 +1001,16 @@ var ProductService = class {
1001
1001
  });
1002
1002
  return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
1003
1003
  }
1004
+ /**
1005
+ * Free-text product search by name. The product `q` is a `field:value` DSL,
1006
+ * so a bare term (e.g. "in time") 400s with "No value for key …". This builds
1007
+ * a `name:(~<term>)` regex filter (regex metacharacters escaped) and delegates
1008
+ * to {@link search}.
1009
+ */
1010
+ async searchByName(query, params = {}, auth2 = ANON) {
1011
+ const escaped = query.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1012
+ return this.search(`name:(~${escaped})`, params, auth2);
1013
+ }
1004
1014
  /**
1005
1015
  * Bulk fetch by id. POSTs `/products/search` with `q="id:(id1,id2,…)"`,
1006
1016
  * chunking when the list is larger than `options.chunkSize` (default
@@ -1464,6 +1474,16 @@ var PaymentGatewayService = class {
1464
1474
  };
1465
1475
 
1466
1476
  // src/services/price.ts
1477
+ function normalizeMatch(raw) {
1478
+ const itemId = raw.itemId ?? raw.itemRef;
1479
+ const base = raw;
1480
+ if (!itemId) return base;
1481
+ const itemRef = {
1482
+ ...itemId.itemType !== void 0 ? { itemType: itemId.itemType } : {},
1483
+ ...itemId.id !== void 0 ? { id: itemId.id } : {}
1484
+ };
1485
+ return { ...base, itemId, itemRef };
1486
+ }
1467
1487
  var ANON3 = { kind: "anonymous" };
1468
1488
  var SERVICE = { kind: "service" };
1469
1489
  function requireContextAuth(auth2) {
@@ -1484,24 +1504,26 @@ var PriceService = class {
1484
1504
  * anonymous; pass a customer/raw context for personalized pricing.
1485
1505
  */
1486
1506
  async matchByContext(input, auth2) {
1487
- return this.ctx.http.request({
1507
+ const rows = await this.ctx.http.request({
1488
1508
  method: "POST",
1489
1509
  path: `/price/${this.ctx.tenant}/match-prices-by-context`,
1490
1510
  auth: requireContextAuth(auth2),
1491
1511
  body: input
1492
1512
  });
1513
+ return rows.map(normalizeMatch);
1493
1514
  }
1494
1515
  /**
1495
1516
  * Resolves prices from an explicit context. Default auth: service
1496
1517
  * (requires `price.price_read` / `price.price_manage`).
1497
1518
  */
1498
1519
  async match(input, auth2 = SERVICE) {
1499
- return this.ctx.http.request({
1520
+ const rows = await this.ctx.http.request({
1500
1521
  method: "POST",
1501
1522
  path: `/price/${this.ctx.tenant}/match-prices`,
1502
1523
  auth: auth2,
1503
1524
  body: input
1504
1525
  });
1526
+ return rows.map(normalizeMatch);
1505
1527
  }
1506
1528
  /**
1507
1529
  * Chunked variant of {@link matchByContext} for large `items` arrays. The
@@ -1514,7 +1536,7 @@ var PriceService = class {
1514
1536
  * `throwOnAnyChunkError: true` to reject on the first failure instead.
1515
1537
  *
1516
1538
  * **Result order is not guaranteed** — match entries back to your items by
1517
- * `priceId` / `itemRef.id`.
1539
+ * `priceId` / `itemId.id`.
1518
1540
  */
1519
1541
  async matchByContextChunked(input, opts = {}, auth2) {
1520
1542
  const chunkSize = opts.chunkSize ?? 50;
@@ -2064,7 +2086,10 @@ var CompaniesService = class {
2064
2086
  body: input
2065
2087
  });
2066
2088
  }
2067
- /** Patches a legal entity. */
2089
+ /**
2090
+ * Patches a legal entity. The endpoint is a PATCH, so the body is a partial
2091
+ * of the generated `LegalEntityUpdate` (full-replace) shape.
2092
+ */
2068
2093
  async update(legalEntityId, patch, auth2) {
2069
2094
  return this.ctx.http.request({
2070
2095
  method: "PATCH",
@@ -2110,7 +2135,10 @@ var ContactsService = class {
2110
2135
  body: input
2111
2136
  });
2112
2137
  }
2113
- /** Patches a contact assignment. */
2138
+ /**
2139
+ * Patches a contact assignment. PATCH endpoint, so the body is a partial of
2140
+ * the generated `ContactAssignmentUpdate` shape.
2141
+ */
2114
2142
  async update(contactAssignmentId, patch, auth2) {
2115
2143
  return this.ctx.http.request({
2116
2144
  method: "PATCH",
@@ -2164,7 +2192,10 @@ var LocationsService = class {
2164
2192
  body: input
2165
2193
  });
2166
2194
  }
2167
- /** Patches a location. */
2195
+ /**
2196
+ * Patches a location. PATCH endpoint, so the body is a partial of the
2197
+ * generated `LocationUpdate` shape.
2198
+ */
2168
2199
  async update(locationId, patch, auth2) {
2169
2200
  return this.ctx.http.request({
2170
2201
  method: "PATCH",
@@ -2201,6 +2232,23 @@ var CustomerGroupsService = class {
2201
2232
  auth: auth2
2202
2233
  });
2203
2234
  }
2235
+ /** Adds a user (customer or employee) to a group. */
2236
+ async addMember(groupId, member, auth2) {
2237
+ return this.ctx.http.request({
2238
+ method: "POST",
2239
+ path: `${this.base()}/${groupId}/users`,
2240
+ auth: auth2,
2241
+ body: member
2242
+ });
2243
+ }
2244
+ /** Removes a user from a group. */
2245
+ async removeMember(groupId, userId, auth2) {
2246
+ await this.ctx.http.request({
2247
+ method: "DELETE",
2248
+ path: `${this.base()}/${groupId}/users/${userId}`,
2249
+ auth: auth2
2250
+ });
2251
+ }
2204
2252
  };
2205
2253
 
2206
2254
  // src/services/orders.ts
@@ -5020,7 +5068,7 @@ var ApprovalService = class {
5020
5068
  };
5021
5069
 
5022
5070
  // package.json
5023
- var version = "2.8.0";
5071
+ var version = "2.9.0";
5024
5072
 
5025
5073
  // src/version.ts
5026
5074
  var SDK_VERSION = version;
@@ -5191,6 +5239,13 @@ var EmporixClient = class {
5191
5239
  }
5192
5240
  };
5193
5241
 
5242
+ // src/core/yrn.ts
5243
+ function productIdFromYrn(yrn) {
5244
+ if (!yrn) return "";
5245
+ const semi = yrn.lastIndexOf(";");
5246
+ return semi >= 0 ? yrn.slice(semi + 1) : "";
5247
+ }
5248
+
5194
5249
  exports.AiService = AiService;
5195
5250
  exports.ApprovalService = ApprovalService;
5196
5251
  exports.AvailabilityService = AvailabilityService;
@@ -5254,6 +5309,7 @@ exports.createConsoleLogger = createConsoleLogger;
5254
5309
  exports.createNoopLogger = createNoopLogger;
5255
5310
  exports.errorFromResponse = errorFromResponse;
5256
5311
  exports.iterateAll = iterateAll;
5312
+ exports.productIdFromYrn = productIdFromYrn;
5257
5313
  exports.redact = redact;
5258
5314
  exports.resolveToken = resolveToken;
5259
5315
  exports.validateConfig = validateConfig;