@wix/auto_sdk_stores_inventory 1.0.84 → 1.0.85

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.
@@ -1,7 +1,25 @@
1
1
  import { HttpClient, NonNullablePaths, EventDefinition, MaybeContext, BuildRESTFunction, BuildEventDefinition } from '@wix/sdk-types';
2
- import { UpdateInventoryVariantsInventoryItem, DecrementData, IncrementData, GetInventoryVariantsOptions, GetInventoryVariantsResponse, QueryInventoryOptions, QueryInventoryResponse, InventoryItemChangedEnvelope, InventoryVariantsChangedEnvelope } from './index.typings.js';
2
+ import { GetInventoryVariantsOptions, GetInventoryVariantsResponse, QueryInventoryOptions, QueryInventoryResponse, UpdateInventoryVariantsInventoryItem, DecrementData, IncrementData, InventoryItemChangedEnvelope, InventoryVariantsChangedEnvelope } from './index.typings.js';
3
3
  export { AccountInfo, BaseEventMetadata, BulkUpdateInventoryItemsRequest, BulkUpdateInventoryItemsResponse, BulkUpdateInventoryVariantsRequest, BulkUpdateInventoryVariantsRequestActionOneOf, BulkUpdateInventoryVariantsResponse, ChangedInventoryVariant, ChangedInventoryVariantData, DecrementDataIdOneOf, DecrementInventoryRequest, DecrementInventoryResponse, GetInventoryItemsRequest, GetInventoryItemsResponse, GetInventoryVariantsOptionsIdOneOf, GetInventoryVariantsRequest, GetInventoryVariantsRequestIdOneOf, IdentificationData, IdentificationDataIdOneOf, IncrementDataIdOneOf, IncrementInventoryRequest, IncrementInventoryResponse, InventoryItemChanged, InventoryItemV2, InventoryVariantV2, InventoryVariantsChanged, MessageEnvelope, Paging, PagingMetadata, PreorderInfo, Query, QueryInventoryRequest, ReasonType, ReasonTypeWithLiterals, UpdateInventoryVariantsRequest, UpdateInventoryVariantsResponse, WebhookIdentityType, WebhookIdentityTypeWithLiterals } from './index.typings.js';
4
4
 
5
+ declare function getInventoryVariants$1(httpClient: HttpClient): GetInventoryVariantsSignature;
6
+ interface GetInventoryVariantsSignature {
7
+ /**
8
+ * Gets inventory variant information based on the specified option choices.
9
+ *
10
+ *
11
+ * The `getInventoryVariants()` function returns a Promise that resolves to the specified inventory variant information.
12
+ * @param - Inventory item ID.
13
+ */
14
+ (inventoryId: string, options?: GetInventoryVariantsOptions): Promise<NonNullablePaths<GetInventoryVariantsResponse, `inventoryItem.variants` | `inventoryItem.variants.${number}.variantId` | `inventoryItem.variants.${number}.availableForPreorder` | `inventoryItem.numericId` | `inventoryItem.preorderInfo.enabled`, 3>>;
15
+ }
16
+ declare function queryInventory$1(httpClient: HttpClient): QueryInventorySignature;
17
+ interface QueryInventorySignature {
18
+ /**
19
+ * Returns a list of inventory items, given the provided paging, sorting and filtering.
20
+ */
21
+ (options?: QueryInventoryOptions): Promise<NonNullablePaths<QueryInventoryResponse, `inventoryItems` | `inventoryItems.${number}.numericId` | `inventoryItems.${number}.preorderInfo.enabled` | `metadata.items` | `metadata.offset` | `totalResults`, 3>>;
22
+ }
5
23
  declare function updateInventoryVariants$1(httpClient: HttpClient): UpdateInventoryVariantsSignature;
6
24
  interface UpdateInventoryVariantsSignature {
7
25
  /**
@@ -36,32 +54,14 @@ interface IncrementInventorySignature {
36
54
  */
37
55
  (incrementData: IncrementData[]): Promise<void>;
38
56
  }
