@augno/sdk 0.18.2 → 0.19.1

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 (193) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/package.json +1 -1
  3. package/resources/catalog/catalog.d.mts +6 -6
  4. package/resources/catalog/catalog.d.mts.map +1 -1
  5. package/resources/catalog/catalog.d.ts +6 -6
  6. package/resources/catalog/catalog.d.ts.map +1 -1
  7. package/resources/catalog/catalog.js.map +1 -1
  8. package/resources/catalog/catalog.mjs.map +1 -1
  9. package/resources/catalog/index.d.mts +3 -3
  10. package/resources/catalog/index.d.mts.map +1 -1
  11. package/resources/catalog/index.d.ts +3 -3
  12. package/resources/catalog/index.d.ts.map +1 -1
  13. package/resources/catalog/index.js.map +1 -1
  14. package/resources/catalog/index.mjs.map +1 -1
  15. package/resources/catalog/items/actions.d.mts +249 -0
  16. package/resources/catalog/items/actions.d.mts.map +1 -0
  17. package/resources/catalog/items/actions.d.ts +249 -0
  18. package/resources/catalog/items/actions.d.ts.map +1 -0
  19. package/resources/catalog/items/actions.js +46 -0
  20. package/resources/catalog/items/actions.js.map +1 -0
  21. package/resources/catalog/items/actions.mjs +42 -0
  22. package/resources/catalog/items/actions.mjs.map +1 -0
  23. package/resources/catalog/items/index.d.mts +3 -1
  24. package/resources/catalog/items/index.d.mts.map +1 -1
  25. package/resources/catalog/items/index.d.ts +3 -1
  26. package/resources/catalog/items/index.d.ts.map +1 -1
  27. package/resources/catalog/items/index.js +5 -1
  28. package/resources/catalog/items/index.js.map +1 -1
  29. package/resources/catalog/items/index.mjs +2 -0
  30. package/resources/catalog/items/index.mjs.map +1 -1
  31. package/resources/catalog/items/inventory.d.mts +247 -0
  32. package/resources/catalog/items/inventory.d.mts.map +1 -0
  33. package/resources/catalog/items/inventory.d.ts +247 -0
  34. package/resources/catalog/items/inventory.d.ts.map +1 -0
  35. package/resources/catalog/items/inventory.js +75 -0
  36. package/resources/catalog/items/inventory.js.map +1 -0
  37. package/resources/catalog/items/inventory.mjs +71 -0
  38. package/resources/catalog/items/inventory.mjs.map +1 -0
  39. package/resources/catalog/items/items.d.mts +9 -104
  40. package/resources/catalog/items/items.d.mts.map +1 -1
  41. package/resources/catalog/items/items.d.ts +9 -104
  42. package/resources/catalog/items/items.d.ts.map +1 -1
  43. package/resources/catalog/items/items.js +8 -21
  44. package/resources/catalog/items/items.js.map +1 -1
  45. package/resources/catalog/items/items.mjs +8 -21
  46. package/resources/catalog/items/items.mjs.map +1 -1
  47. package/resources/catalog/materials/index.d.mts +1 -1
  48. package/resources/catalog/materials/index.d.mts.map +1 -1
  49. package/resources/catalog/materials/index.d.ts +1 -1
  50. package/resources/catalog/materials/index.d.ts.map +1 -1
  51. package/resources/catalog/materials/index.js.map +1 -1
  52. package/resources/catalog/materials/index.mjs.map +1 -1
  53. package/resources/catalog/materials/materials.d.mts +36 -3
  54. package/resources/catalog/materials/materials.d.mts.map +1 -1
  55. package/resources/catalog/materials/materials.d.ts +36 -3
  56. package/resources/catalog/materials/materials.d.ts.map +1 -1
  57. package/resources/catalog/materials/materials.js.map +1 -1
  58. package/resources/catalog/materials/materials.mjs.map +1 -1
  59. package/resources/catalog/product-lines/index.d.mts +1 -1
  60. package/resources/catalog/product-lines/index.d.mts.map +1 -1
  61. package/resources/catalog/product-lines/index.d.ts +1 -1
  62. package/resources/catalog/product-lines/index.d.ts.map +1 -1
  63. package/resources/catalog/product-lines/index.js.map +1 -1
  64. package/resources/catalog/product-lines/index.mjs.map +1 -1
  65. package/resources/catalog/product-lines/product-lines.d.mts +8 -23
  66. package/resources/catalog/product-lines/product-lines.d.mts.map +1 -1
  67. package/resources/catalog/product-lines/product-lines.d.ts +8 -23
  68. package/resources/catalog/product-lines/product-lines.d.ts.map +1 -1
  69. package/resources/catalog/product-lines/product-lines.js.map +1 -1
  70. package/resources/catalog/product-lines/product-lines.mjs.map +1 -1
  71. package/resources/core/audit-events.d.mts +4 -4
  72. package/resources/core/audit-events.d.mts.map +1 -1
  73. package/resources/core/audit-events.d.ts +4 -4
  74. package/resources/core/audit-events.d.ts.map +1 -1
  75. package/resources/core/core.d.mts +2 -2
  76. package/resources/core/core.d.mts.map +1 -1
  77. package/resources/core/core.d.ts +2 -2
  78. package/resources/core/core.d.ts.map +1 -1
  79. package/resources/core/core.js.map +1 -1
  80. package/resources/core/core.mjs.map +1 -1
  81. package/resources/core/jobs.d.mts +2 -2
  82. package/resources/core/jobs.d.mts.map +1 -1
  83. package/resources/core/jobs.d.ts +2 -2
  84. package/resources/core/jobs.d.ts.map +1 -1
  85. package/resources/messaging/blocks.d.mts +4 -3
  86. package/resources/messaging/blocks.d.mts.map +1 -1
  87. package/resources/messaging/blocks.d.ts +4 -3
  88. package/resources/messaging/blocks.d.ts.map +1 -1
  89. package/resources/messaging/blocks.js.map +1 -1
  90. package/resources/messaging/blocks.mjs.map +1 -1
  91. package/resources/messaging/conversations/conversations.d.mts +3 -3
  92. package/resources/messaging/conversations/conversations.d.mts.map +1 -1
  93. package/resources/messaging/conversations/conversations.d.ts +3 -3
  94. package/resources/messaging/conversations/conversations.d.ts.map +1 -1
  95. package/resources/messaging/conversations/conversations.js.map +1 -1
  96. package/resources/messaging/conversations/conversations.mjs.map +1 -1
  97. package/resources/messaging/conversations/links.d.mts +2 -2
  98. package/resources/messaging/conversations/links.d.mts.map +1 -1
  99. package/resources/messaging/conversations/links.d.ts +2 -2
  100. package/resources/messaging/conversations/links.d.ts.map +1 -1
  101. package/resources/messaging/conversations/messages.d.mts +2 -2
  102. package/resources/messaging/conversations/messages.d.mts.map +1 -1
  103. package/resources/messaging/conversations/messages.d.ts +2 -2
  104. package/resources/messaging/conversations/messages.d.ts.map +1 -1
  105. package/resources/messaging/notifications/notifications.d.mts +2 -2
  106. package/resources/messaging/notifications/notifications.d.mts.map +1 -1
  107. package/resources/messaging/notifications/notifications.d.ts +2 -2
  108. package/resources/messaging/notifications/notifications.d.ts.map +1 -1
  109. package/resources/messaging/notifications/notifications.js.map +1 -1
  110. package/resources/messaging/notifications/notifications.mjs.map +1 -1
  111. package/resources/operations/machine-downtime-events.d.mts +5 -5
  112. package/resources/operations/machine-downtime-events.d.mts.map +1 -1
  113. package/resources/operations/machine-downtime-events.d.ts +5 -5
  114. package/resources/operations/machine-downtime-events.d.ts.map +1 -1
  115. package/resources/operations/production-schedules/actions.d.mts +1 -95
  116. package/resources/operations/production-schedules/actions.d.mts.map +1 -1
  117. package/resources/operations/production-schedules/actions.d.ts +1 -95
  118. package/resources/operations/production-schedules/actions.d.ts.map +1 -1
  119. package/resources/operations/production-schedules/actions.js +0 -34
  120. package/resources/operations/production-schedules/actions.js.map +1 -1
  121. package/resources/operations/production-schedules/actions.mjs +0 -34
  122. package/resources/operations/production-schedules/actions.mjs.map +1 -1
  123. package/resources/operations/production-schedules/index.d.mts +1 -1
  124. package/resources/operations/production-schedules/index.d.mts.map +1 -1
  125. package/resources/operations/production-schedules/index.d.ts +1 -1
  126. package/resources/operations/production-schedules/index.d.ts.map +1 -1
  127. package/resources/operations/production-schedules/index.js.map +1 -1
  128. package/resources/operations/production-schedules/index.mjs.map +1 -1
  129. package/resources/operations/production-schedules/production-schedules.d.mts +2 -2
  130. package/resources/operations/production-schedules/production-schedules.d.mts.map +1 -1
  131. package/resources/operations/production-schedules/production-schedules.d.ts +2 -2
  132. package/resources/operations/production-schedules/production-schedules.d.ts.map +1 -1
  133. package/resources/operations/production-schedules/production-schedules.js.map +1 -1
  134. package/resources/operations/production-schedules/production-schedules.mjs.map +1 -1
  135. package/resources/operations/shipping-terms.d.mts +9 -9
  136. package/resources/operations/shipping-terms.d.mts.map +1 -1
  137. package/resources/operations/shipping-terms.d.ts +9 -9
  138. package/resources/operations/shipping-terms.d.ts.map +1 -1
  139. package/resources/sales/account-prices/account-prices.d.mts +3 -3
  140. package/resources/sales/account-prices/account-prices.d.mts.map +1 -1
  141. package/resources/sales/account-prices/account-prices.d.ts +3 -3
  142. package/resources/sales/account-prices/account-prices.d.ts.map +1 -1
  143. package/resources/sales/account-users/sales-targets.d.mts +2 -2
  144. package/resources/sales/account-users/sales-targets.d.mts.map +1 -1
  145. package/resources/sales/account-users/sales-targets.d.ts +2 -2
  146. package/resources/sales/account-users/sales-targets.d.ts.map +1 -1
  147. package/resources/sales/customers/customers.d.mts +5 -5
  148. package/resources/sales/customers/customers.d.mts.map +1 -1
  149. package/resources/sales/customers/customers.d.ts +5 -5
  150. package/resources/sales/customers/customers.d.ts.map +1 -1
  151. package/resources/sales/sales-orders/lines/lines.d.mts +5 -5
  152. package/resources/sales/sales-orders/lines/lines.d.mts.map +1 -1
  153. package/resources/sales/sales-orders/lines/lines.d.ts +5 -5
  154. package/resources/sales/sales-orders/lines/lines.d.ts.map +1 -1
  155. package/resources/sales/sales-orders/sales-orders.d.mts +8 -4
  156. package/resources/sales/sales-orders/sales-orders.d.mts.map +1 -1
  157. package/resources/sales/sales-orders/sales-orders.d.ts +8 -4
  158. package/resources/sales/sales-orders/sales-orders.d.ts.map +1 -1
  159. package/resources/sales/sales-orders/sales-orders.js.map +1 -1
  160. package/resources/sales/sales-orders/sales-orders.mjs.map +1 -1
  161. package/src/resources/catalog/catalog.ts +2 -8
  162. package/src/resources/catalog/index.ts +1 -4
  163. package/src/resources/catalog/items/actions.ts +296 -0
  164. package/src/resources/catalog/items/index.ts +23 -3
  165. package/src/resources/catalog/items/inventory.ts +294 -0
  166. package/src/resources/catalog/items/items.ts +54 -124
  167. package/src/resources/catalog/materials/index.ts +1 -0
  168. package/src/resources/catalog/materials/materials.ts +41 -2
  169. package/src/resources/catalog/product-lines/index.ts +0 -1
  170. package/src/resources/catalog/product-lines/product-lines.ts +7 -25
  171. package/src/resources/core/audit-events.ts +26 -14
  172. package/src/resources/core/core.ts +13 -7
  173. package/src/resources/core/jobs.ts +7 -4
  174. package/src/resources/messaging/blocks.ts +4 -3
  175. package/src/resources/messaging/conversations/conversations.ts +21 -12
  176. package/src/resources/messaging/conversations/links.ts +14 -8
  177. package/src/resources/messaging/conversations/messages.ts +14 -8
  178. package/src/resources/messaging/notifications/notifications.ts +14 -8
  179. package/src/resources/operations/machine-downtime-events.ts +5 -5
  180. package/src/resources/operations/production-schedules/actions.ts +0 -118
  181. package/src/resources/operations/production-schedules/index.ts +0 -3
  182. package/src/resources/operations/production-schedules/production-schedules.ts +0 -6
  183. package/src/resources/operations/shipping-terms.ts +9 -9
  184. package/src/resources/sales/account-prices/account-prices.ts +3 -3
  185. package/src/resources/sales/account-users/sales-targets.ts +2 -2
  186. package/src/resources/sales/customers/customers.ts +5 -5
  187. package/src/resources/sales/sales-orders/lines/lines.ts +5 -5
  188. package/src/resources/sales/sales-orders/sales-orders.ts +9 -4
  189. package/src/version.ts +1 -1
  190. package/version.d.mts +1 -1
  191. package/version.d.ts +1 -1
  192. package/version.js +1 -1
  193. package/version.mjs +1 -1
