@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.
Files changed (132) hide show
  1. package/CHANGELOG.md +407 -0
  2. package/LICENSE +21 -0
  3. package/README.md +115 -0
  4. package/dist/cart.cjs +214 -0
  5. package/dist/cart.cjs.map +1 -0
  6. package/dist/cart.d.cts +1807 -0
  7. package/dist/cart.d.ts +1807 -0
  8. package/dist/cart.js +4 -0
  9. package/dist/cart.js.map +1 -0
  10. package/dist/category.cjs +97 -0
  11. package/dist/category.cjs.map +1 -0
  12. package/dist/category.d.cts +313 -0
  13. package/dist/category.d.ts +313 -0
  14. package/dist/category.js +4 -0
  15. package/dist/category.js.map +1 -0
  16. package/dist/checkout.cjs +98 -0
  17. package/dist/checkout.cjs.map +1 -0
  18. package/dist/checkout.d.cts +252 -0
  19. package/dist/checkout.d.ts +252 -0
  20. package/dist/checkout.js +4 -0
  21. package/dist/checkout.js.map +1 -0
  22. package/dist/chunk-4BJUCCKJ.js +86 -0
  23. package/dist/chunk-4BJUCCKJ.js.map +1 -0
  24. package/dist/chunk-6UNFMCHZ.js +95 -0
  25. package/dist/chunk-6UNFMCHZ.js.map +1 -0
  26. package/dist/chunk-B56JZNI7.js +49 -0
  27. package/dist/chunk-B56JZNI7.js.map +1 -0
  28. package/dist/chunk-BFQ732VZ.js +11 -0
  29. package/dist/chunk-BFQ732VZ.js.map +1 -0
  30. package/dist/chunk-F3WAQH2E.js +120 -0
  31. package/dist/chunk-F3WAQH2E.js.map +1 -0
  32. package/dist/chunk-GWJ2U2CP.js +14 -0
  33. package/dist/chunk-GWJ2U2CP.js.map +1 -0
  34. package/dist/chunk-HEO34WLO.js +47 -0
  35. package/dist/chunk-HEO34WLO.js.map +1 -0
  36. package/dist/chunk-HKPZI7Y5.js +30 -0
  37. package/dist/chunk-HKPZI7Y5.js.map +1 -0
  38. package/dist/chunk-IEZHGU7F.js +171 -0
  39. package/dist/chunk-IEZHGU7F.js.map +1 -0
  40. package/dist/chunk-KTODT6DV.js +86 -0
  41. package/dist/chunk-KTODT6DV.js.map +1 -0
  42. package/dist/chunk-NM7VDXBR.js +57 -0
  43. package/dist/chunk-NM7VDXBR.js.map +1 -0
  44. package/dist/chunk-OMYVOOSX.js +57 -0
  45. package/dist/chunk-OMYVOOSX.js.map +1 -0
  46. package/dist/chunk-QDABAMVN.js +89 -0
  47. package/dist/chunk-QDABAMVN.js.map +1 -0
  48. package/dist/chunk-RXVVFNYN.js +56 -0
  49. package/dist/chunk-RXVVFNYN.js.map +1 -0
  50. package/dist/chunk-SKX7KCMH.js +23 -0
  51. package/dist/chunk-SKX7KCMH.js.map +1 -0
  52. package/dist/chunk-TLH6SLAF.js +215 -0
  53. package/dist/chunk-TLH6SLAF.js.map +1 -0
  54. package/dist/chunk-Z6PNI5VT.js +142 -0
  55. package/dist/chunk-Z6PNI5VT.js.map +1 -0
  56. package/dist/companies.cjs +58 -0
  57. package/dist/companies.cjs.map +1 -0
  58. package/dist/companies.d.cts +31 -0
  59. package/dist/companies.d.ts +31 -0
  60. package/dist/companies.js +3 -0
  61. package/dist/companies.js.map +1 -0
  62. package/dist/contacts.cjs +51 -0
  63. package/dist/contacts.cjs.map +1 -0
  64. package/dist/contacts.d.cts +28 -0
  65. package/dist/contacts.d.ts +28 -0
  66. package/dist/contacts.js +3 -0
  67. package/dist/contacts.js.map +1 -0
  68. package/dist/context-vKgzZ-5f.d.cts +329 -0
  69. package/dist/context-vKgzZ-5f.d.ts +329 -0
  70. package/dist/customer-groups.cjs +25 -0
  71. package/dist/customer-groups.cjs.map +1 -0
  72. package/dist/customer-groups.d.cts +36 -0
  73. package/dist/customer-groups.d.ts +36 -0
  74. package/dist/customer-groups.js +3 -0
  75. package/dist/customer-groups.js.map +1 -0
  76. package/dist/customer.cjs +262 -0
  77. package/dist/customer.cjs.map +1 -0
  78. package/dist/customer.d.cts +386 -0
  79. package/dist/customer.d.ts +386 -0
  80. package/dist/customer.js +5 -0
  81. package/dist/customer.js.map +1 -0
  82. package/dist/index.cjs +2075 -0
  83. package/dist/index.cjs.map +1 -0
  84. package/dist/index.d.cts +218 -0
  85. package/dist/index.d.ts +218 -0
  86. package/dist/index.js +791 -0
  87. package/dist/index.js.map +1 -0
  88. package/dist/locations.cjs +59 -0
  89. package/dist/locations.cjs.map +1 -0
  90. package/dist/locations.d.cts +30 -0
  91. package/dist/locations.d.ts +30 -0
  92. package/dist/locations.js +3 -0
  93. package/dist/locations.js.map +1 -0
  94. package/dist/media.cjs +123 -0
  95. package/dist/media.cjs.map +1 -0
  96. package/dist/media.d.cts +219 -0
  97. package/dist/media.d.ts +219 -0
  98. package/dist/media.js +3 -0
  99. package/dist/media.js.map +1 -0
  100. package/dist/orders.cjs +98 -0
  101. package/dist/orders.cjs.map +1 -0
  102. package/dist/orders.d.cts +167 -0
  103. package/dist/orders.d.ts +167 -0
  104. package/dist/orders.js +3 -0
  105. package/dist/orders.js.map +1 -0
  106. package/dist/payment.cjs +77 -0
  107. package/dist/payment.cjs.map +1 -0
  108. package/dist/payment.d.cts +110 -0
  109. package/dist/payment.d.ts +110 -0
  110. package/dist/payment.js +5 -0
  111. package/dist/payment.js.map +1 -0
  112. package/dist/price.cjs +88 -0
  113. package/dist/price.cjs.map +1 -0
  114. package/dist/price.d.cts +445 -0
  115. package/dist/price.d.ts +445 -0
  116. package/dist/price.js +4 -0
  117. package/dist/price.js.map +1 -0
  118. package/dist/product.cjs +100 -0
  119. package/dist/product.cjs.map +1 -0
  120. package/dist/product.d.cts +400 -0
  121. package/dist/product.d.ts +400 -0
  122. package/dist/product.js +4 -0
  123. package/dist/product.js.map +1 -0
  124. package/dist/segment.cjs +189 -0
  125. package/dist/segment.cjs.map +1 -0
  126. package/dist/segment.d.cts +241 -0
  127. package/dist/segment.d.ts +241 -0
  128. package/dist/segment.js +5 -0
  129. package/dist/segment.js.map +1 -0
  130. package/dist/types.gen-D1QuqPLs.d.cts +166 -0
  131. package/dist/types.gen-D1QuqPLs.d.ts +166 -0
  132. package/package.json +141 -0