39
- declare function getInventoryVariants$1(httpClient: HttpClient): GetInventoryVariantsSignature;
40
- interface GetInventoryVariantsSignature {
41
- /**
42
- * Gets inventory variant information based on the specified option choices.
43
- *
44
- *
45
- * The `getInventoryVariants()` function returns a Promise that resolves to the specified inventory variant information.
46
- * @param - Inventory item ID.
47
- */
48
- (inventoryId: string, options?: GetInventoryVariantsOptions): Promise<NonNullablePaths<GetInventoryVariantsResponse, `inventoryItem.variants` | `inventoryItem.variants.${number}.variantId` | `inventoryItem.variants.${number}.availableForPreorder` | `inventoryItem.numericId` | `inventoryItem.preorderInfo.enabled`, 3>>;
49
- }
50
- declare function queryInventory$1(httpClient: HttpClient): QueryInventorySignature;
51
- interface QueryInventorySignature {
52
- /**
53
- * Returns a list of inventory items, given the provided paging, sorting and filtering.
54
- */
55
- (options?: QueryInventoryOptions): Promise<NonNullablePaths<QueryInventoryResponse, `inventoryItems` | `inventoryItems.${number}.numericId` | `inventoryItems.${number}.preorderInfo.enabled` | `metadata.items` | `metadata.offset` | `totalResults`, 3>>;
56
- }
57
57
  declare const onInventoryItemChanged$1: EventDefinition<InventoryItemChangedEnvelope, "com.wix.ecommerce.inventory.api.v1.InventoryItemChanged">;
58
58
  declare const onInventoryVariantsChanged$1: EventDefinition<InventoryVariantsChangedEnvelope, "com.wix.ecommerce.inventory.api.v1.InventoryVariantsChanged">;
59
59
 
60
+ declare const getInventoryVariants: MaybeContext<BuildRESTFunction<typeof getInventoryVariants$1> & typeof getInventoryVariants$1>;
61
+ declare const queryInventory: MaybeContext<BuildRESTFunction<typeof queryInventory$1> & typeof queryInventory$1>;
60
62
  declare const updateInventoryVariants: MaybeContext<BuildRESTFunction<typeof updateInventoryVariants$1> & typeof updateInventoryVariants$1>;
61
63
  declare const decrementInventory: MaybeContext<BuildRESTFunction<typeof decrementInventory$1> & typeof decrementInventory$1>;
62
64
  declare const incrementInventory: MaybeContext<BuildRESTFunction<typeof incrementInventory$1> & typeof incrementInventory$1>;
63
- declare const getInventoryVariants: MaybeContext<BuildRESTFunction<typeof getInventoryVariants$1> & typeof getInventoryVariants$1>;
64
- declare const queryInventory: MaybeContext<BuildRESTFunction<typeof queryInventory$1> & typeof queryInventory$1>;
65
65
  /**
66
66
  * Triggered when an inventory item is changed.
67
67
  */