@@ -0,0 +1,296 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import * as APIKeysAPI from '../../auth/api-keys/api-keys';
5
+ import { APIPromise } from '../../../core/api-promise';
6
+ import { RequestOptions } from '../../../internal/request-options';
7
+
8
+ /**
9
+ * List and manage inventory items.
10
+ */
11
+ export class Actions extends APIResource {
12
+ /**
13
+ * Reconciles inventory for multiple items by SKU in one call, the bulk equivalent
14
+ * of counting stock and correcting the books.
15
+ *
16
+ * `reconcile_type` controls whether each quantity is added to the item's current
17
+ * quantity (`addition`) or replaces it (`force`). The figure a `force` measures
18
+ * against is what is on hand net of demand nothing has covered, the same basis the
19
+ * single-item endpoint uses. The response reports each item as reconciled, skipped
20
+ * (e.g. unknown SKU), or errored (e.g. unknown unit), so a problem with one item
21
+ * does not fail the rest of the batch.
22
+ *
23
+ * Each correction is written to the item's inventory audit trail as a user
24
+ * correction, attributed to the caller.
25
+ *
26
+ * This endpoint requires the permission: `items:create`.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const bulkReconcileItemsResponse =
31
+ * await client.catalog.items.actions.bulkReconcile({
32
+ * data: [
33
+ * {
34
+ * sku: 'ALM-2024-1001',
35
+ * unit: 'kg',
36
+ * quantity: '10.5',
37
+ * },
38
+ * ],
39
+ * reconcile_type: 'addition',
40
+ * });
41
+ * ```
42
+ */
43
+ bulkReconcile(
44
+ body: ActionBulkReconcileParams,
45
+ options?: RequestOptions,
46
+ ): APIPromise<BulkReconcileItemsResponse> {
47
+ return this._client.post('/v1/catalog/items/actions/bulk-reconcile', { body, ...options });
48
+ }
49
+ }
50
+
51
+ /**
52
+ * One item to reconcile in a bulk reconcile request.
53
+ */
54
+ export interface BulkReconcileItemInput {
55
+ /**
56
+ * Quantity to apply, interpreted according to the request's `reconcile_type`.
57
+ *
58
+ * A decimal string rather than a number: a quantity that has been through a binary
59
+ * float is not the quantity you sent.
60
+ */
61
+ quantity: string;
62
+
63
+ /**
64
+ * SKU of the item to reconcile.
65
+ *
66
+ * Items whose SKU does not match an existing item are reported in the response's
67
+ * `skipped_items` rather than failing the request.
68
+ */
69
+ sku: string;
70
+
71
+ /**
72
+ * Abbreviation of a unit available to your account (e.g. `kg`).
73
+ *
74
+ * The unit is checked for existence only: the quantity is always recorded in the
75
+ * item's own base unit, so send figures already expressed in that unit. Rows
76
+ * naming an abbreviation that matches no built-in or account-defined unit are
77
+ * reported in the response's `errors`.
78
+ */
79
+ unit: string;
80
+ }
81
+
82
+ /**
83
+ * Request to reconcile inventory for many items at once.
84
+ */
85
+ export interface BulkReconcileItemsRequest {
86
+ /**
87
+ * Items to reconcile.
88
+ */
89
+ data: Array<BulkReconcileItemInput>;
90
+
91
+ /**
92
+ * How each item's quantity is applied to its current quantity.
93
+ *
94
+ * - `addition`: adds the quantity to the item's current quantity.
95
+ * - `force`: sets the item's current quantity to exactly the given quantity.
96
+ */
97
+ reconcile_type: string;
98
+ }
99
+
100
+ /**
101
+ * The outcome of a bulk inventory reconciliation, reported as three separate
102
+ * lists.
103
+ */
104
+ export interface BulkReconcileItemsResponse {
105
+ /**
106
+ * A single page of resources, together with the metadata needed to page through
107
+ * the rest of the result set.
108
+ */
109
+ errors: ListReconcileErrorResult | null;
110
+
111
+ /**
112
+ * Resource type identifier.
113
+ */
114
+ object: 'bulk_reconcile_items_response';
115
+
116
+ /**
117
+ * A single page of resources, together with the metadata needed to page through
118
+ * the rest of the result set.
119
+ */
120
+ reconciled_items: ListReconciledItemResult | null;
121
+
122
+ /**
123
+ * A single page of resources, together with the metadata needed to page through
124
+ * the rest of the result set.
125
+ */
126
+ skipped_items: ListSkippedItemResult | null;
127
+ }
128
+
129
+ /**
130
+ * A single page of resources, together with the metadata needed to page through
131
+ * the rest of the result set.
132
+ */
133
+ export interface ListReconcileErrorResult {
134
+ /**
135
+ * Resources in this page.
136
+ */
137
+ data: Array<ReconcileErrorResult>;
138
+
139
+ /**
140
+ * Resource type identifier.
141
+ */
142
+ object: 'list';
143
+
144
+ /**
145
+ * PageInfo describes where the current page sits within a paginated result set and
146
+ * how to move to the adjacent pages.
147
+ *
148
+ * Page a list by following the URLs below rather than assembling cursors yourself.
149
+ * For a top-level list endpoint the URL repeats the original request's query
150
+ * string with only the cursor swapped, so following it preserves the same filters,
151
+ * search term, and page size.
152
+ */
153
+ page_info: APIKeysAPI.PageInfo;
154
+ }
155
+
156
+ /**
157
+ * A single page of resources, together with the metadata needed to page through
158
+ * the rest of the result set.
159
+ */
160
+ export interface ListReconciledItemResult {
161
+ /**
162
+ * Resources in this page.
163
+ */
164
+ data: Array<ReconciledItemResult>;
165
+
166
+ /**
167
+ * Resource type identifier.
168
+ */
169
+ object: 'list';
170
+
171
+ /**
172
+ * PageInfo describes where the current page sits within a paginated result set and
173
+ * how to move to the adjacent pages.
174
+ *
175
+ * Page a list by following the URLs below rather than assembling cursors yourself.
176
+ * For a top-level list endpoint the URL repeats the original request's query
177
+ * string with only the cursor swapped, so following it preserves the same filters,
178
+ * search term, and page size.
179
+ */
180
+ page_info: APIKeysAPI.PageInfo;
181
+ }
182
+
183
+ /**
184
+ * A single page of resources, together with the metadata needed to page through
185
+ * the rest of the result set.
186
+ */
187
+ export interface ListSkippedItemResult {
188
+ /**
189
+ * Resources in this page.
190
+ */
191
+ data: Array<SkippedItemResult>;
192
+
193
+ /**
194
+ * Resource type identifier.
195
+ */
196
+ object: 'list';
197
+
198
+ /**
199
+ * PageInfo describes where the current page sits within a paginated result set and
200
+ * how to move to the adjacent pages.
201
+ *
202
+ * Page a list by following the URLs below rather than assembling cursors yourself.
203
+ * For a top-level list endpoint the URL repeats the original request's query
204
+ * string with only the cursor swapped, so following it preserves the same filters,
205
+ * search term, and page size.
206
+ */
207
+ page_info: APIKeysAPI.PageInfo;
208
+ }
209
+
210
+ /**
211
+ * A submitted row that could not be reconciled.
212
+ */
213
+ export interface ReconcileErrorResult {
214
+ /**
215
+ * Error message.
216
+ */
217
+ error: string;
218
+
219
+ /**
220
+ * Item SKU.
221
+ */
222
+ sku: string;
223
+ }
224
+
225
+ /**
226
+ * An item whose on-hand quantity was successfully reconciled.
227
+ *
228
+ * Both quantities are expressed in the item's own base unit, not in the unit
229
+ * submitted with the request.
230
+ */
231
+ export interface ReconciledItemResult {
232
+ /**
233
+ * Item ID.
234
+ */
235
+ item_id: string;
236
+
237
+ /**
238
+ * Quantity after the reconciliation, as a decimal string.
239
+ */
240
+ new_quantity: string;
241
+
242
+ /**
243
+ * Quantity before the reconciliation, as a decimal string.
244
+ */
245
+ previous_quantity: string;
246
+
247
+ /**
248
+ * Item SKU.
249
+ */
250
+ sku: string;
251
+ }
252
+
253
+ /**
254
+ * A submitted row that was skipped rather than reconciled.
255
+ */
256
+ export interface SkippedItemResult {
257
+ /**
258
+ * Human-readable reason the item was skipped.
259
+ */
260
+ reason: string;
261
+
262
+ /**
263
+ * Item SKU.
264
+ */
265
+ sku: string;
266
+ }
267
+
268
+ export interface ActionBulkReconcileParams {
269
+ /**
270
+ * Items to reconcile.
271
+ */
272
+ data: Array<BulkReconcileItemInput>;
273
+
274
+ /**
275
+ * How each item's quantity is applied to its current quantity.
276
+ *
277
+ * - `addition`: adds the quantity to the item's current quantity.
278
+ * - `force`: sets the item's current quantity to exactly the given quantity.
279
+ */
280
+ reconcile_type: string;
281
+ }
282
+
283
+ export declare namespace Actions {
284
+ export {
285
+ type BulkReconcileItemInput as BulkReconcileItemInput,
286
+ type BulkReconcileItemsRequest as BulkReconcileItemsRequest,
287
+ type BulkReconcileItemsResponse as BulkReconcileItemsResponse,
288
+ type ListReconcileErrorResult as ListReconcileErrorResult,
289
+ type ListReconciledItemResult as ListReconciledItemResult,
290
+ type ListSkippedItemResult as ListSkippedItemResult,
291
+ type ReconcileErrorResult as ReconcileErrorResult,
292
+ type ReconciledItemResult as ReconciledItemResult,
293
+ type SkippedItemResult as SkippedItemResult,
294
+ type ActionBulkReconcileParams as ActionBulkReconcileParams,
295
+ };
296
+ }
@@ -1,18 +1,38 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
+ export {
4
+ Actions,
5
+ type BulkReconcileItemInput,
6
+ type BulkReconcileItemsRequest,
7
+ type BulkReconcileItemsResponse,
8
+ type ListReconcileErrorResult,
9
+ type ListReconciledItemResult,
10
+ type ListSkippedItemResult,
11
+ type ReconcileErrorResult,
12
+ type ReconciledItemResult,
13
+ type SkippedItemResult,
14
+ type ActionBulkReconcileParams,
15
+ } from './actions';
3
16
  export { Attributes, type AttributeUpdateParams, type AttributeDeleteParams } from './attributes';