package/dist/cart.js ADDED
@@ -0,0 +1,4 @@
1
+ export { CartService } from './chunk-IEZHGU7F.js';
2
+ import './chunk-KTODT6DV.js';
3
+ //# sourceMappingURL=cart.js.map
4
+ //# sourceMappingURL=cart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"cart.js"}
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ // src/core/context.ts
4
+ async function* iterateAll(fetchPage, start = 1) {
5
+ let p = start;
6
+ for (; ; ) {
7
+ const page = await fetchPage(p);
8
+ for (const it of page.items) yield it;
9
+ if (!page.hasNextPage) return;
10
+ p += 1;
11
+ }
12
+ }
13
+
14
+ // src/services/category.ts
15
+ var ANON = { kind: "anonymous" };
16
+ var CategoryService = class {
17
+ constructor(ctx) {
18
+ this.ctx = ctx;
19
+ }
20
+ ctx;
21
+ /** Fetches one category by id. */
22
+ async get(categoryId, auth = ANON) {
23
+ return this.ctx.http.request({
24
+ method: "GET",
25
+ path: `/category/${this.ctx.tenant}/categories/${categoryId}`,
26
+ auth
27
+ });
28
+ }
29
+ /** One page of categories. */
30
+ async list(params = {}, auth = ANON) {
31
+ const pageNumber = params.pageNumber ?? 1;
32
+ const pageSize = params.pageSize ?? 50;
33
+ const items = await this.ctx.http.request({
34
+ method: "GET",
35
+ path: `/category/${this.ctx.tenant}/categories`,
36
+ query: { pageNumber, pageSize },
37
+ auth
38
+ });
39
+ return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
40
+ }
41
+ /** Async-iterates every category across pages. */
42
+ listAll(params = {}, auth = ANON) {
43
+ const pageSize = params.pageSize ?? 50;
44
+ return iterateAll((pageNumber) => this.list({ pageNumber, pageSize }, auth));
45
+ }
46
+ /** Fetches the category tree, optionally rooted at `rootId`. */
47
+ async tree(rootId, auth = ANON) {
48
+ return this.ctx.http.request({
49
+ method: "GET",
50
+ path: `/category/${this.ctx.tenant}/categories/tree`,
51
+ query: rootId ? { rootId } : {},
52
+ auth
53
+ });
54
+ }
55
+ /** One page of products in a category. */
56
+ async productsIn(categoryId, params = {}, auth = ANON) {
57
+ const pageNumber = params.pageNumber ?? 1;
58
+ const pageSize = params.pageSize ?? 50;
59
+ const items = await this.ctx.http.request({
60
+ method: "GET",
61
+ path: `/category/${this.ctx.tenant}/categories/${categoryId}/products`,
62
+ query: { pageNumber, pageSize },
63
+ auth
64
+ });
65
+ return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
66
+ }
67
+ /**
68
+ * Bulk fetch by id. POSTs `/categories/search` with `q="id:(id1,id2,…)"`,
69
+ * chunking when the list is larger than `options.chunkSize` (default
70
+ * 100). An empty list short-circuits with no HTTP call. **Order is not
71
+ * guaranteed** across chunks — re-index by `id` if order matters.
72
+ */
73
+ async searchByIds(ids, options = {}, auth = ANON) {
74
+ if (ids.length === 0) return [];
75
+ const chunkSize = options.chunkSize ?? 100;
76
+ const chunks = [];
77
+ for (let i = 0; i < ids.length; i += chunkSize) {
78
+ chunks.push(ids.slice(i, i + chunkSize));
79
+ }
80
+ const pages = await Promise.all(
81
+ chunks.map(
82
+ (chunk) => this.ctx.http.request({
83
+ method: "POST",
84
+ path: `/category/${this.ctx.tenant}/categories/search`,
85
+ query: { pageSize: chunk.length },
86
+ auth,
87
+ body: { q: `id:(${chunk.join(",")})` }
88
+ })
89
+ )
90
+ );
91
+ return pages.flat();
92
+ }
93
+ };
94
+
95
+ exports.CategoryService = CategoryService;
96
+ //# sourceMappingURL=category.cjs.map
97
+ //# sourceMappingURL=category.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/context.ts","../src/services/category.ts"],"names":[],"mappings":";;;AAkCA,gBAAuB,UAAA,CACrB,SAAA,EACA,KAAA,GAAQ,CAAA,EACU;AAClB,EAAA,IAAI,CAAA,GAAI,KAAA;AACR,EAAA,WAAS;AACP,IAAA,MAAM,IAAA,GAAO,MAAM,SAAA,CAAU,CAAC,CAA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AA,EAC/E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,WAAA,CACJ,GAAA,EACA,UAAkC,EAAC,EACnC,OAAoB,IAAA,EACC;AACrB,IAAA,IAAI,GAAA,CAAI,MAAA,KAAW,CAAA,EAAG,OAAO,EAAC;AAC9B,IAAA,MAAM,SAAA,GAAY,QAAQ,SAAA,IAAa,GAAA;AACvC,IAAA,MAAM,SAAqB,EAAC;AAC5B,IAAA,KAAA,IAAS,IAAI,CAAA,EAAG,CAAA,GAAI,GAAA,CAAI,MAAA,EAAQ,KAAK,SAAA,EAAW;AAC9C,MAAA,MAAA,CAAO,KAAK,GAAA,CAAI,KAAA,CAAM,CAAA,EAAG,CAAA,GAAI,SAAS,CAAC,CAAA;AAAA,IACzC;AACA,IAAA,MAAM,KAAA,GAAQ,MAAM,OAAA,CAAQ,GAAA;AAAA,MAC1B,MAAA,CAAO,GAAA;AAAA,QAAI,CAAC,KAAA,KACV,IAAA,CAAK,GAAA,CAAI,KAAK,OAAA,CAAoB;AAAA,UAChC,MAAA,EAAQ,MAAA;AAAA,UACR,IAAA,EAAM,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,kBAAA,CAAA;AAAA,UAClC,KAAA,EAAO,EAAE,QAAA,EAAU,KAAA,CAAM,MAAA,EAAO;AAAA,UAChC,IAAA;AAAA,UACA,IAAA,EAAM,EAAE,CAAA,EAAG,CAAA,IAAA,EAAO,MAAM,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAA;AAAI,SACtC;AAAA;AACH,KACF;AACA,IAAA,OAAO,MAAM,IAAA,EAAK;AAAA,EACpB;AACF","file":"category.cjs","sourcesContent":["import type { HttpClient } from \"./http\";\nimport type { TokenProvider, AuthContext } from \"./auth\";\nimport type { Logger } from \"./logger\";\n\n/** Shared dependencies every service facade receives. */\nexport interface ClientContext {\n tenant: string;\n http: HttpClient;\n tokenProvider: TokenProvider;\n logger: Logger;\n}\n\n/**\n * A cursor-paged collection — `pageNumber`/`pageSize` indexing with a\n * `hasNextPage` signal driven by the source page being full. Used by all\n * paginated services and hooks across the SDK.\n */\nexport interface PaginatedItems<T> {\n items: T[];\n pageNumber: number;\n pageSize: number;\n hasNextPage: boolean;\n}\n\n/** Default `AuthContext` applied by a service when the caller passes none. */\nexport type DefaultAuth = AuthContext | undefined;\n\n/**\n * Async-iterates every item across pages of a `PaginatedItems<T>` source.\n * Stops when the source reports `hasNextPage: false`.\n *\n * @param fetchPage - given a 1-based page number, returns the page.\n * @param start - first page to fetch (default `1`).\n */\nexport async function* iterateAll<T>(\n fetchPage: (pageNumber: number) => Promise<PaginatedItems<T>>,\n start = 1,\n): AsyncIterable<T> {\n let p = start;\n for (;;) {\n const page = await fetchPage(p);\n for (const it of page.items) yield it;\n if (!page.hasNextPage) return;\n p += 1;\n }\n}\n\n","import type { ClientContext, PaginatedItems } from \"../core/context\";\nimport { iterateAll } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type { Product } from \"./product\";\nimport type { Category as GeneratedCategory, CategoryTree } from \"../generated/category\";\n\nconst ANON: AuthContext = { kind: \"anonymous\" };\n\n/** A category as returned by the Category service (all generated fields). */\nexport type Category = GeneratedCategory;\n\n/** The category tree as returned by the Category service. */\nexport type CategoryNode = CategoryTree;\n\n/** Category reads. Default auth: anonymous. */\nexport class CategoryService {\n constructor(private readonly ctx: ClientContext) {}\n\n /** Fetches one category by id. */\n async get(categoryId: string, auth: AuthContext = ANON): Promise<Category> {\n return this.ctx.http.request<Category>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}`,\n auth,\n });\n }\n\n /** One page of categories. */\n async list(\n params: { pageNumber?: number; pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Category>> {\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n const items = await this.ctx.http.request<Category[]>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories`,\n query: { pageNumber, pageSize },\n auth,\n });\n return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };\n }\n\n /** Async-iterates every category across pages. */\n listAll(params: { pageSize?: number } = {}, auth: AuthContext = ANON): AsyncIterable<Category> {\n const pageSize = params.pageSize ?? 50;\n return iterateAll<Category>((pageNumber) => this.list({ pageNumber, pageSize }, auth));\n }\n\n /** Fetches the category tree, optionally rooted at `rootId`. */\n async tree(rootId?: string, auth: AuthContext = ANON): Promise<CategoryNode> {\n return this.ctx.http.request<CategoryNode>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/tree`,\n query: rootId ? { rootId } : {},\n auth,\n });\n }\n\n /** One page of products in a category. */\n async productsIn(\n categoryId: 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: `/category/${this.ctx.tenant}/categories/${categoryId}/products`,\n query: { pageNumber, pageSize },\n auth,\n });\n return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };\n }\n\n /**\n * Bulk fetch by id. POSTs `/categories/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<Category[]> {\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<Category[]>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/categories/search`,\n query: { pageSize: chunk.length },\n auth,\n body: { q: `id:(${chunk.join(\",\")})` },\n }),\n ),\n );\n return pages.flat();\n }\n}\n"]}
@@ -0,0 +1,313 @@
1
+ import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-vKgzZ-5f.cjs';
2
+ import { Product } from './product.cjs';
3
+
4
+ /**
5
+ * Classification mixin defined for a given category.
6
+ */
7
+ type OwnClassificationMixin = {
8
+ /**
9
+ * Name of the mixin.
10
+ */
11
+ name: string;
12
+ /**
13
+ * URL of the mixin schema.
14
+ */
15
+ schemaUrl: string;
16
+ /**
17
+ * Indicates whether the mixin is required.
18
+ */
19
+ required?: boolean;
20
+ };
21
+ /**
22
+ * Classification mixin with source category information.
23
+ */
24
+ type ClassificationMixin = {
25
+ /**
26
+ * Name of the mixin
27
+ */
28
+ name: string;
29
+ /**
30
+ * The mixins path that should be used when defining attributes on a product. It's built based on the following pattern - `class_<sourceCategory.code>_<name>`.
31
+ */
32
+ mixinPath?: string;
33
+ /**
34
+ * URL of the mixin schema.
35
+ */
36
+ schemaUrl: string;
37
+ /**
38
+ * Indicates whether the mixin is required.
39
+ */
40
+ required?: boolean;
41
+ /**
42
+ * Unique identifier of the category from which the mixin comes from. Can be this category ID or one of the parent categories IDs.
43
+ */
44
+ sourceCategoryId?: string;
45
+ };
46
+ /**
47
+ * Definition of category
48
+ */
49
+ type Category$1 = {
50
+ /**
51
+ * Category unique identifier generated when the category is created.
52
+ */
53
+ id: string;
54
+ /**
55
+ * Unique identifier of the parent category. No parentId in the body indicates that this is a root category.
56
+ */
57
+ parentId?: string | null;
58
+ /**
59
+ * Localized category name as a map of translations.
60
+ */
61
+ localizedName: {
62
+ [key: string]: string;
63
+ };
64
+ /**
65
+ * Localized category description as a map of translations.
66
+ */
67
+ localizedDescription?: {
68
+ [key: string]: string;
69
+ };
70
+ /**
71
+ * Provides localized category name or code without diacritics for the URL.
72
+ */
73
+ localizedSlug?: {
74
+ [key: string]: string;
75
+ };
76
+ /**
77
+ * Category name in tenant default language.
78
+ * @deprecated
79
+ */
80
+ name?: string;
81
+ /**
82
+ * Description in tenant default language.
83
+ * @deprecated
84
+ */
85
+ description?: string;
86
+ /**
87
+ * Unique category identifier defined by the tenant.
88
+ */
89
+ code?: string;
90
+ /**
91
+ * List of external category numbers (ECNs) unique for each category.
92
+ */
93
+ ecn?: Array<string>;
94
+ validity?: Validity;
95
+ /**
96
+ * Category position relative to sibling categories.
97
+ */
98
+ position: number;
99
+ /**
100
+ * Flag indicating whether the category has been published.
101
+ */
102
+ published: boolean;
103
+ /**
104
+ * IDs of supercategories.
105
+ */
106
+ supercategoriesIds?: Array<string>;
107
+ /**
108
+ * List of classification mixins defined for this category.
109
+ */
110
+ ownClassificationMixins?: Array<OwnClassificationMixin>;
111
+ /**
112
+ * Combined list of classification mixins from parent categories and category's ownClassification mixins.
113
+ */
114
+ classificationMixins?: Array<ClassificationMixin>;
115
+ /**
116
+ * Custom category attributes included directly in the mixins object.
117
+ */
118
+ mixins?: {
119
+ [key: string]: unknown;
120
+ };
121
+ metadata: MetadataResponse;
122
+ media: Array<Media>;
123
+ };
124
+ /**
125
+ * Definition of category tree
126
+ */
127
+ type CategoryTree = {
128
+ /**
129
+ * Category unique identifier generated when the category is created.
130
+ */
131
+ id: string;
132
+ /**
133
+ * Category name in tenant default language.
134
+ * @deprecated
135
+ */
136
+ name: string;
137
+ /**
138
+ * Description in tenant default language.
139
+ * @deprecated
140
+ */
141
+ description?: string;
142
+ /**
143
+ * Unique category identifier defined by the tenant.
144
+ * @deprecated
145
+ */
146
+ code?: string;
147
+ /**
148
+ * Localized category name as a map of translations.
149
+ */
150
+ localizedName: {
151
+ [key: string]: string;
152
+ };
153
+ /**
154
+ * Localized category description as a map of translations.
155
+ */
156
+ localizedDescription?: {
157
+ [key: string]: string;
158
+ };
159
+ /**
160
+ * Provides localized category name or code without diacritics for the URL.
161
+ */
162
+ localizedSlug?: {
163
+ [key: string]: string;
164
+ };
165
+ validity?: Validity;
166
+ /**
167
+ * Category position in relation to sibling categories.
168
+ */
169
+ position: number;
170
+ /**
171
+ * Flag indicating whether the category has been published.
172
+ */
173
+ published: boolean;
174
+ /**
175
+ * List of external category numbers (ECNs) unique for each category.
176
+ */
177
+ ecn?: Array<string>;
178
+ /**
179
+ * Subcategories of this category.
180
+ */
181
+ subcategories?: Array<CategoryTree>;
182
+ };
183
+ type Media = {
184
+ /**
185
+ * Unique identifier of media.
186
+ */
187
+ id?: string;
188
+ /**
189
+ * Url of the file.
190
+ */
191
+ url?: string;
192
+ /**
193
+ * Content type of the file.
194
+ */
195
+ contentType?: string;
196
+ metadata?: MediaMetadataQueryDocument & unknown;
197
+ customAttributes?: MediaCustomAttributesQueryDocument & unknown;
198
+ };
199
+ /**
200
+ * Custom attributes of the file.
201
+ */
202
+ type MediaCustomAttributesQueryDocument = {
203
+ /**
204
+ * Unique identifier of media's custom attributes.
205
+ */
206
+ id?: string;
207
+ /**
208
+ * Height of the media image.
209
+ */
210
+ height?: number;
211
+ /**
212
+ * Width of the media image.
213
+ */
214
+ width?: number;
215
+ /**
216
+ * Size in kilobytes of the file.
217
+ */
218
+ sizeKB?: number;
219
+ /**
220
+ * Mime type of the file.
221
+ */
222
+ type?: string;
223
+ /**
224
+ * Name of the file.
225
+ */
226
+ name?: string;
227
+ };
228
+ /**
229
+ * Metadata of the file.
230
+ */
231
+ type MediaMetadataQueryDocument = {
232
+ /**
233
+ * Timestamp indicating when the media was created compliant with the ISO 8601 standard.
234
+ */
235
+ createdAt?: string;
236
+ /**
237
+ * Timestamp indicating when the media was modified compliant with the ISO 8601 standard.
238
+ */
239
+ modifiedAt?: string;
240
+ };
241
+ type MetadataCreate = {
242
+ /**
243
+ * A key-value map, where key is a mixin name and value is a link to the mixin schema.
244
+ */
245
+ mixins?: {
246
+ [key: string]: string;
247
+ };
248
+ };
249
+ type MetadataUpdate = {
250
+ /**
251
+ * Category version.
252
+ */
253
+ version?: number;
254
+ } & MetadataCreate;
255
+ type MetadataResponse = {
256
+ /**
257
+ * Timestamp indicating when the category was created compliant with the ISO 8601 standard.
258
+ */
259
+ createdAt?: string;
260
+ /**
261
+ * Timestamp indicating when the category was last modified compliant with the ISO 8601 standard.
262
+ */
263
+ modifiedAt?: string;
264
+ } & MetadataUpdate;
265
+ type Validity = {
266
+ /**
267
+ * Date and time from which the category is valid compliant with the ISO 8601 standard.
268
+ */
269
+ from?: string;
270
+ /**
271
+ * Date and time to which the category is valid compliant with the ISO 8601 standard.
272
+ */
273
+ to?: string;
274
+ };
275
+
276
+ /** A category as returned by the Category service (all generated fields). */
277
+ type Category = Category$1;
278
+ /** The category tree as returned by the Category service. */
279
+ type CategoryNode = CategoryTree;
280
+ /** Category reads. Default auth: anonymous. */
281
+ declare class CategoryService {
282
+ private readonly ctx;
283
+ constructor(ctx: ClientContext);
284
+ /** Fetches one category by id. */
285
+ get(categoryId: string, auth?: AuthContext): Promise<Category>;
286
+ /** One page of categories. */
287
+ list(params?: {
288
+ pageNumber?: number;
289
+ pageSize?: number;
290
+ }, auth?: AuthContext): Promise<PaginatedItems<Category>>;
291
+ /** Async-iterates every category across pages. */
292
+ listAll(params?: {
293
+ pageSize?: number;
294
+ }, auth?: AuthContext): AsyncIterable<Category>;
295
+ /** Fetches the category tree, optionally rooted at `rootId`. */
296
+ tree(rootId?: string, auth?: AuthContext): Promise<CategoryNode>;
297
+ /** One page of products in a category. */
298
+ productsIn(categoryId: string, params?: {
299
+ pageNumber?: number;
300
+ pageSize?: number;
301
+ }, auth?: AuthContext): Promise<PaginatedItems<Product>>;
302
+ /**
303
+ * Bulk fetch by id. POSTs `/categories/search` with `q="id:(id1,id2,…)"`,
304
+ * chunking when the list is larger than `options.chunkSize` (default
305
+ * 100). An empty list short-circuits with no HTTP call. **Order is not
306
+ * guaranteed** across chunks — re-index by `id` if order matters.
307
+ */
308
+ searchByIds(ids: string[], options?: {
309
+ chunkSize?: number;
310
+ }, auth?: AuthContext): Promise<Category[]>;
311
+ }
312
+
313
+ export { type Category, type CategoryNode, CategoryService };