@@ -50,17 +50,6 @@ var import_transform_paths = require("@wix/sdk-runtime/transformations/transform
50
50
  var import_rest_modules = require("@wix/sdk-runtime/rest-modules");
51
51
  var TRANSFORM_PATHS_0 = [{ path: "inventoryItem.lastUpdated" }];
52
52
  var TRANSFORM_PATHS_1 = [{ path: "inventoryItems.lastUpdated" }];
53
- function resolveWixInventoryApiV1InventoryReadApiUrl(opts) {
54
- const domainToMappings = {
55
- "api._api_base_domain_": [
56
- {
57
- srcPath: "/inventory-read-api-proxy",
58
- destPath: ""
59
- }
60
- ]
61
- };
62
- return (0, import_rest_modules.resolveUrl)(Object.assign(opts, { domainToMappings }));
63
- }
64
53
  function resolveWixInventoryApiV1InventoryWriteApiUrl(opts) {
65
54
  const domainToMappings = {
66
55
  _: [
@@ -140,7 +129,72 @@ function resolveWixInventoryApiV1InventoryWriteApiUrl(opts) {
140
129
  };
141
130
  return (0, import_rest_modules.resolveUrl)(Object.assign(opts, { domainToMappings }));
142
131
  }
132
+ function resolveWixInventoryApiV1InventoryReadApiUrl(opts) {
133
+ const domainToMappings = {
134
+ "api._api_base_domain_": [
135
+ {
136
+ srcPath: "/inventory-read-api-proxy",
137
+ destPath: ""
138
+ }
139
+ ]
140
+ };
141
+ return (0, import_rest_modules.resolveUrl)(Object.assign(opts, { domainToMappings }));
142
+ }
143
143
  var PACKAGE_NAME = "@wix/auto_sdk_stores_inventory";
144
+ function getInventoryVariants(payload) {
145
+ function __getInventoryVariants({ host }) {
146
+ const metadata = {
147
+ entityFqdn: "wix.stores.v2.inventory",
148
+ method: "POST",
149
+ methodFqn: "wix.inventory.api.v1.InventoryReadApi.GetInventoryVariants",
150
+ packageName: PACKAGE_NAME,
151
+ migrationOptions: {
152
+ optInTransformResponse: true
153
+ },
154
+ url: resolveWixInventoryApiV1InventoryReadApiUrl({
155
+ protoPath: "/v2/inventoryItems/{inventoryId}/getVariants",
156
+ data: payload,
157
+ host
158
+ }),
159
+ data: payload,
160
+ transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
161
+ {
162
+ transformFn: import_timestamp2.transformRESTTimestampToSDKTimestamp,
163
+ paths: TRANSFORM_PATHS_0
164
+ }
165
+ ])
166
+ };
167
+ return metadata;
168
+ }
169
+ return __getInventoryVariants;
170
+ }
171
+ function queryInventory(payload) {
172
+ function __queryInventory({ host }) {
173
+ const metadata = {
174
+ entityFqdn: "wix.stores.v2.inventory",
175
+ method: "POST",
176
+ methodFqn: "wix.inventory.api.v1.InventoryReadApi.QueryInventory",
177
+ packageName: PACKAGE_NAME,
178
+ migrationOptions: {
179
+ optInTransformResponse: true
180
+ },
181
+ url: resolveWixInventoryApiV1InventoryReadApiUrl({
182
+ protoPath: "/v2/inventoryItems/query",
183
+ data: payload,
184
+ host
185
+ }),
186
+ data: payload,
187
+ transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
188
+ {
189
+ transformFn: import_timestamp2.transformRESTTimestampToSDKTimestamp,
190
+ paths: TRANSFORM_PATHS_1
191
+ }
192
+ ])
193
+ };
194
+ return metadata;
195
+ }
196
+ return __queryInventory;
197
+ }
144
198
  function updateInventoryVariants(payload) {
145
199
  function __updateInventoryVariants({ host }) {
146
200
  const serializedData = (0, import_transform_paths.transformPaths)(payload, [
@@ -210,60 +264,6 @@ function incrementInventory(payload) {
210
264
  }
211
265
  return __incrementInventory;
212
266
  }
213
- function getInventoryVariants(payload) {
214
- function __getInventoryVariants({ host }) {
215
- const metadata = {
216
- entityFqdn: "wix.stores.v2.inventory",
217
- method: "POST",
218
- methodFqn: "wix.inventory.api.v1.InventoryReadApi.GetInventoryVariants",
219
- packageName: PACKAGE_NAME,
220
- migrationOptions: {
221
- optInTransformResponse: true
222
- },
223
- url: resolveWixInventoryApiV1InventoryReadApiUrl({
224
- protoPath: "/v2/inventoryItems/{inventoryId}/getVariants",
225
- data: payload,
226
- host
227
- }),
228
- data: payload,
229
- transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
230
- {
231
- transformFn: import_timestamp2.transformRESTTimestampToSDKTimestamp,
232
- paths: TRANSFORM_PATHS_0
233
- }
234
- ])
235
- };
236
- return metadata;
237
- }
238
- return __getInventoryVariants;
239
- }
240
- function queryInventory(payload) {
241
- function __queryInventory({ host }) {
242
- const metadata = {
243
- entityFqdn: "wix.stores.v2.inventory",
244
- method: "POST",
245
- methodFqn: "wix.inventory.api.v1.InventoryReadApi.QueryInventory",
246
- packageName: PACKAGE_NAME,
247
- migrationOptions: {
248
- optInTransformResponse: true
249
- },
250
- url: resolveWixInventoryApiV1InventoryReadApiUrl({
251
- protoPath: "/v2/inventoryItems/query",
252
- data: payload,
253
- host
254
- }),
255
- data: payload,
256
- transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
257
- {
258
- transformFn: import_timestamp2.transformRESTTimestampToSDKTimestamp,
259
- paths: TRANSFORM_PATHS_1
260
- }
261
- ])
262
- };
263
- return metadata;
264
- }
265
- return __queryInventory;
266
- }
267
267
 
268
268
  // src/stores-v2-inventory-inventory.universal.ts