17
+ export {
18
+ Inventory,
19
+ type ComputedQuantity,
20
+ type ItemInventory,
21
+ type QuantityInput,
22
+ type UpdateItemInventoryRequest,
23
+ type InventoryUpdateResponse,
24
+ type InventoryListParams,
25
+ type InventoryUpdateParams,
26
+ } from './inventory';
4
27
  export {
5
28
  Items,
6
29
  type Item,
7
30
  type ItemCategory,
8
- type ItemInventory,
9
31
  type ItemLotDefault,
10
32
  type ListItem,
11
- type Quantity,
12
33
  type Rate,
13
34
  type ItemListParams,
14
35
  type ItemRetrieveParams,
15
- type ItemRetrieveInventoryParams,
16
36
  type ItemRetrieveLotDefaultParams,
17
37
  type ItemChangeCategoryParams,
18
38
  } from './items';
@@ -0,0 +1,294 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import * as UnitsAPI from '../units/units';
5
+ import { APIPromise } from '../../../core/api-promise';
6
+ import { RequestOptions } from '../../../internal/request-options';
7
+ import { path } from '../../../internal/utils/path';
8
+
9
+ /**
10
+ * List and manage inventory items.
11
+ */
12
+ export class Inventory extends APIResource {
13
+ /**
14
+ * Returns the stock position for an item: what is on hand, what is reserved
15
+ * against existing orders, what is free to promise, and what is short.
16
+ *
17
+ * Stock your account either owns or holds counts toward the on-hand figure, so
18
+ * customer-supplied material sitting in your facility is included. All four
19
+ * quantities are reported in the base unit of the item's category.
20
+ *
21
+ * This endpoint requires the permission: `items:read`.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const itemInventory =
26
+ * await client.catalog.items.inventory.list(
27
+ * 'it_pej07ckhvu62',
28
+ * );
29
+ * ```
30
+ */
31
+ list(
32
+ id: string,
33
+ query: InventoryListParams | null | undefined = {},
34
+ options?: RequestOptions,
35
+ ): APIPromise<ItemInventory> {
36
+ return this._client.get(path`/v1/catalog/items/${id}/inventory`, { query, ...options });
37
+ }
38
+
39
+ /**
40
+ * Adjusts or reconciles the quantity of an item you hold.
41
+ *
42
+ * With `operation` set to `adjust` (the behavior when it is omitted), `quantity`
43
+ * is added to the current quantity; with `reconcile`, the current quantity is set
44
+ * to exactly `quantity`. Either way it is the resulting difference that gets
45
+ * written, so a difference of zero moves no stock.
46
+ *
47
+ * The figure a `reconcile` measures against is what is on hand net of demand
48
+ * nothing has covered — the same figure `available_to_promise` is derived from,
49
+ * not the raw on-hand total. Reconciling to the quantity already reported
50
+ * therefore writes nothing.
51
+ *
52
+ * Stock that arrives is allocated against unfilled demand for the item, so an
53
+ * adjustment can settle a shortfall instead of raising the quantity free to
54
+ * promise. That allocation happens just after the request rather than inside it,
55
+ * because it walks every open issue for the item. The change is recorded in the
56
+ * item's inventory audit trail as a user correction attributed to the caller.
57
+ *
58
+ * This endpoint requires the permission: `items:update`.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const inventory =
63
+ * await client.catalog.items.inventory.update(
64
+ * 'it_pej07ckhvu62',
65
+ * {
66
+ * quantity: {
67
+ * value: '10.5',
68
+ * unit_id: 'un_82bd37dae5po',
69
+ * },
70
+ * customer_id: 'ac_opnlh43ymyee',
71
+ * location_id: 'lc_yonnys0hx3ju',
72
+ * operation: 'adjust',
73
+ * },
74
+ * );
75
+ * ```
76
+ */
77
+ update(
78
+ id: string,
79
+ body: InventoryUpdateParams,
80
+ options?: RequestOptions,
81
+ ): APIPromise<InventoryUpdateResponse> {
82
+ return this._client.patch(path`/v1/catalog/items/${id}/inventory`, { body, ...options });
83
+ }
84
+ }
85
+
86
+ /**
87
+ * An amount calculated on demand rather than stored.
88
+ *
89
+ * The same shape as a quantity minus the ID, because nothing was written: it is
90
+ * derived per request, such as a total rolled up across invoiced lines for one
91
+ * analysis.
92
+ */
93
+ export interface ComputedQuantity {
94
+ /**
95
+ * Formatted value with unit abbreviation (e.g. "1,200 pr").
96
+ */
97
+ display_value: string;
98
+
99
+ /**
100
+ * Resource type identifier.
101
+ */
102
+ object: 'computed_quantity';
103
+
104
+ /**
105
+ * Unit of measurement used for conversions and product quantities.
106
+ */
107
+ unit: UnitsAPI.Unit | null;
108
+
109
+ /**
110
+ * Raw decimal value, as a string to preserve precision.
111
+ *
112
+ * This is the unformatted machine value; see `display_value` for the
113
+ * human-readable rendering.
114
+ */
115
+ value: string;
116
+ }
117
+
118
+ /**
119
+ * The stock position for an item: what is in stock, what is already committed, and
120
+ * what is still free to sell.
121
+ *
122
+ * All four quantities are reported in the same unit — the base unit of the item's
123
+ * category. Derived figures, not stored rows: each is netted out of the ledger at
124
+ * read time, so none of them carries a quantity id.
125
+ */
126
+ export interface ItemInventory {
127
+ /**
128
+ * An amount calculated on demand rather than stored.
129
+ *
130
+ * The same shape as a quantity minus the ID, because nothing was written: it is
131
+ * derived per request, such as a total rolled up across invoiced lines for one
132
+ * analysis.
133
+ */
134
+ available_to_promise: ComputedQuantity | null;
135
+
136
+ /**
137
+ * Resource type identifier.
138
+ */
139
+ object: 'item_inventory';
140
+
141
+ /**
142
+ * An amount calculated on demand rather than stored.
143
+ *
144
+ * The same shape as a quantity minus the ID, because nothing was written: it is
145
+ * derived per request, such as a total rolled up across invoiced lines for one
146
+ * analysis.
147
+ */
148
+ on_hand: ComputedQuantity | null;
149
+
150
+ /**
151
+ * An amount calculated on demand rather than stored.
152
+ *
153
+ * The same shape as a quantity minus the ID, because nothing was written: it is
154
+ * derived per request, such as a total rolled up across invoiced lines for one
155
+ * analysis.
156
+ */
157
+ reserved: ComputedQuantity | null;
158
+
159
+ /**
160
+ * An amount calculated on demand rather than stored.
161
+ *
162
+ * The same shape as a quantity minus the ID, because nothing was written: it is
163
+ * derived per request, such as a total rolled up across invoiced lines for one
164
+ * analysis.
165
+ */
166
+ short: ComputedQuantity | null;
167
+ }
168
+
169
+ /**
170
+ * An amount together with the unit it is expressed in.
171
+ *
172
+ * The unit may be a currency, so money amounts such as a credit limit are written
173
+ * the same way as physical amounts like weights or counts.
174
+ */
175
+ export interface QuantityInput {
176
+ /**
177
+ * ID of the unit of measure for the value.
178
+ */
179
+ unit_id: string;
180
+
181
+ /**
182
+ * Decimal value, as a string to preserve precision.
183
+ */
184
+ value: string;
185
+ }
186
+
187
+ /**
188
+ * Request to adjust or reconcile inventory for an item.
189
+ */
190
+ export interface UpdateItemInventoryRequest {
191
+ /**
192
+ * An amount together with the unit it is expressed in.
193
+ *
194
+ * The unit may be a currency, so money amounts such as a credit limit are written
195
+ * the same way as physical amounts like weights or counts.
196
+ */
197
+ quantity: QuantityInput;
198
+
199
+ /**
200
+ * ID of the customer account that owns the resulting inventory.
201
+ *
202
+ * Use this for stock you hold but do not own, such as customer-supplied material.
203
+ * It only affects quantity being added: your account stays the holder, the
204
+ * customer becomes the owner, and the current quantity a `reconcile` measures
205
+ * against is still your account's. Requires edit access to that customer.
206
+ */
207
+ customer_id?: string;
208
+
209
+ /**
210
+ * ID of the location to record the inventory change against.
211
+ *
212
+ * Must be a location in your account.
213
+ */
214
+ location_id?: string;
215
+
216
+ /**
217
+ * Lot number to record the inventory change against.
218
+ *
219
+ * The lot is created for the item if it does not already exist.
220
+ */
221
+ lot_number?: string;
222
+
223
+ /**
224
+ * How `quantity` is applied.
225
+ *
226
+ * - `adjust`: adds `quantity` to the current quantity.
227
+ * - `reconcile`: sets the current quantity to exactly `quantity`.
228
+ */
229
+ operation?: 'adjust' | 'reconcile';
230
+ }
231
+
232
+ export interface InventoryUpdateResponse {}
233
+
234
+ export interface InventoryListParams {
235
+ /**
236
+ * Sub-objects to expand in the response. When omitted, sub-objects are returned as
237
+ * `null`.
238
+ */
239
+ include?: Array<'on_hand' | 'reserved' | 'available_to_promise' | 'short'>;
240
+ }
241
+
242
+ export interface InventoryUpdateParams {
243
+ /**
244
+ * An amount together with the unit it is expressed in.
245
+ *
246
+ * The unit may be a currency, so money amounts such as a credit limit are written
247
+ * the same way as physical amounts like weights or counts.
248
+ */
249
+ quantity: QuantityInput;
250
+
251
+ /**
252
+ * ID of the customer account that owns the resulting inventory.
253
+ *
254
+ * Use this for stock you hold but do not own, such as customer-supplied material.
255
+ * It only affects quantity being added: your account stays the holder, the
256
+ * customer becomes the owner, and the current quantity a `reconcile` measures
257
+ * against is still your account's. Requires edit access to that customer.
258
+ */
259
+ customer_id?: string;
260
+
261
+ /**
262
+ * ID of the location to record the inventory change against.
263
+ *
264
+ * Must be a location in your account.
265
+ */
266
+ location_id?: string;
267
+
268
+ /**
269
+ * Lot number to record the inventory change against.
270
+ *
271
+ * The lot is created for the item if it does not already exist.
272
+ */
273
+ lot_number?: string;
274
+
275
+ /**
276
+ * How `quantity` is applied.
277
+ *
278
+ * - `adjust`: adds `quantity` to the current quantity.
279
+ * - `reconcile`: sets the current quantity to exactly `quantity`.
280
+ */
281
+ operation?: 'adjust' | 'reconcile';
282
+ }
283
+
284
+ export declare namespace Inventory {
285
+ export {
286
+ type ComputedQuantity as ComputedQuantity,
287
+ type ItemInventory as ItemInventory,
288
+ type QuantityInput as QuantityInput,
289
+ type UpdateItemInventoryRequest as UpdateItemInventoryRequest,
290
+ type InventoryUpdateResponse as InventoryUpdateResponse,
291
+ type InventoryListParams as InventoryListParams,
292
+ type InventoryUpdateParams as InventoryUpdateParams,
293
+ };
294
+ }