269
269
  var ReasonType = /* @__PURE__ */ ((ReasonType2) => {
@@ -281,60 +281,70 @@ var WebhookIdentityType = /* @__PURE__ */ ((WebhookIdentityType2) => {
281
281
  WebhookIdentityType2["APP"] = "APP";
282
282
  return WebhookIdentityType2;
283
283
  })(WebhookIdentityType || {});
284
- async function updateInventoryVariants2(productId, inventoryItem) {
284
+ async function getInventoryVariants2(inventoryId, options) {
285
285
  const { httpClient, sideEffects } = arguments[2];
286
286
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
287
- inventoryItem: { ...inventoryItem, productId }
287
+ inventoryId,
288
+ externalId: options?.externalId,
289
+ productId: options?.productId,
290
+ variantIds: options?.variantIds
288
291
  });
289
- const reqOpts = updateInventoryVariants(payload);
292
+ const reqOpts = getInventoryVariants(payload);
290
293
  sideEffects?.onSiteCall?.();
291
294
  try {
292
295
  const result = await httpClient.request(reqOpts);
293
296
  sideEffects?.onSuccess?.(result);
297
+ return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data);
294
298
  } catch (err) {
295
299
  const transformedError = (0, import_transform_error.transformError)(
296
300
  err,
297
301
  {
298
- spreadPathsToArguments: { inventoryItem: "$[1]" },
299
- explicitPathsToArguments: { "inventoryItem.productId": "$[0]" },
302
+ spreadPathsToArguments: {},
303
+ explicitPathsToArguments: {
304
+ inventoryId: "$[0]",
305
+ externalId: "$[1].externalId",
306
+ productId: "$[1].productId",
307
+ variantIds: "$[1].variantIds"
308
+ },
300
309
  singleArgumentUnchanged: false
301
310
  },
302
- ["productId", "inventoryItem"]
311
+ ["inventoryId", "options"]
303
312
  );
304
313
  sideEffects?.onError?.(err);
305
314
  throw transformedError;
306
315
  }
307
316
  }
308
- async function decrementInventory2(decrementData) {
317
+ async function queryInventory2(options) {
309
318
  const { httpClient, sideEffects } = arguments[1];
310
319
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
311
- decrementData
320
+ query: options?.query
312
321
  });
313
- const reqOpts = decrementInventory(payload);
322
+ const reqOpts = queryInventory(payload);
314
323
  sideEffects?.onSiteCall?.();
315
324
  try {
316
325
  const result = await httpClient.request(reqOpts);
317
326
  sideEffects?.onSuccess?.(result);
327
+ return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data);
318
328
  } catch (err) {
319
329
  const transformedError = (0, import_transform_error.transformError)(
320
330
  err,
321
331
  {
322
332
  spreadPathsToArguments: {},
323
- explicitPathsToArguments: { decrementData: "$[0]" },
333
+ explicitPathsToArguments: { query: "$[0].query" },
324
334
  singleArgumentUnchanged: false
325
335
  },
326
- ["decrementData"]
336
+ ["options"]
327
337
  );
328
338
  sideEffects?.onError?.(err);
329
339
  throw transformedError;
330
340
  }
331
341
  }
332
- async function incrementInventory2(incrementData) {
333
- const { httpClient, sideEffects } = arguments[1];
342
+ async function updateInventoryVariants2(productId, inventoryItem) {
343
+ const { httpClient, sideEffects } = arguments[2];
334
344
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
335
- incrementData
345
+ inventoryItem: { ...inventoryItem, productId }
336
346
  });
337
- const reqOpts = incrementInventory(payload);
347
+ const reqOpts = updateInventoryVariants(payload);
338
348
  sideEffects?.onSiteCall?.();
339
349
  try {
340
350
  const result = await httpClient.request(reqOpts);
@@ -343,69 +353,59 @@ async function incrementInventory2(incrementData) {
343
353
  const transformedError = (0, import_transform_error.transformError)(
344
354
  err,
345
355
  {
346
- spreadPathsToArguments: {},
347
- explicitPathsToArguments: { incrementData: "$[0]" },
356
+ spreadPathsToArguments: { inventoryItem: "$[1]" },
357
+ explicitPathsToArguments: { "inventoryItem.productId": "$[0]" },
348
358
  singleArgumentUnchanged: false
349
359
  },
350
- ["incrementData"]
360
+ ["productId", "inventoryItem"]
351
361
  );
352
362
  sideEffects?.onError?.(err);
353
363
  throw transformedError;
354
364
  }
355
365
  }
356
- async function getInventoryVariants2(inventoryId, options) {
357
- const { httpClient, sideEffects } = arguments[2];
366
+ async function decrementInventory2(decrementData) {
367
+ const { httpClient, sideEffects } = arguments[1];
358
368
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
359
- inventoryId,
360
- externalId: options?.externalId,
361
- productId: options?.productId,
362
- variantIds: options?.variantIds
369
+ decrementData
363
370
  });
364
- const reqOpts = getInventoryVariants(payload);
371
+ const reqOpts = decrementInventory(payload);
365
372
  sideEffects?.onSiteCall?.();
366
373
  try {
367
374
  const result = await httpClient.request(reqOpts);
368
375
  sideEffects?.onSuccess?.(result);
369
- return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data);
370
376
  } catch (err) {
371
377
  const transformedError = (0, import_transform_error.transformError)(
372
378
  err,
373
379
  {
374
380
  spreadPathsToArguments: {},
375
- explicitPathsToArguments: {
376
- inventoryId: "$[0]",
377
- externalId: "$[1].externalId",
378
- productId: "$[1].productId",
379
- variantIds: "$[1].variantIds"
380
- },
381
+ explicitPathsToArguments: { decrementData: "$[0]" },
381
382
  singleArgumentUnchanged: false
382
383
  },
383
- ["inventoryId", "options"]
384
+ ["decrementData"]
384
385
  );
385
386
  sideEffects?.onError?.(err);
386
387
  throw transformedError;
387
388
  }
388
389
  }
389
- async function queryInventory2(options) {
390
+ async function incrementInventory2(incrementData) {
390
391
  const { httpClient, sideEffects } = arguments[1];
391
392
  const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
392
- query: options?.query
393
+ incrementData
393
394
  });
394
- const reqOpts = queryInventory(payload);
395
+ const reqOpts = incrementInventory(payload);
395
396
  sideEffects?.onSiteCall?.();
396
397
  try {
397
398
  const result = await httpClient.request(reqOpts);
398
399
  sideEffects?.onSuccess?.(result);
399
- return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data);
400
400
  } catch (err) {
401
401
  const transformedError = (0, import_transform_error.transformError)(
402
402
  err,
403
403
  {
404
404
  spreadPathsToArguments: {},
405
- explicitPathsToArguments: { query: "$[0].query" },
405
+ explicitPathsToArguments: { incrementData: "$[0]" },
406
406
  singleArgumentUnchanged: false
407
407
  },
408
- ["options"]
408
+ ["incrementData"]
409
409
  );
410
410
  sideEffects?.onError?.(err);
411
411
  throw transformedError;
@@ -415,6 +415,21 @@ async function queryInventory2(options) {
415
415
  // src/stores-v2-inventory-inventory.public.ts
416
416
  var TRANSFORM_PATHS_02 = [{ path: "data.fieldMask" }];
417
417
  var TRANSFORM_PATHS_12 = [{ path: "data.updatedDate" }];
418
+ function getInventoryVariants3(httpClient) {
419
+ return (inventoryId, options) => getInventoryVariants2(
420
+ inventoryId,
421
+ options,
422
+ // @ts-ignore
423
+ { httpClient }
424
+ );
425
+ }
426
+ function queryInventory3(httpClient) {
427
+ return (options) => queryInventory2(
428
+ options,
429
+ // @ts-ignore
430
+ { httpClient }
431
+ );
432
+ }
418
433
  function updateInventoryVariants3(httpClient) {
419
434
  return (productId, inventoryItem) => updateInventoryVariants2(
420
435
  productId,
@@ -437,21 +452,6 @@ function incrementInventory3(httpClient) {
437
452
  { httpClient }
438
453
  );
439
454
  }
440
- function getInventoryVariants3(httpClient) {
441
- return (inventoryId, options) => getInventoryVariants2(
442
- inventoryId,
443
- options,
444
- // @ts-ignore
445
- { httpClient }
446
- );
447
- }
448
- function queryInventory3(httpClient) {
449
- return (options) => queryInventory2(
450
- options,
451
- // @ts-ignore
452
- { httpClient }
453
- );
454
- }
455
455
  var onInventoryItemChanged = /* @__PURE__ */ (0, import_sdk_types.EventDefinition)(
456
456
  "com.wix.ecommerce.inventory.api.v1.InventoryItemChanged",
457
457
  false,
@@ -484,11 +484,11 @@ var onInventoryVariantsChanged = /* @__PURE__ */ (0, import_sdk_types.EventDefin
484
484
  // src/stores-v2-inventory-inventory.context.ts
485
485
  var import_rest_modules2 = require("@wix/sdk-runtime/rest-modules");
486
486
  var import_event_definition_modules = require("@wix/sdk-runtime/event-definition-modules");
487
+ var getInventoryVariants4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(getInventoryVariants3);
488
+ var queryInventory4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(queryInventory3);
487
489
  var updateInventoryVariants4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(updateInventoryVariants3);
488
490
  var decrementInventory4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(decrementInventory3);
489
491
  var incrementInventory4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(incrementInventory3);
490
- var getInventoryVariants4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(getInventoryVariants3);
491
- var queryInventory4 = /* @__PURE__ */ (0, import_rest_modules2.createRESTModule)(queryInventory3);
492
492
  var onInventoryItemChanged2 = /* @__PURE__ */ (0, import_event_definition_modules.createEventModule)(
493
493
  onInventoryItemChanged
494
494
  );