@lana-commerce/core 11.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 (972) hide show
  1. package/CHANGELOG.md +531 -0
  2. package/cjs/actionLock.js +31 -0
  3. package/cjs/addEmptyListItem.js +7 -0
  4. package/cjs/aggregateOptions.js +178 -0
  5. package/cjs/analytics.js +90 -0
  6. package/cjs/analyticsProductData.js +33 -0
  7. package/cjs/arrayToDict.js +12 -0
  8. package/cjs/asyncModuleWrapper.js +52 -0
  9. package/cjs/averageReviewScore.js +45 -0
  10. package/cjs/buildconfig.js +16 -0
  11. package/cjs/cachedLoader.js +36 -0
  12. package/cjs/canonicalVariantURL.js +2 -0
  13. package/cjs/cartOperation.js +132 -0
  14. package/cjs/categorySEO.js +20 -0
  15. package/cjs/commonTypes.js +2 -0
  16. package/cjs/compact.js +8 -0
  17. package/cjs/configLoader.js +69 -0
  18. package/cjs/controlledQueue.js +46 -0
  19. package/cjs/convertImageURL.js +19 -0
  20. package/cjs/dataLoader.js +185 -0
  21. package/cjs/defaultVariant.js +30 -0
  22. package/cjs/effector/clearOnChangeAfterDelay.js +17 -0
  23. package/cjs/effector/combineEvery.js +8 -0
  24. package/cjs/effector/combineSome.js +8 -0
  25. package/cjs/effector/debounced.js +18 -0
  26. package/cjs/effector/form.js +168 -0
  27. package/cjs/effector/hideOnChangeAfterDelay.js +17 -0
  28. package/cjs/effector/requestResponse.js +30 -0
  29. package/cjs/effector/requestResponseMulti.js +51 -0
  30. package/cjs/effector/restoreNamed.js +8 -0
  31. package/cjs/effector/split.js +29 -0
  32. package/cjs/effector/validator.js +33 -0
  33. package/cjs/effector/wrapSignInRequired.js +13 -0
  34. package/cjs/exceptions.js +6 -0
  35. package/cjs/fetchAllItems.js +56 -0
  36. package/cjs/file.js +83 -0
  37. package/cjs/fileWebsocket.js +83 -0
  38. package/cjs/filterFunc.js +48 -0
  39. package/cjs/filterFuncBrand.js +12 -0
  40. package/cjs/filterFuncCategory.js +12 -0
  41. package/cjs/filterFuncContentBlock.js +19 -0
  42. package/cjs/filterFuncCustomer.js +161 -0
  43. package/cjs/filterFuncDataFeed.js +54 -0
  44. package/cjs/filterFuncOrder.js +334 -0
  45. package/cjs/filterFuncPreprocess.js +14 -0
  46. package/cjs/filterFuncProduct.js +70 -0
  47. package/cjs/filterFuncPurchaseOrder.js +126 -0
  48. package/cjs/filterFuncSupplier.js +36 -0
  49. package/cjs/filterFuncTransfer.js +135 -0
  50. package/cjs/formatAbbrevNumber.js +21 -0
  51. package/cjs/formatCurrency.js +47 -0
  52. package/cjs/formatToJSX.js +123 -0
  53. package/cjs/fulfillmentNumber.js +7 -0
  54. package/cjs/generateRandomToken.js +12 -0
  55. package/cjs/generateUUID.js +10 -0
  56. package/cjs/generated/codes.js +47 -0
  57. package/cjs/genericFile.js +73 -0
  58. package/cjs/getSalesChannelID.js +13 -0
  59. package/cjs/getSessionID.js +13 -0
  60. package/cjs/getTimezone.js +12 -0
  61. package/cjs/graphql/fragments/Branding.js +3 -0
  62. package/cjs/graphql/fragments/BrandingField.js +3 -0
  63. package/cjs/graphql/fragments/CartCustomItem.js +3 -0
  64. package/cjs/graphql/fragments/CartOrder.js +3 -0
  65. package/cjs/graphql/fragments/CartVariant.js +3 -0
  66. package/cjs/graphql/fragments/CartVariantFull.js +3 -0
  67. package/cjs/graphql/fragments/Category.js +3 -0
  68. package/cjs/graphql/fragments/CommonCartVariant.js +3 -0
  69. package/cjs/graphql/fragments/Currency.js +3 -0
  70. package/cjs/graphql/fragments/CurrencyPrice.js +3 -0
  71. package/cjs/graphql/fragments/CustomField.js +3 -0
  72. package/cjs/graphql/fragments/CustomFieldObjects.js +3 -0
  73. package/cjs/graphql/fragments/Customer.js +3 -0
  74. package/cjs/graphql/fragments/CustomerBalance.js +3 -0
  75. package/cjs/graphql/fragments/CustomerBalanceHistory.js +3 -0
  76. package/cjs/graphql/fragments/CustomerFavorite.js +3 -0
  77. package/cjs/graphql/fragments/CustomerFavoriteShort.js +3 -0
  78. package/cjs/graphql/fragments/CustomerOAuthProvider.js +3 -0
  79. package/cjs/graphql/fragments/CustomerOrderBrief.js +3 -0
  80. package/cjs/graphql/fragments/CustomerOrderFulfillment.js +3 -0
  81. package/cjs/graphql/fragments/CustomerOrderFull.js +3 -0
  82. package/cjs/graphql/fragments/CustomerPaymentSource.js +3 -0
  83. package/cjs/graphql/fragments/CustomerReturnBrief.js +3 -0
  84. package/cjs/graphql/fragments/CustomerReturnFull.js +3 -0
  85. package/cjs/graphql/fragments/CustomerReturnPolicy.js +3 -0
  86. package/cjs/graphql/fragments/CustomerSubscriptionBrief.js +3 -0
  87. package/cjs/graphql/fragments/CustomerSubscriptionFull.js +3 -0
  88. package/cjs/graphql/fragments/File.js +3 -0
  89. package/cjs/graphql/fragments/FileForUpload.js +3 -0
  90. package/cjs/graphql/fragments/FileNoFallback.js +3 -0
  91. package/cjs/graphql/fragments/FullAddress.js +3 -0
  92. package/cjs/graphql/fragments/Gateway.js +3 -0
  93. package/cjs/graphql/fragments/GatewayManual.js +3 -0
  94. package/cjs/graphql/fragments/GatewayPaypal.js +3 -0
  95. package/cjs/graphql/fragments/GatewayStripe.js +3 -0
  96. package/cjs/graphql/fragments/GatewayTest.js +3 -0
  97. package/cjs/graphql/fragments/IPAndUAInfo.js +3 -0
  98. package/cjs/graphql/fragments/InfoCountry.js +3 -0
  99. package/cjs/graphql/fragments/InfoCountryDedupField.js +3 -0
  100. package/cjs/graphql/fragments/InfoCurrency.js +3 -0
  101. package/cjs/graphql/fragments/InfoProvince.js +3 -0
  102. package/cjs/graphql/fragments/KeyValue.js +3 -0
  103. package/cjs/graphql/fragments/LineItemField.js +3 -0
  104. package/cjs/graphql/fragments/MediaFile.js +3 -0
  105. package/cjs/graphql/fragments/MinCurrencyPrice.js +3 -0
  106. package/cjs/graphql/fragments/ProductField.js +3 -0
  107. package/cjs/graphql/fragments/ProductFieldSet.js +3 -0
  108. package/cjs/graphql/fragments/ProductFlat.js +3 -0
  109. package/cjs/graphql/fragments/ProductQuestion.js +3 -0
  110. package/cjs/graphql/fragments/ProductQuestionAnswer.js +3 -0
  111. package/cjs/graphql/fragments/ProductQuestionPage.js +3 -0
  112. package/cjs/graphql/fragments/ProductReview.js +3 -0
  113. package/cjs/graphql/fragments/ProductReviewAnswer.js +3 -0
  114. package/cjs/graphql/fragments/ProductReviewAverageScore.js +3 -0
  115. package/cjs/graphql/fragments/ProductReviewPage.js +3 -0
  116. package/cjs/graphql/fragments/ProductReviewScore.js +3 -0
  117. package/cjs/graphql/fragments/ProductReviewSurveyAnswer.js +3 -0
  118. package/cjs/graphql/fragments/ProductSearchOptionAgg.js +3 -0
  119. package/cjs/graphql/fragments/ProductSearchResult.js +3 -0
  120. package/cjs/graphql/fragments/ReturnReason.js +3 -0
  121. package/cjs/graphql/fragments/ReviewDimension.js +3 -0
  122. package/cjs/graphql/fragments/ReviewDimensionSet.js +3 -0
  123. package/cjs/graphql/fragments/ReviewImagePage.js +3 -0
  124. package/cjs/graphql/fragments/ReviewQuestionProduct.js +3 -0
  125. package/cjs/graphql/fragments/ReviewSettings.js +3 -0
  126. package/cjs/graphql/fragments/SearchProduct.js +3 -0
  127. package/cjs/graphql/fragments/Shop.js +3 -0
  128. package/cjs/graphql/fragments/SubscriptionPlan.js +3 -0
  129. package/cjs/graphql/fragments/SurveyQuestion.js +3 -0
  130. package/cjs/graphql/fragments/TieredPricing.js +3 -0
  131. package/cjs/graphql/fragments/TieredPricingTier.js +3 -0
  132. package/cjs/graphql/fragments/VariantOption.js +3 -0
  133. package/cjs/graphql/operations/ApplyGiftCardMutation.js +3 -0
  134. package/cjs/graphql/operations/AuthRequestMutation.js +3 -0
  135. package/cjs/graphql/operations/CancelOrderMutation.js +3 -0
  136. package/cjs/graphql/operations/CancelSubscriptionMutation.js +3 -0
  137. package/cjs/graphql/operations/ConnectOAuth2Mutation.js +3 -0
  138. package/cjs/graphql/operations/CreateCartMutation.js +26 -0
  139. package/cjs/graphql/operations/CreateFavoriteMutation.js +22 -0
  140. package/cjs/graphql/operations/CreateFileMutation.js +6 -0
  141. package/cjs/graphql/operations/CreatePaymentSourceMutation.js +6 -0
  142. package/cjs/graphql/operations/CreateProductQuestionAnswerMutation.js +3 -0
  143. package/cjs/graphql/operations/CreateProductQuestionMutation.js +8 -0
  144. package/cjs/graphql/operations/CreateProductReviewMutation.js +18 -0
  145. package/cjs/graphql/operations/CreateReturnMutation.js +22 -0
  146. package/cjs/graphql/operations/DeleteFavoriteMutation.js +3 -0
  147. package/cjs/graphql/operations/DeletePaymentSourceMutation.js +3 -0
  148. package/cjs/graphql/operations/DeleteProductQuestionAnswerMutation.js +3 -0
  149. package/cjs/graphql/operations/DeleteProductQuestionMutation.js +3 -0
  150. package/cjs/graphql/operations/DeleteProductReviewMutation.js +3 -0
  151. package/cjs/graphql/operations/DisconnectOAuth2Mutation.js +3 -0
  152. package/cjs/graphql/operations/EditSubscriptionMutation.js +3 -0
  153. package/cjs/graphql/operations/FileUploadedMutation.js +6 -0
  154. package/cjs/graphql/operations/FlagQuestionAnswerMutation.js +3 -0
  155. package/cjs/graphql/operations/FlagQuestionMutation.js +3 -0
  156. package/cjs/graphql/operations/FlagReviewAnswerMutation.js +3 -0
  157. package/cjs/graphql/operations/FlagReviewMutation.js +3 -0
  158. package/cjs/graphql/operations/GetBrandingQuery.js +10 -0
  159. package/cjs/graphql/operations/GetCartQuery.js +26 -0
  160. package/cjs/graphql/operations/GetCustomerAddressesPageDataQuery.js +16 -0
  161. package/cjs/graphql/operations/GetCustomerBalanceHistoryPageQuery.js +6 -0
  162. package/cjs/graphql/operations/GetCustomerBalanceQuery.js +8 -0
  163. package/cjs/graphql/operations/GetCustomerInfoQuery.js +10 -0
  164. package/cjs/graphql/operations/GetCustomerQuery.js +8 -0
  165. package/cjs/graphql/operations/GetFavoritesQuery.js +22 -0
  166. package/cjs/graphql/operations/GetFileStatusQuery.js +6 -0
  167. package/cjs/graphql/operations/GetGatewaysQuery.js +14 -0
  168. package/cjs/graphql/operations/GetInfoCurrenciesQuery.js +6 -0
  169. package/cjs/graphql/operations/GetLastCartQuery.js +26 -0
  170. package/cjs/graphql/operations/GetOrderQuery.js +30 -0
  171. package/cjs/graphql/operations/GetOrdersPageQuery.js +24 -0
  172. package/cjs/graphql/operations/GetPaymentMethodsPageDataQuery.js +18 -0
  173. package/cjs/graphql/operations/GetProductQuestionsPageQuery.js +10 -0
  174. package/cjs/graphql/operations/GetProductReviewImagesPageQuery.js +8 -0
  175. package/cjs/graphql/operations/GetProductReviewsPageQuery.js +20 -0
  176. package/cjs/graphql/operations/GetProvincesQuery.js +6 -0
  177. package/cjs/graphql/operations/GetQuestionQuery.js +8 -0
  178. package/cjs/graphql/operations/GetReturnCreationInfoQuery.js +36 -0
  179. package/cjs/graphql/operations/GetReturnQuery.js +28 -0
  180. package/cjs/graphql/operations/GetReturnsPageQuery.js +22 -0
  181. package/cjs/graphql/operations/GetReviewDimensionsQuery.js +6 -0
  182. package/cjs/graphql/operations/GetReviewQuery.js +18 -0
  183. package/cjs/graphql/operations/GetReviewSettingsQuery.js +12 -0
  184. package/cjs/graphql/operations/GetShopCurrenciesQuery.js +6 -0
  185. package/cjs/graphql/operations/GetShopQuery.js +8 -0
  186. package/cjs/graphql/operations/GetSubscriptionQuery.js +36 -0
  187. package/cjs/graphql/operations/GetSubscriptionsPageQuery.js +22 -0
  188. package/cjs/graphql/operations/GetVariantPageQuery.js +20 -0
  189. package/cjs/graphql/operations/LoadProductNoCustomerQuery.js +62 -0
  190. package/cjs/graphql/operations/LoadProductQuery.js +66 -0
  191. package/cjs/graphql/operations/ModifyCartMutation.js +26 -0
  192. package/cjs/graphql/operations/ModifyCustomerMutation.js +8 -0
  193. package/cjs/graphql/operations/ModifyFavoriteMutation.js +22 -0
  194. package/cjs/graphql/operations/ModifyProductQuestionAnswerMutation.js +3 -0
  195. package/cjs/graphql/operations/ModifyProductQuestionMutation.js +8 -0
  196. package/cjs/graphql/operations/ModifyProductReviewMutation.js +18 -0
  197. package/cjs/graphql/operations/NewPasswordMutation.js +3 -0
  198. package/cjs/graphql/operations/PauseSubscriptionMutation.js +3 -0
  199. package/cjs/graphql/operations/ResetPasswordMutation.js +3 -0
  200. package/cjs/graphql/operations/ResumeSubscriptionMutation.js +3 -0
  201. package/cjs/graphql/operations/SearchProductsAdvancedQuery.js +24 -0
  202. package/cjs/graphql/operations/SearchProductsQuery.js +20 -0
  203. package/cjs/graphql/operations/SearchQuestionsQuery.js +8 -0
  204. package/cjs/graphql/operations/SearchReviewsQuery.js +18 -0
  205. package/cjs/graphql/operations/SignInMutation.js +3 -0
  206. package/cjs/graphql/operations/SignInViaEmailCompleteMutation.js +3 -0
  207. package/cjs/graphql/operations/SignInViaEmailInitMutation.js +3 -0
  208. package/cjs/graphql/operations/SignUpMutation.js +3 -0
  209. package/cjs/graphql/operations/SkipNextSubscriptionMutation.js +3 -0
  210. package/cjs/graphql/operations/UploadFileMutation.js +3 -0
  211. package/cjs/graphql/operations/VerifyCodeMutation.js +3 -0
  212. package/cjs/graphql/operations/VoteQuestionAnswerMutation.js +3 -0
  213. package/cjs/graphql/operations/VoteQuestionMutation.js +3 -0
  214. package/cjs/graphql/operations/VoteReviewAnswerMutation.js +3 -0
  215. package/cjs/graphql/operations/VoteReviewMutation.js +3 -0
  216. package/cjs/graphql/types.js +2 -0
  217. package/cjs/hierarchicalSearchOption.js +42 -0
  218. package/cjs/idgen.js +8 -0
  219. package/cjs/ignoreQueue.js +50 -0
  220. package/cjs/imageAltProps.js +13 -0
  221. package/cjs/invoiceFormat.js +59 -0
  222. package/cjs/isShippingRequired.js +20 -0
  223. package/cjs/isoStripTrailingZeros.js +7 -0
  224. package/cjs/json/commerce.js +10 -0
  225. package/cjs/json/commerceFileUpload.js +57 -0
  226. package/cjs/json/commerceTypes.js +2 -0
  227. package/cjs/json/common.js +320 -0
  228. package/cjs/json/fetchAllItems.js +61 -0
  229. package/cjs/json/mutator.js +957 -0
  230. package/cjs/json/storefront.js +10 -0
  231. package/cjs/json/storefrontTypes.js +2 -0
  232. package/cjs/lastValue.js +17 -0
  233. package/cjs/lineItemPrice.js +111 -0
  234. package/cjs/loadJWT.js +25 -0
  235. package/cjs/mapInvalidInput.js +33 -0
  236. package/cjs/mapResponseData.js +16 -0
  237. package/cjs/mapResponseMultiData.js +14 -0
  238. package/cjs/meanBy.js +15 -0
  239. package/cjs/media.js +16 -0
  240. package/cjs/modules/advancedSearch.js +127 -0
  241. package/cjs/modules/cart.js +708 -0
  242. package/cjs/modules/config/defaultAdvancedSearchGraphQLConfig.js +8 -0
  243. package/cjs/modules/config/defaultCartGraphQLConfig.js +14 -0
  244. package/cjs/modules/config/defaultProductGraphQLConfig.js +48 -0
  245. package/cjs/modules/config/defaultSearchGraphQLConfig.js +8 -0
  246. package/cjs/modules/customer.js +2174 -0
  247. package/cjs/modules/helpers/cartInitOption.js +22 -0
  248. package/cjs/modules/helpers/cookieConsent.js +33 -0
  249. package/cjs/modules/helpers/customerOauth2.js +64 -0
  250. package/cjs/modules/helpers/getOAuth2Hook.js +52 -0
  251. package/cjs/modules/helpers/hookUpAnalytics.js +49 -0
  252. package/cjs/modules/helpers/loadJWT.js +23 -0
  253. package/cjs/modules/helpers/misc.js +58 -0
  254. package/cjs/modules/imageDialog.js +78 -0
  255. package/cjs/modules/persist.js +55 -0
  256. package/cjs/modules/popupMessage.js +21 -0
  257. package/cjs/modules/product.js +1261 -0
  258. package/cjs/modules/recentlyVisitedProducts.js +72 -0
  259. package/cjs/modules/search.js +102 -0
  260. package/cjs/multiResponseToResponse.js +22 -0
  261. package/cjs/nonNull.js +10 -0
  262. package/cjs/oauthState.js +40 -0
  263. package/cjs/orderShippingAddress.js +7 -0
  264. package/cjs/package.json +3 -0
  265. package/cjs/pender.js +16 -0
  266. package/cjs/percentageOff.js +7 -0
  267. package/cjs/popupConnectQueue.js +62 -0
  268. package/cjs/preact/components/SixDigitInput.js +167 -0
  269. package/cjs/preact/effector.js +74 -0
  270. package/cjs/preact/transition/CSSTransition.js +55 -0
  271. package/cjs/preact/transition/Transition.js +104 -0
  272. package/cjs/preact/translateLocalStatic.js +31 -0
  273. package/cjs/productFiltering.js +173 -0
  274. package/cjs/productSEO.js +51 -0
  275. package/cjs/productSorting.js +93 -0
  276. package/cjs/promiseAll.js +18 -0
  277. package/cjs/promiseLimit.js +38 -0
  278. package/cjs/rdsToInitialScores.js +32 -0
  279. package/cjs/react/components/Portal.js +7 -0
  280. package/cjs/react/components/RootCloseWrapper.js +41 -0
  281. package/cjs/react/components/SixDigitInput.js +167 -0
  282. package/cjs/react/contains.js +14 -0
  283. package/cjs/react/popperBinder.js +70 -0
  284. package/cjs/react/rootClose.js +112 -0
  285. package/cjs/react/translateLocalStatic.js +32 -0
  286. package/cjs/react/useAsyncCachedValue.js +14 -0
  287. package/cjs/refreshTimeout.js +25 -0
  288. package/cjs/remoteAuth.js +59 -0
  289. package/cjs/request.js +348 -0
  290. package/cjs/requestDetails.js +76 -0
  291. package/cjs/rfc3339Normalize.js +10 -0
  292. package/cjs/script.js +172 -0
  293. package/cjs/seo.js +2 -0
  294. package/cjs/shopDomain.js +8 -0
  295. package/cjs/shopLinks.js +63 -0
  296. package/cjs/slate.js +376 -0
  297. package/cjs/sleep.js +10 -0
  298. package/cjs/splitBy.js +21 -0
  299. package/cjs/splitName.js +28 -0
  300. package/cjs/stripZeros.js +13 -0
  301. package/cjs/stripeError.js +65 -0
  302. package/cjs/tailSplit.js +12 -0
  303. package/cjs/tieredPrice.js +32 -0
  304. package/cjs/timeIt.js +15 -0
  305. package/cjs/toMajor.js +8 -0
  306. package/cjs/toMinor.js +8 -0
  307. package/cjs/trace.js +37 -0
  308. package/cjs/translateLocale.js +12 -0
  309. package/cjs/traverse.js +14 -0
  310. package/cjs/truncate.js +21 -0
  311. package/cjs/typedLocalStorage.js +30 -0
  312. package/cjs/variantImage.js +26 -0
  313. package/cjs/variantImageURL.js +13 -0
  314. package/cjs/variantImages.js +19 -0
  315. package/cjs/variantInventory.js +43 -0
  316. package/cjs/variantOptions.js +21 -0
  317. package/cjs/variantPrice.js +96 -0
  318. package/cjs/variantPriceCommerce.js +29 -0
  319. package/cjs/variantTitle.js +9 -0
  320. package/cjs/variantTitleFull.js +11 -0
  321. package/cjs/variantURL.js +9 -0
  322. package/cjs/vendor/popper/index.d.ts +160 -0
  323. package/cjs/vendor/popper/index.js +2657 -0
  324. package/cjs/vendor/popper/index.js.map +1 -0
  325. package/cjs/vendor/popper/package.json +3 -0
  326. package/cjs/websocket.js +179 -0
  327. package/esm/actionLock.js +24 -0
  328. package/esm/addEmptyListItem.js +3 -0
  329. package/esm/aggregateOptions.js +169 -0
  330. package/esm/analytics.js +91 -0
  331. package/esm/analyticsProductData.js +28 -0
  332. package/esm/arrayToDict.js +8 -0
  333. package/esm/asyncModuleWrapper.js +47 -0
  334. package/esm/averageReviewScore.js +40 -0
  335. package/esm/buildconfig.js +13 -0
  336. package/esm/cachedLoader.js +32 -0
  337. package/esm/canonicalVariantURL.js +1 -0
  338. package/esm/cartOperation.js +126 -0
  339. package/esm/categorySEO.js +16 -0
  340. package/esm/commonTypes.js +1 -0
  341. package/esm/compact.js +4 -0
  342. package/esm/configLoader.js +61 -0
  343. package/esm/controlledQueue.js +38 -0
  344. package/esm/convertImageURL.js +15 -0
  345. package/esm/dataLoader.js +192 -0
  346. package/esm/defaultVariant.js +25 -0
  347. package/esm/effector/clearOnChangeAfterDelay.js +13 -0
  348. package/esm/effector/combineEvery.js +4 -0
  349. package/esm/effector/combineSome.js +4 -0
  350. package/esm/effector/debounced.js +14 -0
  351. package/esm/effector/form.js +166 -0
  352. package/esm/effector/hideOnChangeAfterDelay.js +13 -0
  353. package/esm/effector/requestResponse.js +24 -0
  354. package/esm/effector/requestResponseMulti.js +47 -0
  355. package/esm/effector/restoreNamed.js +4 -0
  356. package/esm/effector/split.js +25 -0
  357. package/esm/effector/validator.js +28 -0
  358. package/esm/effector/wrapSignInRequired.js +9 -0
  359. package/esm/exceptions.js +2 -0
  360. package/esm/fetchAllItems.js +44 -0
  361. package/esm/file.js +67 -0
  362. package/esm/fileWebsocket.js +75 -0
  363. package/esm/filterFunc.js +43 -0
  364. package/esm/filterFuncBrand.js +9 -0
  365. package/esm/filterFuncCategory.js +9 -0
  366. package/esm/filterFuncContentBlock.js +16 -0
  367. package/esm/filterFuncCustomer.js +153 -0
  368. package/esm/filterFuncDataFeed.js +50 -0
  369. package/esm/filterFuncOrder.js +325 -0
  370. package/esm/filterFuncPreprocess.js +9 -0
  371. package/esm/filterFuncProduct.js +66 -0
  372. package/esm/filterFuncPurchaseOrder.js +122 -0
  373. package/esm/filterFuncSupplier.js +31 -0
  374. package/esm/filterFuncTransfer.js +130 -0
  375. package/esm/formatAbbrevNumber.js +16 -0
  376. package/esm/formatCurrency.js +42 -0
  377. package/esm/formatToJSX.js +118 -0
  378. package/esm/fulfillmentNumber.js +3 -0
  379. package/esm/generateRandomToken.js +8 -0
  380. package/esm/generateUUID.js +6 -0
  381. package/esm/generated/codes.js +44 -0
  382. package/esm/genericFile.js +65 -0
  383. package/esm/getSalesChannelID.js +9 -0
  384. package/esm/getSessionID.js +9 -0
  385. package/esm/getTimezone.js +8 -0
  386. package/esm/graphql/fragments/Branding.js +1 -0
  387. package/esm/graphql/fragments/BrandingField.js +1 -0
  388. package/esm/graphql/fragments/CartCustomItem.js +1 -0
  389. package/esm/graphql/fragments/CartOrder.js +1 -0
  390. package/esm/graphql/fragments/CartVariant.js +1 -0
  391. package/esm/graphql/fragments/CartVariantFull.js +1 -0
  392. package/esm/graphql/fragments/Category.js +1 -0
  393. package/esm/graphql/fragments/CommonCartVariant.js +1 -0
  394. package/esm/graphql/fragments/Currency.js +1 -0
  395. package/esm/graphql/fragments/CurrencyPrice.js +1 -0
  396. package/esm/graphql/fragments/CustomField.js +1 -0
  397. package/esm/graphql/fragments/CustomFieldObjects.js +1 -0
  398. package/esm/graphql/fragments/Customer.js +1 -0
  399. package/esm/graphql/fragments/CustomerBalance.js +1 -0
  400. package/esm/graphql/fragments/CustomerBalanceHistory.js +1 -0
  401. package/esm/graphql/fragments/CustomerFavorite.js +1 -0
  402. package/esm/graphql/fragments/CustomerFavoriteShort.js +1 -0
  403. package/esm/graphql/fragments/CustomerOAuthProvider.js +1 -0
  404. package/esm/graphql/fragments/CustomerOrderBrief.js +1 -0
  405. package/esm/graphql/fragments/CustomerOrderFulfillment.js +1 -0
  406. package/esm/graphql/fragments/CustomerOrderFull.js +1 -0
  407. package/esm/graphql/fragments/CustomerPaymentSource.js +1 -0
  408. package/esm/graphql/fragments/CustomerReturnBrief.js +1 -0
  409. package/esm/graphql/fragments/CustomerReturnFull.js +1 -0
  410. package/esm/graphql/fragments/CustomerReturnPolicy.js +1 -0
  411. package/esm/graphql/fragments/CustomerSubscriptionBrief.js +1 -0
  412. package/esm/graphql/fragments/CustomerSubscriptionFull.js +1 -0
  413. package/esm/graphql/fragments/File.js +1 -0
  414. package/esm/graphql/fragments/FileForUpload.js +1 -0
  415. package/esm/graphql/fragments/FileNoFallback.js +1 -0
  416. package/esm/graphql/fragments/FullAddress.js +1 -0
  417. package/esm/graphql/fragments/Gateway.js +1 -0
  418. package/esm/graphql/fragments/GatewayManual.js +1 -0
  419. package/esm/graphql/fragments/GatewayPaypal.js +1 -0
  420. package/esm/graphql/fragments/GatewayStripe.js +1 -0
  421. package/esm/graphql/fragments/GatewayTest.js +1 -0
  422. package/esm/graphql/fragments/IPAndUAInfo.js +1 -0
  423. package/esm/graphql/fragments/InfoCountry.js +1 -0
  424. package/esm/graphql/fragments/InfoCountryDedupField.js +1 -0
  425. package/esm/graphql/fragments/InfoCurrency.js +1 -0
  426. package/esm/graphql/fragments/InfoProvince.js +1 -0
  427. package/esm/graphql/fragments/KeyValue.js +1 -0
  428. package/esm/graphql/fragments/LineItemField.js +1 -0
  429. package/esm/graphql/fragments/MediaFile.js +1 -0
  430. package/esm/graphql/fragments/MinCurrencyPrice.js +1 -0
  431. package/esm/graphql/fragments/ProductField.js +1 -0
  432. package/esm/graphql/fragments/ProductFieldSet.js +1 -0
  433. package/esm/graphql/fragments/ProductFlat.js +1 -0
  434. package/esm/graphql/fragments/ProductQuestion.js +1 -0
  435. package/esm/graphql/fragments/ProductQuestionAnswer.js +1 -0
  436. package/esm/graphql/fragments/ProductQuestionPage.js +1 -0
  437. package/esm/graphql/fragments/ProductReview.js +1 -0
  438. package/esm/graphql/fragments/ProductReviewAnswer.js +1 -0
  439. package/esm/graphql/fragments/ProductReviewAverageScore.js +1 -0
  440. package/esm/graphql/fragments/ProductReviewPage.js +1 -0
  441. package/esm/graphql/fragments/ProductReviewScore.js +1 -0
  442. package/esm/graphql/fragments/ProductReviewSurveyAnswer.js +1 -0
  443. package/esm/graphql/fragments/ProductSearchOptionAgg.js +1 -0
  444. package/esm/graphql/fragments/ProductSearchResult.js +1 -0
  445. package/esm/graphql/fragments/ReturnReason.js +1 -0
  446. package/esm/graphql/fragments/ReviewDimension.js +1 -0
  447. package/esm/graphql/fragments/ReviewDimensionSet.js +1 -0
  448. package/esm/graphql/fragments/ReviewImagePage.js +1 -0
  449. package/esm/graphql/fragments/ReviewQuestionProduct.js +1 -0
  450. package/esm/graphql/fragments/ReviewSettings.js +1 -0
  451. package/esm/graphql/fragments/SearchProduct.js +1 -0
  452. package/esm/graphql/fragments/Shop.js +1 -0
  453. package/esm/graphql/fragments/SubscriptionPlan.js +1 -0
  454. package/esm/graphql/fragments/SurveyQuestion.js +1 -0
  455. package/esm/graphql/fragments/TieredPricing.js +1 -0
  456. package/esm/graphql/fragments/TieredPricingTier.js +1 -0
  457. package/esm/graphql/fragments/VariantOption.js +1 -0
  458. package/esm/graphql/operations/ApplyGiftCardMutation.js +1 -0
  459. package/esm/graphql/operations/AuthRequestMutation.js +1 -0
  460. package/esm/graphql/operations/CancelOrderMutation.js +1 -0
  461. package/esm/graphql/operations/CancelSubscriptionMutation.js +1 -0
  462. package/esm/graphql/operations/ConnectOAuth2Mutation.js +1 -0
  463. package/esm/graphql/operations/CreateCartMutation.js +23 -0
  464. package/esm/graphql/operations/CreateFavoriteMutation.js +19 -0
  465. package/esm/graphql/operations/CreateFileMutation.js +3 -0
  466. package/esm/graphql/operations/CreatePaymentSourceMutation.js +3 -0
  467. package/esm/graphql/operations/CreateProductQuestionAnswerMutation.js +1 -0
  468. package/esm/graphql/operations/CreateProductQuestionMutation.js +5 -0
  469. package/esm/graphql/operations/CreateProductReviewMutation.js +15 -0
  470. package/esm/graphql/operations/CreateReturnMutation.js +19 -0
  471. package/esm/graphql/operations/DeleteFavoriteMutation.js +1 -0
  472. package/esm/graphql/operations/DeletePaymentSourceMutation.js +1 -0
  473. package/esm/graphql/operations/DeleteProductQuestionAnswerMutation.js +1 -0
  474. package/esm/graphql/operations/DeleteProductQuestionMutation.js +1 -0
  475. package/esm/graphql/operations/DeleteProductReviewMutation.js +1 -0
  476. package/esm/graphql/operations/DisconnectOAuth2Mutation.js +1 -0
  477. package/esm/graphql/operations/EditSubscriptionMutation.js +1 -0
  478. package/esm/graphql/operations/FileUploadedMutation.js +3 -0
  479. package/esm/graphql/operations/FlagQuestionAnswerMutation.js +1 -0
  480. package/esm/graphql/operations/FlagQuestionMutation.js +1 -0
  481. package/esm/graphql/operations/FlagReviewAnswerMutation.js +1 -0
  482. package/esm/graphql/operations/FlagReviewMutation.js +1 -0
  483. package/esm/graphql/operations/GetBrandingQuery.js +7 -0
  484. package/esm/graphql/operations/GetCartQuery.js +23 -0
  485. package/esm/graphql/operations/GetCustomerAddressesPageDataQuery.js +13 -0
  486. package/esm/graphql/operations/GetCustomerBalanceHistoryPageQuery.js +3 -0
  487. package/esm/graphql/operations/GetCustomerBalanceQuery.js +5 -0
  488. package/esm/graphql/operations/GetCustomerInfoQuery.js +7 -0
  489. package/esm/graphql/operations/GetCustomerQuery.js +5 -0
  490. package/esm/graphql/operations/GetFavoritesQuery.js +19 -0
  491. package/esm/graphql/operations/GetFileStatusQuery.js +3 -0
  492. package/esm/graphql/operations/GetGatewaysQuery.js +11 -0
  493. package/esm/graphql/operations/GetInfoCurrenciesQuery.js +3 -0
  494. package/esm/graphql/operations/GetLastCartQuery.js +23 -0
  495. package/esm/graphql/operations/GetOrderQuery.js +27 -0
  496. package/esm/graphql/operations/GetOrdersPageQuery.js +21 -0
  497. package/esm/graphql/operations/GetPaymentMethodsPageDataQuery.js +15 -0
  498. package/esm/graphql/operations/GetProductQuestionsPageQuery.js +7 -0
  499. package/esm/graphql/operations/GetProductReviewImagesPageQuery.js +5 -0
  500. package/esm/graphql/operations/GetProductReviewsPageQuery.js +17 -0
  501. package/esm/graphql/operations/GetProvincesQuery.js +3 -0
  502. package/esm/graphql/operations/GetQuestionQuery.js +5 -0
  503. package/esm/graphql/operations/GetReturnCreationInfoQuery.js +33 -0
  504. package/esm/graphql/operations/GetReturnQuery.js +25 -0
  505. package/esm/graphql/operations/GetReturnsPageQuery.js +19 -0
  506. package/esm/graphql/operations/GetReviewDimensionsQuery.js +3 -0
  507. package/esm/graphql/operations/GetReviewQuery.js +15 -0
  508. package/esm/graphql/operations/GetReviewSettingsQuery.js +9 -0
  509. package/esm/graphql/operations/GetShopCurrenciesQuery.js +3 -0
  510. package/esm/graphql/operations/GetShopQuery.js +5 -0
  511. package/esm/graphql/operations/GetSubscriptionQuery.js +33 -0
  512. package/esm/graphql/operations/GetSubscriptionsPageQuery.js +19 -0
  513. package/esm/graphql/operations/GetVariantPageQuery.js +17 -0
  514. package/esm/graphql/operations/LoadProductNoCustomerQuery.js +59 -0
  515. package/esm/graphql/operations/LoadProductQuery.js +63 -0
  516. package/esm/graphql/operations/ModifyCartMutation.js +23 -0
  517. package/esm/graphql/operations/ModifyCustomerMutation.js +5 -0
  518. package/esm/graphql/operations/ModifyFavoriteMutation.js +19 -0
  519. package/esm/graphql/operations/ModifyProductQuestionAnswerMutation.js +1 -0
  520. package/esm/graphql/operations/ModifyProductQuestionMutation.js +5 -0
  521. package/esm/graphql/operations/ModifyProductReviewMutation.js +15 -0
  522. package/esm/graphql/operations/NewPasswordMutation.js +1 -0
  523. package/esm/graphql/operations/PauseSubscriptionMutation.js +1 -0
  524. package/esm/graphql/operations/ResetPasswordMutation.js +1 -0
  525. package/esm/graphql/operations/ResumeSubscriptionMutation.js +1 -0
  526. package/esm/graphql/operations/SearchProductsAdvancedQuery.js +21 -0
  527. package/esm/graphql/operations/SearchProductsQuery.js +17 -0
  528. package/esm/graphql/operations/SearchQuestionsQuery.js +5 -0
  529. package/esm/graphql/operations/SearchReviewsQuery.js +15 -0
  530. package/esm/graphql/operations/SignInMutation.js +1 -0
  531. package/esm/graphql/operations/SignInViaEmailCompleteMutation.js +1 -0
  532. package/esm/graphql/operations/SignInViaEmailInitMutation.js +1 -0
  533. package/esm/graphql/operations/SignUpMutation.js +1 -0
  534. package/esm/graphql/operations/SkipNextSubscriptionMutation.js +1 -0
  535. package/esm/graphql/operations/UploadFileMutation.js +1 -0
  536. package/esm/graphql/operations/VerifyCodeMutation.js +1 -0
  537. package/esm/graphql/operations/VoteQuestionAnswerMutation.js +1 -0
  538. package/esm/graphql/operations/VoteQuestionMutation.js +1 -0
  539. package/esm/graphql/operations/VoteReviewAnswerMutation.js +1 -0
  540. package/esm/graphql/operations/VoteReviewMutation.js +1 -0
  541. package/esm/graphql/types.js +1 -0
  542. package/esm/hierarchicalSearchOption.js +43 -0
  543. package/esm/idgen.js +4 -0
  544. package/esm/ignoreQueue.js +45 -0
  545. package/esm/imageAltProps.js +9 -0
  546. package/esm/invoiceFormat.js +54 -0
  547. package/esm/isShippingRequired.js +16 -0
  548. package/esm/isoStripTrailingZeros.js +3 -0
  549. package/esm/json/commerce.js +3 -0
  550. package/esm/json/commerceFileUpload.js +43 -0
  551. package/esm/json/commerceTypes.js +1 -0
  552. package/esm/json/common.js +309 -0
  553. package/esm/json/fetchAllItems.js +51 -0
  554. package/esm/json/mutator.js +952 -0
  555. package/esm/json/storefront.js +3 -0
  556. package/esm/json/storefrontTypes.js +1 -0
  557. package/esm/lastValue.js +12 -0
  558. package/esm/lineItemPrice.js +106 -0
  559. package/esm/loadJWT.js +20 -0
  560. package/esm/mapInvalidInput.js +27 -0
  561. package/esm/mapResponseData.js +11 -0
  562. package/esm/mapResponseMultiData.js +10 -0
  563. package/esm/meanBy.js +11 -0
  564. package/esm/media.js +12 -0
  565. package/esm/modules/advancedSearch.js +132 -0
  566. package/esm/modules/cart.js +699 -0
  567. package/esm/modules/config/defaultAdvancedSearchGraphQLConfig.js +4 -0
  568. package/esm/modules/config/defaultCartGraphQLConfig.js +10 -0
  569. package/esm/modules/config/defaultProductGraphQLConfig.js +44 -0
  570. package/esm/modules/config/defaultSearchGraphQLConfig.js +4 -0
  571. package/esm/modules/customer.js +2198 -0
  572. package/esm/modules/helpers/cartInitOption.js +18 -0
  573. package/esm/modules/helpers/cookieConsent.js +29 -0
  574. package/esm/modules/helpers/customerOauth2.js +53 -0
  575. package/esm/modules/helpers/getOAuth2Hook.js +48 -0
  576. package/esm/modules/helpers/hookUpAnalytics.js +44 -0
  577. package/esm/modules/helpers/loadJWT.js +18 -0
  578. package/esm/modules/helpers/misc.js +49 -0
  579. package/esm/modules/imageDialog.js +71 -0
  580. package/esm/modules/persist.js +49 -0
  581. package/esm/modules/popupMessage.js +17 -0
  582. package/esm/modules/product.js +1278 -0
  583. package/esm/modules/recentlyVisitedProducts.js +70 -0
  584. package/esm/modules/search.js +103 -0
  585. package/esm/multiResponseToResponse.js +18 -0
  586. package/esm/nonNull.js +6 -0
  587. package/esm/oauthState.js +35 -0
  588. package/esm/orderShippingAddress.js +3 -0
  589. package/esm/package.json +3 -0
  590. package/esm/pender.js +11 -0
  591. package/esm/percentageOff.js +3 -0
  592. package/esm/popupConnectQueue.js +55 -0
  593. package/esm/preact/components/SixDigitInput.js +159 -0
  594. package/esm/preact/effector.js +69 -0
  595. package/esm/preact/transition/CSSTransition.js +47 -0
  596. package/esm/preact/transition/Transition.js +100 -0
  597. package/esm/preact/translateLocalStatic.js +26 -0
  598. package/esm/productFiltering.js +164 -0
  599. package/esm/productSEO.js +46 -0
  600. package/esm/productSorting.js +89 -0
  601. package/esm/promiseAll.js +11 -0
  602. package/esm/promiseLimit.js +32 -0
  603. package/esm/rdsToInitialScores.js +27 -0
  604. package/esm/react/components/Portal.js +2 -0
  605. package/esm/react/components/RootCloseWrapper.js +33 -0
  606. package/esm/react/components/SixDigitInput.js +158 -0
  607. package/esm/react/contains.js +10 -0
  608. package/esm/react/popperBinder.js +71 -0
  609. package/esm/react/rootClose.js +106 -0
  610. package/esm/react/translateLocalStatic.js +26 -0
  611. package/esm/react/useAsyncCachedValue.js +10 -0
  612. package/esm/refreshTimeout.js +21 -0
  613. package/esm/remoteAuth.js +52 -0
  614. package/esm/request.js +323 -0
  615. package/esm/requestDetails.js +69 -0
  616. package/esm/rfc3339Normalize.js +6 -0
  617. package/esm/script.js +157 -0
  618. package/esm/seo.js +1 -0
  619. package/esm/shopDomain.js +4 -0
  620. package/esm/shopLinks.js +47 -0
  621. package/esm/slate.js +364 -0
  622. package/esm/sleep.js +3 -0
  623. package/esm/splitBy.js +17 -0
  624. package/esm/splitName.js +22 -0
  625. package/esm/stripZeros.js +9 -0
  626. package/esm/stripeError.js +53 -0
  627. package/esm/tailSplit.js +8 -0
  628. package/esm/tieredPrice.js +28 -0
  629. package/esm/timeIt.js +8 -0
  630. package/esm/toMajor.js +4 -0
  631. package/esm/toMinor.js +4 -0
  632. package/esm/trace.js +37 -0
  633. package/esm/translateLocale.js +7 -0
  634. package/esm/traverse.js +10 -0
  635. package/esm/truncate.js +17 -0
  636. package/esm/typedLocalStorage.js +24 -0
  637. package/esm/variantImage.js +22 -0
  638. package/esm/variantImageURL.js +9 -0
  639. package/esm/variantImages.js +15 -0
  640. package/esm/variantInventory.js +38 -0
  641. package/esm/variantOptions.js +15 -0
  642. package/esm/variantPrice.js +92 -0
  643. package/esm/variantPriceCommerce.js +25 -0
  644. package/esm/variantTitle.js +5 -0
  645. package/esm/variantTitleFull.js +7 -0
  646. package/esm/variantURL.js +5 -0
  647. package/esm/vendor/popper/index.d.ts +160 -0
  648. package/esm/vendor/popper/index.js +2657 -0
  649. package/esm/vendor/popper/index.js.map +1 -0
  650. package/esm/vendor/popper/package.json +3 -0
  651. package/esm/websocket.js +169 -0
  652. package/package.json +92 -0
  653. package/types/actionLock.d.ts +7 -0
  654. package/types/addEmptyListItem.d.ts +2 -0
  655. package/types/aggregateOptions.d.ts +33 -0
  656. package/types/analytics.d.ts +23 -0
  657. package/types/analyticsProductData.d.ts +38 -0
  658. package/types/arrayToDict.d.ts +2 -0
  659. package/types/asyncModuleWrapper.d.ts +13 -0
  660. package/types/averageReviewScore.d.ts +28 -0
  661. package/types/buildconfig.d.ts +13 -0
  662. package/types/cachedLoader.d.ts +10 -0
  663. package/types/canonicalVariantURL.d.ts +12 -0
  664. package/types/cartOperation.d.ts +28 -0
  665. package/types/categorySEO.d.ts +17 -0
  666. package/types/commonTypes.d.ts +10 -0
  667. package/types/compact.d.ts +1 -0
  668. package/types/configLoader.d.ts +53 -0
  669. package/types/controlledQueue.d.ts +17 -0
  670. package/types/convertImageURL.d.ts +9 -0
  671. package/types/dataLoader.d.ts +301 -0
  672. package/types/defaultVariant.d.ts +9 -0
  673. package/types/effector/clearOnChangeAfterDelay.d.ts +2 -0
  674. package/types/effector/combineEvery.d.ts +2 -0
  675. package/types/effector/combineSome.d.ts +2 -0
  676. package/types/effector/debounced.d.ts +2 -0
  677. package/types/effector/form.d.ts +74 -0
  678. package/types/effector/hideOnChangeAfterDelay.d.ts +6 -0
  679. package/types/effector/requestResponse.d.ts +9 -0
  680. package/types/effector/requestResponseMulti.d.ts +7 -0
  681. package/types/effector/restoreNamed.d.ts +2 -0
  682. package/types/effector/split.d.ts +7 -0
  683. package/types/effector/validator.d.ts +14 -0
  684. package/types/effector/wrapSignInRequired.d.ts +2 -0
  685. package/types/exceptions.d.ts +2 -0
  686. package/types/fetchAllItems.d.ts +25 -0
  687. package/types/file.d.ts +4 -0
  688. package/types/fileWebsocket.d.ts +6 -0
  689. package/types/filterFunc.d.ts +8 -0
  690. package/types/filterFuncBrand.d.ts +3 -0
  691. package/types/filterFuncCategory.d.ts +3 -0
  692. package/types/filterFuncContentBlock.d.ts +3 -0
  693. package/types/filterFuncCustomer.d.ts +3 -0
  694. package/types/filterFuncDataFeed.d.ts +8 -0
  695. package/types/filterFuncOrder.d.ts +3 -0
  696. package/types/filterFuncPreprocess.d.ts +2 -0
  697. package/types/filterFuncProduct.d.ts +3 -0
  698. package/types/filterFuncPurchaseOrder.d.ts +3 -0
  699. package/types/filterFuncSupplier.d.ts +3 -0
  700. package/types/filterFuncTransfer.d.ts +3 -0
  701. package/types/formatAbbrevNumber.d.ts +6 -0
  702. package/types/formatCurrency.d.ts +44 -0
  703. package/types/formatToJSX.d.ts +24 -0
  704. package/types/fulfillmentNumber.d.ts +1 -0
  705. package/types/generateRandomToken.d.ts +1 -0
  706. package/types/generateUUID.d.ts +1 -0
  707. package/types/generated/codes.d.ts +234 -0
  708. package/types/genericFile.d.ts +57 -0
  709. package/types/getSalesChannelID.d.ts +1 -0
  710. package/types/getSessionID.d.ts +1 -0
  711. package/types/getTimezone.d.ts +1 -0
  712. package/types/graphql/fragments/Branding.d.ts +2 -0
  713. package/types/graphql/fragments/BrandingField.d.ts +2 -0
  714. package/types/graphql/fragments/CartCustomItem.d.ts +2 -0
  715. package/types/graphql/fragments/CartOrder.d.ts +2 -0
  716. package/types/graphql/fragments/CartVariant.d.ts +2 -0
  717. package/types/graphql/fragments/CartVariantFull.d.ts +2 -0
  718. package/types/graphql/fragments/Category.d.ts +2 -0
  719. package/types/graphql/fragments/CommonCartVariant.d.ts +2 -0
  720. package/types/graphql/fragments/Currency.d.ts +2 -0
  721. package/types/graphql/fragments/CurrencyPrice.d.ts +2 -0
  722. package/types/graphql/fragments/CustomField.d.ts +2 -0
  723. package/types/graphql/fragments/CustomFieldObjects.d.ts +2 -0
  724. package/types/graphql/fragments/Customer.d.ts +2 -0
  725. package/types/graphql/fragments/CustomerBalance.d.ts +2 -0
  726. package/types/graphql/fragments/CustomerBalanceHistory.d.ts +2 -0
  727. package/types/graphql/fragments/CustomerFavorite.d.ts +2 -0
  728. package/types/graphql/fragments/CustomerFavoriteShort.d.ts +2 -0
  729. package/types/graphql/fragments/CustomerOAuthProvider.d.ts +2 -0
  730. package/types/graphql/fragments/CustomerOrderBrief.d.ts +2 -0
  731. package/types/graphql/fragments/CustomerOrderFulfillment.d.ts +2 -0
  732. package/types/graphql/fragments/CustomerOrderFull.d.ts +2 -0
  733. package/types/graphql/fragments/CustomerPaymentSource.d.ts +2 -0
  734. package/types/graphql/fragments/CustomerReturnBrief.d.ts +2 -0
  735. package/types/graphql/fragments/CustomerReturnFull.d.ts +2 -0
  736. package/types/graphql/fragments/CustomerReturnPolicy.d.ts +2 -0
  737. package/types/graphql/fragments/CustomerSubscriptionBrief.d.ts +2 -0
  738. package/types/graphql/fragments/CustomerSubscriptionFull.d.ts +2 -0
  739. package/types/graphql/fragments/File.d.ts +2 -0
  740. package/types/graphql/fragments/FileForUpload.d.ts +2 -0
  741. package/types/graphql/fragments/FileNoFallback.d.ts +2 -0
  742. package/types/graphql/fragments/FullAddress.d.ts +2 -0
  743. package/types/graphql/fragments/Gateway.d.ts +2 -0
  744. package/types/graphql/fragments/GatewayManual.d.ts +2 -0
  745. package/types/graphql/fragments/GatewayPaypal.d.ts +2 -0
  746. package/types/graphql/fragments/GatewayStripe.d.ts +2 -0
  747. package/types/graphql/fragments/GatewayTest.d.ts +2 -0
  748. package/types/graphql/fragments/IPAndUAInfo.d.ts +2 -0
  749. package/types/graphql/fragments/InfoCountry.d.ts +2 -0
  750. package/types/graphql/fragments/InfoCountryDedupField.d.ts +2 -0
  751. package/types/graphql/fragments/InfoCurrency.d.ts +2 -0
  752. package/types/graphql/fragments/InfoProvince.d.ts +2 -0
  753. package/types/graphql/fragments/KeyValue.d.ts +2 -0
  754. package/types/graphql/fragments/LineItemField.d.ts +2 -0
  755. package/types/graphql/fragments/MediaFile.d.ts +2 -0
  756. package/types/graphql/fragments/MinCurrencyPrice.d.ts +2 -0
  757. package/types/graphql/fragments/ProductField.d.ts +2 -0
  758. package/types/graphql/fragments/ProductFieldSet.d.ts +2 -0
  759. package/types/graphql/fragments/ProductFlat.d.ts +2 -0
  760. package/types/graphql/fragments/ProductQuestion.d.ts +2 -0
  761. package/types/graphql/fragments/ProductQuestionAnswer.d.ts +2 -0
  762. package/types/graphql/fragments/ProductQuestionPage.d.ts +2 -0
  763. package/types/graphql/fragments/ProductReview.d.ts +2 -0
  764. package/types/graphql/fragments/ProductReviewAnswer.d.ts +2 -0
  765. package/types/graphql/fragments/ProductReviewAverageScore.d.ts +2 -0
  766. package/types/graphql/fragments/ProductReviewPage.d.ts +2 -0
  767. package/types/graphql/fragments/ProductReviewScore.d.ts +2 -0
  768. package/types/graphql/fragments/ProductReviewSurveyAnswer.d.ts +2 -0
  769. package/types/graphql/fragments/ProductSearchOptionAgg.d.ts +2 -0
  770. package/types/graphql/fragments/ProductSearchResult.d.ts +2 -0
  771. package/types/graphql/fragments/ReturnReason.d.ts +2 -0
  772. package/types/graphql/fragments/ReviewDimension.d.ts +2 -0
  773. package/types/graphql/fragments/ReviewDimensionSet.d.ts +2 -0
  774. package/types/graphql/fragments/ReviewImagePage.d.ts +2 -0
  775. package/types/graphql/fragments/ReviewQuestionProduct.d.ts +2 -0
  776. package/types/graphql/fragments/ReviewSettings.d.ts +2 -0
  777. package/types/graphql/fragments/SearchProduct.d.ts +2 -0
  778. package/types/graphql/fragments/Shop.d.ts +2 -0
  779. package/types/graphql/fragments/SubscriptionPlan.d.ts +2 -0
  780. package/types/graphql/fragments/SurveyQuestion.d.ts +2 -0
  781. package/types/graphql/fragments/TieredPricing.d.ts +2 -0
  782. package/types/graphql/fragments/TieredPricingTier.d.ts +2 -0
  783. package/types/graphql/fragments/VariantOption.d.ts +2 -0
  784. package/types/graphql/operations/ApplyGiftCardMutation.d.ts +3 -0
  785. package/types/graphql/operations/AuthRequestMutation.d.ts +3 -0
  786. package/types/graphql/operations/CancelOrderMutation.d.ts +3 -0
  787. package/types/graphql/operations/CancelSubscriptionMutation.d.ts +3 -0
  788. package/types/graphql/operations/ConnectOAuth2Mutation.d.ts +3 -0
  789. package/types/graphql/operations/CreateCartMutation.d.ts +3 -0
  790. package/types/graphql/operations/CreateFavoriteMutation.d.ts +3 -0
  791. package/types/graphql/operations/CreateFileMutation.d.ts +3 -0
  792. package/types/graphql/operations/CreatePaymentSourceMutation.d.ts +3 -0
  793. package/types/graphql/operations/CreateProductQuestionAnswerMutation.d.ts +3 -0
  794. package/types/graphql/operations/CreateProductQuestionMutation.d.ts +3 -0
  795. package/types/graphql/operations/CreateProductReviewMutation.d.ts +3 -0
  796. package/types/graphql/operations/CreateReturnMutation.d.ts +3 -0
  797. package/types/graphql/operations/DeleteFavoriteMutation.d.ts +3 -0
  798. package/types/graphql/operations/DeletePaymentSourceMutation.d.ts +3 -0
  799. package/types/graphql/operations/DeleteProductQuestionAnswerMutation.d.ts +3 -0
  800. package/types/graphql/operations/DeleteProductQuestionMutation.d.ts +3 -0
  801. package/types/graphql/operations/DeleteProductReviewMutation.d.ts +3 -0
  802. package/types/graphql/operations/DisconnectOAuth2Mutation.d.ts +3 -0
  803. package/types/graphql/operations/EditSubscriptionMutation.d.ts +3 -0
  804. package/types/graphql/operations/FileUploadedMutation.d.ts +3 -0
  805. package/types/graphql/operations/FlagQuestionAnswerMutation.d.ts +3 -0
  806. package/types/graphql/operations/FlagQuestionMutation.d.ts +3 -0
  807. package/types/graphql/operations/FlagReviewAnswerMutation.d.ts +3 -0
  808. package/types/graphql/operations/FlagReviewMutation.d.ts +3 -0
  809. package/types/graphql/operations/GetBrandingQuery.d.ts +3 -0
  810. package/types/graphql/operations/GetCartQuery.d.ts +3 -0
  811. package/types/graphql/operations/GetCustomerAddressesPageDataQuery.d.ts +3 -0
  812. package/types/graphql/operations/GetCustomerBalanceHistoryPageQuery.d.ts +3 -0
  813. package/types/graphql/operations/GetCustomerBalanceQuery.d.ts +3 -0
  814. package/types/graphql/operations/GetCustomerInfoQuery.d.ts +3 -0
  815. package/types/graphql/operations/GetCustomerQuery.d.ts +3 -0
  816. package/types/graphql/operations/GetFavoritesQuery.d.ts +3 -0
  817. package/types/graphql/operations/GetFileStatusQuery.d.ts +3 -0
  818. package/types/graphql/operations/GetGatewaysQuery.d.ts +3 -0
  819. package/types/graphql/operations/GetInfoCurrenciesQuery.d.ts +3 -0
  820. package/types/graphql/operations/GetLastCartQuery.d.ts +3 -0
  821. package/types/graphql/operations/GetOrderQuery.d.ts +3 -0
  822. package/types/graphql/operations/GetOrdersPageQuery.d.ts +3 -0
  823. package/types/graphql/operations/GetPaymentMethodsPageDataQuery.d.ts +3 -0
  824. package/types/graphql/operations/GetProductQuestionsPageQuery.d.ts +3 -0
  825. package/types/graphql/operations/GetProductReviewImagesPageQuery.d.ts +3 -0
  826. package/types/graphql/operations/GetProductReviewsPageQuery.d.ts +3 -0
  827. package/types/graphql/operations/GetProvincesQuery.d.ts +3 -0
  828. package/types/graphql/operations/GetQuestionQuery.d.ts +3 -0
  829. package/types/graphql/operations/GetReturnCreationInfoQuery.d.ts +3 -0
  830. package/types/graphql/operations/GetReturnQuery.d.ts +3 -0
  831. package/types/graphql/operations/GetReturnsPageQuery.d.ts +3 -0
  832. package/types/graphql/operations/GetReviewDimensionsQuery.d.ts +3 -0
  833. package/types/graphql/operations/GetReviewQuery.d.ts +3 -0
  834. package/types/graphql/operations/GetReviewSettingsQuery.d.ts +3 -0
  835. package/types/graphql/operations/GetShopCurrenciesQuery.d.ts +3 -0
  836. package/types/graphql/operations/GetShopQuery.d.ts +3 -0
  837. package/types/graphql/operations/GetSubscriptionQuery.d.ts +3 -0
  838. package/types/graphql/operations/GetSubscriptionsPageQuery.d.ts +3 -0
  839. package/types/graphql/operations/GetVariantPageQuery.d.ts +3 -0
  840. package/types/graphql/operations/LoadProductNoCustomerQuery.d.ts +3 -0
  841. package/types/graphql/operations/LoadProductQuery.d.ts +3 -0
  842. package/types/graphql/operations/ModifyCartMutation.d.ts +3 -0
  843. package/types/graphql/operations/ModifyCustomerMutation.d.ts +3 -0
  844. package/types/graphql/operations/ModifyFavoriteMutation.d.ts +3 -0
  845. package/types/graphql/operations/ModifyProductQuestionAnswerMutation.d.ts +3 -0
  846. package/types/graphql/operations/ModifyProductQuestionMutation.d.ts +3 -0
  847. package/types/graphql/operations/ModifyProductReviewMutation.d.ts +3 -0
  848. package/types/graphql/operations/NewPasswordMutation.d.ts +3 -0
  849. package/types/graphql/operations/PauseSubscriptionMutation.d.ts +3 -0
  850. package/types/graphql/operations/ResetPasswordMutation.d.ts +3 -0
  851. package/types/graphql/operations/ResumeSubscriptionMutation.d.ts +3 -0
  852. package/types/graphql/operations/SearchProductsAdvancedQuery.d.ts +3 -0
  853. package/types/graphql/operations/SearchProductsQuery.d.ts +3 -0
  854. package/types/graphql/operations/SearchQuestionsQuery.d.ts +3 -0
  855. package/types/graphql/operations/SearchReviewsQuery.d.ts +3 -0
  856. package/types/graphql/operations/SignInMutation.d.ts +3 -0
  857. package/types/graphql/operations/SignInViaEmailCompleteMutation.d.ts +3 -0
  858. package/types/graphql/operations/SignInViaEmailInitMutation.d.ts +3 -0
  859. package/types/graphql/operations/SignUpMutation.d.ts +3 -0
  860. package/types/graphql/operations/SkipNextSubscriptionMutation.d.ts +3 -0
  861. package/types/graphql/operations/UploadFileMutation.d.ts +3 -0
  862. package/types/graphql/operations/VerifyCodeMutation.d.ts +3 -0
  863. package/types/graphql/operations/VoteQuestionAnswerMutation.d.ts +3 -0
  864. package/types/graphql/operations/VoteQuestionMutation.d.ts +3 -0
  865. package/types/graphql/operations/VoteReviewAnswerMutation.d.ts +3 -0
  866. package/types/graphql/operations/VoteReviewMutation.d.ts +3 -0
  867. package/types/graphql/types.d.ts +2471 -0
  868. package/types/hierarchicalSearchOption.d.ts +14 -0
  869. package/types/idgen.d.ts +1 -0
  870. package/types/ignoreQueue.d.ts +10 -0
  871. package/types/imageAltProps.d.ts +11 -0
  872. package/types/invoiceFormat.d.ts +32 -0
  873. package/types/isShippingRequired.d.ts +14 -0
  874. package/types/isoStripTrailingZeros.d.ts +1 -0
  875. package/types/json/commerce.d.ts +3 -0
  876. package/types/json/commerceFileUpload.d.ts +20 -0
  877. package/types/json/commerceTypes.d.ts +15422 -0
  878. package/types/json/common.d.ts +81 -0
  879. package/types/json/fetchAllItems.d.ts +15 -0
  880. package/types/json/mutator.d.ts +238 -0
  881. package/types/json/storefront.d.ts +3 -0
  882. package/types/json/storefrontTypes.d.ts +5059 -0
  883. package/types/lastValue.d.ts +10 -0
  884. package/types/lineItemPrice.d.ts +18 -0
  885. package/types/loadJWT.d.ts +1 -0
  886. package/types/mapInvalidInput.d.ts +15 -0
  887. package/types/mapResponseData.d.ts +3 -0
  888. package/types/mapResponseMultiData.d.ts +2 -0
  889. package/types/meanBy.d.ts +1 -0
  890. package/types/media.d.ts +3 -0
  891. package/types/modules/advancedSearch.d.ts +78 -0
  892. package/types/modules/cart.d.ts +263 -0
  893. package/types/modules/config/defaultAdvancedSearchGraphQLConfig.d.ts +3 -0
  894. package/types/modules/config/defaultCartGraphQLConfig.d.ts +6 -0
  895. package/types/modules/config/defaultProductGraphQLConfig.d.ts +23 -0
  896. package/types/modules/config/defaultSearchGraphQLConfig.d.ts +3 -0
  897. package/types/modules/customer.d.ts +624 -0
  898. package/types/modules/helpers/cartInitOption.d.ts +2 -0
  899. package/types/modules/helpers/cookieConsent.d.ts +4 -0
  900. package/types/modules/helpers/customerOauth2.d.ts +19 -0
  901. package/types/modules/helpers/getOAuth2Hook.d.ts +22 -0
  902. package/types/modules/helpers/hookUpAnalytics.d.ts +21 -0
  903. package/types/modules/helpers/loadJWT.d.ts +1 -0
  904. package/types/modules/helpers/misc.d.ts +14 -0
  905. package/types/modules/imageDialog.d.ts +31 -0
  906. package/types/modules/persist.d.ts +13 -0
  907. package/types/modules/popupMessage.d.ts +9 -0
  908. package/types/modules/product.d.ts +320 -0
  909. package/types/modules/recentlyVisitedProducts.d.ts +25 -0
  910. package/types/modules/search.d.ts +54 -0
  911. package/types/multiResponseToResponse.d.ts +2 -0
  912. package/types/nonNull.d.ts +1 -0
  913. package/types/oauthState.d.ts +3 -0
  914. package/types/orderShippingAddress.d.ts +6 -0
  915. package/types/pender.d.ts +5 -0
  916. package/types/percentageOff.d.ts +1 -0
  917. package/types/popupConnectQueue.d.ts +41 -0
  918. package/types/preact/components/SixDigitInput.d.ts +28 -0
  919. package/types/preact/effector.d.ts +8 -0
  920. package/types/preact/transition/CSSTransition.d.ts +8 -0
  921. package/types/preact/transition/Transition.d.ts +30 -0
  922. package/types/preact/translateLocalStatic.d.ts +4 -0
  923. package/types/productFiltering.d.ts +58 -0
  924. package/types/productSEO.d.ts +59 -0
  925. package/types/productSorting.d.ts +35 -0
  926. package/types/promiseAll.d.ts +5 -0
  927. package/types/promiseLimit.d.ts +13 -0
  928. package/types/rdsToInitialScores.d.ts +26 -0
  929. package/types/react/components/Portal.d.ts +2 -0
  930. package/types/react/components/RootCloseWrapper.d.ts +18 -0
  931. package/types/react/components/SixDigitInput.d.ts +27 -0
  932. package/types/react/contains.d.ts +1 -0
  933. package/types/react/popperBinder.d.ts +23 -0
  934. package/types/react/rootClose.d.ts +18 -0
  935. package/types/react/translateLocalStatic.d.ts +4 -0
  936. package/types/react/useAsyncCachedValue.d.ts +2 -0
  937. package/types/refreshTimeout.d.ts +5 -0
  938. package/types/remoteAuth.d.ts +14 -0
  939. package/types/request.d.ts +104 -0
  940. package/types/requestDetails.d.ts +16 -0
  941. package/types/rfc3339Normalize.d.ts +1 -0
  942. package/types/script.d.ts +36 -0
  943. package/types/seo.d.ts +5 -0
  944. package/types/shopDomain.d.ts +7 -0
  945. package/types/shopLinks.d.ts +14 -0
  946. package/types/slate.d.ts +47 -0
  947. package/types/sleep.d.ts +1 -0
  948. package/types/splitBy.d.ts +1 -0
  949. package/types/splitName.d.ts +2 -0
  950. package/types/stripZeros.d.ts +1 -0
  951. package/types/stripeError.d.ts +14 -0
  952. package/types/tailSplit.d.ts +1 -0
  953. package/types/tieredPrice.d.ts +2 -0
  954. package/types/timeIt.d.ts +1 -0
  955. package/types/toMajor.d.ts +8 -0
  956. package/types/toMinor.d.ts +8 -0
  957. package/types/trace.d.ts +17 -0
  958. package/types/translateLocale.d.ts +2 -0
  959. package/types/traverse.d.ts +1 -0
  960. package/types/truncate.d.ts +7 -0
  961. package/types/typedLocalStorage.d.ts +3 -0
  962. package/types/variantImage.d.ts +16 -0
  963. package/types/variantImageURL.d.ts +25 -0
  964. package/types/variantImages.d.ts +11 -0
  965. package/types/variantInventory.d.ts +14 -0
  966. package/types/variantOptions.d.ts +18 -0
  967. package/types/variantPrice.d.ts +37 -0
  968. package/types/variantPriceCommerce.d.ts +26 -0
  969. package/types/variantTitle.d.ts +7 -0
  970. package/types/variantTitleFull.d.ts +11 -0
  971. package/types/variantURL.d.ts +7 -0
  972. package/types/websocket.d.ts +33 -0
@@ -0,0 +1,952 @@
1
+ import { CommerceFileUploadAPI } from "./commerceFileUpload.js";
2
+ import { request } from "./commerce.js";
3
+ import { PromiseLimiter } from "../promiseLimit.js";
4
+ import { uploadFileGeneric } from "../genericFile.js";
5
+ import { generateUUID } from "../generateUUID.js";
6
+ import { trace } from "..//trace.js";
7
+ import { traverse } from "../traverse.js";
8
+ import { uploadFileWebsocket } from "../fileWebsocket.js";
9
+ function isUnresolvedID(id) {
10
+ return id.startsWith(":TMPID:");
11
+ }
12
+ function unID(kind) {
13
+ return `:TMPID:${kind}:${generateUUID()}`;
14
+ }
15
+ function extractUniqueUnresolvedIDs(obj) {
16
+ const allIDs = new Set();
17
+ traverse(obj, (_obj, _prop, value) => {
18
+ if (typeof value === "string" && isUnresolvedID(value)) {
19
+ allIDs.add(value);
20
+ }
21
+ });
22
+ return Array.from(allIDs.keys());
23
+ }
24
+ export class NullLogger {
25
+ line() { }
26
+ bar() {
27
+ return { start: () => { }, stop: () => { }, increment: () => { } };
28
+ }
29
+ tree() { }
30
+ }
31
+ function collectNextBatch(resolvedItems, queue) {
32
+ const out = {
33
+ collected: [],
34
+ remaining: [],
35
+ };
36
+ for (const q of queue) {
37
+ if (q.items.length === 0)
38
+ continue;
39
+ const itemsReady = q.items.map((item) => item.deps.every((dep) => resolvedItems.has(dep)));
40
+ const itemsReadyCount = itemsReady.reduce((count, b) => count + (b ? 1 : 0), 0);
41
+ if (itemsReadyCount === q.items.length) {
42
+ out.collected.push(q);
43
+ }
44
+ else if (itemsReadyCount > 0) {
45
+ // split batch
46
+ out.collected.push(q.extractItems((_item, idx) => itemsReady[idx]));
47
+ out.remaining.push(q);
48
+ }
49
+ else {
50
+ out.remaining.push(q);
51
+ }
52
+ }
53
+ return out;
54
+ }
55
+ function normalizeName(name) {
56
+ if (typeof name === "string") {
57
+ return { singular: name, plural: name };
58
+ }
59
+ else {
60
+ return name;
61
+ }
62
+ }
63
+ function plur(v) {
64
+ return {
65
+ singular: v.replace("(s)", ""),
66
+ plural: v.replace("(s)", "s"),
67
+ };
68
+ }
69
+ function formatName(name, n) {
70
+ return n === 1 ? name.singular : name.plural;
71
+ }
72
+ //--------------------------------------------------------------------------------------------------------------------
73
+ //--------------------------------------------------------------------------------------------------------------------
74
+ //--------------------------------------------------------------------------------------------------------------------
75
+ function applyResolvedIDs(obj, resolvedIDs) {
76
+ traverse(obj, (obj, prop, value) => {
77
+ if (typeof value === "string" && isUnresolvedID(value)) {
78
+ const rid = resolvedIDs.get(value);
79
+ if (!rid)
80
+ throw new Error(`unresolved id: ${value}`);
81
+ obj[prop] = rid;
82
+ }
83
+ });
84
+ // important to do this after ID resolving
85
+ traverse(obj, (obj, prop, value) => {
86
+ if (value !== null && typeof value === "object" && value.__deferredJSONObject === true) {
87
+ obj[prop] = JSON.stringify(value.value);
88
+ }
89
+ });
90
+ }
91
+ function applyResolvedIDsToItems(items, resolvedIDs) {
92
+ for (const { item } of items) {
93
+ applyResolvedIDs(item, resolvedIDs);
94
+ }
95
+ }
96
+ // the type here is very evil, be sure to use this function only within the mutator context and for a specific need
97
+ // e.g. as custom_fields[].value
98
+ export function deferredJSONObject(value) {
99
+ return {
100
+ value,
101
+ __deferredJSONObject: true,
102
+ };
103
+ }
104
+ //--------------------------------------------------------------------------------------------------------------------
105
+ //--------------------------------------------------------------------------------------------------------------------
106
+ //--------------------------------------------------------------------------------------------------------------------
107
+ const jsonify = (v) => JSON.stringify(v, null, 2);
108
+ //--------------------------------------------------------------------------------------------------------------------
109
+ //--------------------------------------------------------------------------------------------------------------------
110
+ //--------------------------------------------------------------------------------------------------------------------
111
+ function chunk(input, size) {
112
+ return input.reduce((arr, item, idx) => {
113
+ return idx % size === 0 ? [...arr, [item]] : [...arr.slice(0, -1), [...arr.slice(-1)[0], item]];
114
+ }, []);
115
+ }
116
+ //--------------------------------------------------------------------------------------------------------------------
117
+ //--------------------------------------------------------------------------------------------------------------------
118
+ //--------------------------------------------------------------------------------------------------------------------
119
+ function itemByItemProcessor(name, resolveItem) {
120
+ const normalizedName = normalizeName(name);
121
+ return async (ectx, ctx, items, resolvedIDs) => {
122
+ const resolveItemImpl = async (item) => {
123
+ const result = await ectx.enqueue(normalizedName, 1, () => resolveItem(ctx, item));
124
+ if (result === null)
125
+ return [item.id, ""];
126
+ if (!result)
127
+ throw new Error(`unsuccessful API call\nitem: ${jsonify(item)}`);
128
+ if (Array.isArray(result)) {
129
+ if (result.length !== 1)
130
+ throw new Error(`unsuccessful API call\nitem: ${jsonify(item)}`);
131
+ return [item.id, result[0].id];
132
+ }
133
+ else {
134
+ return [item.id, result.id];
135
+ }
136
+ };
137
+ applyResolvedIDsToItems(items, resolvedIDs);
138
+ if (ectx.opts.sequential) {
139
+ const out = [];
140
+ for (const item of items) {
141
+ out.push(await resolveItemImpl(item));
142
+ }
143
+ return out;
144
+ }
145
+ else {
146
+ return Promise.all(items.map(resolveItemImpl));
147
+ }
148
+ };
149
+ }
150
+ function resultToIDMap(props, items, result) {
151
+ if (!result) {
152
+ throw new Error(`unsuccessful batch API call\nprops: ${jsonify(props)}\nitems: ${jsonify(items)}`);
153
+ }
154
+ if (items.length !== result.length) {
155
+ throw new Error(`mismatching number of items\nprops: ${jsonify(props)}\nitems: ${jsonify(items)}\nresult: ${jsonify(result)}`);
156
+ }
157
+ return items.map((item, idx) => [item.id, result[idx].id]);
158
+ }
159
+ function batchProcessor(name, perBatch, groupBy, resolveItems) {
160
+ const normalizedName = normalizeName(name);
161
+ return async (ectx, ctx, items, resolvedIDs) => {
162
+ applyResolvedIDsToItems(items, resolvedIDs);
163
+ // group items
164
+ const groupsMap = new Map();
165
+ for (const item of items) {
166
+ const key = groupBy(item.item);
167
+ let group = groupsMap.get(key);
168
+ if (!group) {
169
+ group = { props: item.item, items: [] };
170
+ groupsMap.set(key, group);
171
+ }
172
+ group.items.push(item);
173
+ }
174
+ const groups = Array.from(groupsMap.values());
175
+ let result = [];
176
+ if (ectx.opts.sequential) {
177
+ for (const { props, items } of groups) {
178
+ const r1 = [];
179
+ const batches = chunk(items, perBatch);
180
+ for (const items of batches) {
181
+ const result = await ectx.enqueue(normalizedName, items.length, () => resolveItems(ctx, props, items));
182
+ if (result === null)
183
+ return [];
184
+ r1.push(resultToIDMap(props, items, result));
185
+ }
186
+ result.push(r1);
187
+ }
188
+ }
189
+ else {
190
+ result = await Promise.all(groups.map(({ props, items }) => {
191
+ return Promise.all(chunk(items, perBatch).map(async (items) => {
192
+ const result = await ectx.enqueue(normalizedName, items.length, () => resolveItems(ctx, props, items));
193
+ if (result === null)
194
+ return [];
195
+ return resultToIDMap(props, items, result);
196
+ }));
197
+ }));
198
+ }
199
+ // flatten result
200
+ return result.reduce((a, b) => a.concat(b), []).reduce((a, b) => a.concat(b), []);
201
+ };
202
+ }
203
+ class StatsExecuteContext {
204
+ progressCallback;
205
+ stats;
206
+ opts;
207
+ limit;
208
+ constructor(name, opts, progressCallback) {
209
+ this.progressCallback = progressCallback;
210
+ this.opts = opts;
211
+ this.stats = { name, stats: new Map(), secondsElapsed: +new Date() };
212
+ this.limit = new PromiseLimiter(opts.sequential ? 1 : 20);
213
+ }
214
+ done() {
215
+ this.stats.secondsElapsed = (+new Date() - this.stats.secondsElapsed) / 1000;
216
+ }
217
+ async enqueue(name, quantity, f) {
218
+ const stats = this.stats.stats;
219
+ let s = stats.get(name);
220
+ if (!s) {
221
+ s = { apiCalls: 0, objects: 0, secondsElapsed: 0 };
222
+ stats.set(name, s);
223
+ }
224
+ const t0 = +new Date();
225
+ const result = await this.limit.run((tid) => {
226
+ return trace(tid, `${quantity} ${formatName(name, quantity)}`, () => f());
227
+ });
228
+ const t1 = +new Date();
229
+ s.secondsElapsed += (t1 - t0) / 1000;
230
+ s.apiCalls++;
231
+ s.objects += quantity;
232
+ this.progressCallback?.(quantity);
233
+ return result;
234
+ }
235
+ }
236
+ function batchShopIDAndReqCreator(batcher, name, desc, ep) {
237
+ return makeQueue(batcher, name, batchProcessor(desc, 30, (props) => props.shopID, (ctx, props, items) => {
238
+ return ep(ctx)
239
+ .shop_id(props.shopID)
240
+ .data(items.map((v) => v.item.req))
241
+ .sendUnwrap();
242
+ }), (q, shopID, req) => {
243
+ const uid = q.unID();
244
+ q.push(uid, { shopID, req });
245
+ return uid;
246
+ });
247
+ }
248
+ function batchShopIDAndReqModifier(batcher, name, desc, ep) {
249
+ return makeQueue(batcher, name, batchProcessor(desc, 30, (props) => props.shopID, (ctx, props, items) => {
250
+ return ep(ctx)
251
+ .ids(items.map((v) => v.item.id))
252
+ .data(items.map((v) => v.item.req))
253
+ .shop_id(props.shopID)
254
+ .sendUnwrap();
255
+ }), (q, shopID, id, req) => {
256
+ const uid = q.unID();
257
+ q.push(uid, { shopID, id, req });
258
+ });
259
+ }
260
+ function batchShopIDAndReqAndLocaleModifier(batcher, name, desc, ep) {
261
+ return makeQueue(batcher, name, batchProcessor(desc, 30, (props) => `${props.shopID}:${props.locale}`, (ctx, props, items) => {
262
+ const lctx = { ...ctx, locale: props.locale };
263
+ return ep(lctx)
264
+ .ids(items.map((v) => v.item.id))
265
+ .data(items.map((v) => v.item.req))
266
+ .shop_id(props.shopID)
267
+ .sendUnwrap();
268
+ }), (q, shopID, id, req, locale) => {
269
+ const uid = q.unID();
270
+ q.push(uid, { locale, shopID, id, req });
271
+ });
272
+ }
273
+ function batchShopIDAndIDDeletor(batcher, name, desc, ep) {
274
+ return makeQueue(batcher, name, batchProcessor(desc, 30, (props) => props.shopID, async (ctx, props, items) => {
275
+ await ep(ctx)
276
+ .ids(items.map((v) => v.id))
277
+ .shop_id(props.shopID)
278
+ .sendUnwrap();
279
+ return null;
280
+ }), (q, shopID, id) => {
281
+ const uid = q.unID();
282
+ q.push(uid, { shopID, id, req: null });
283
+ });
284
+ }
285
+ class GenericQueueItemCollection {
286
+ _name;
287
+ _processor;
288
+ _id;
289
+ _queue = [];
290
+ constructor(_name, _processor) {
291
+ this._name = _name;
292
+ this._processor = _processor;
293
+ this._id = generateUUID();
294
+ }
295
+ get id() {
296
+ return this._id;
297
+ }
298
+ get items() {
299
+ return this._queue;
300
+ }
301
+ get processor() {
302
+ return this._processor;
303
+ }
304
+ unID() {
305
+ return unID(this._name);
306
+ }
307
+ push(id, item) {
308
+ const deps = extractUniqueUnresolvedIDs(item);
309
+ this._queue.push({ id, deps, item });
310
+ }
311
+ extractItems(cond) {
312
+ const result = this._queue.reduce((accum, item, idx) => {
313
+ (cond(item, idx) ? accum.extracted : accum.remaining).push(item);
314
+ return accum;
315
+ }, { extracted: [], remaining: [] });
316
+ this._queue = result.remaining;
317
+ const c = new GenericQueueItemCollection(this._name, this._processor);
318
+ c._queue = result.extracted;
319
+ return c;
320
+ }
321
+ }
322
+ class Batch {
323
+ queues = new Map();
324
+ barrier;
325
+ get allQueues() {
326
+ const out = [];
327
+ this.queues.forEach((val) => {
328
+ out.push(val);
329
+ });
330
+ return out;
331
+ }
332
+ // Note that when processing multiple batches with cross batch dependencies (see barrier()), this
333
+ // function needs to be aware of previously resolved IDs, hence these are provided via argument.
334
+ topoSort(resolvedIDs) {
335
+ const out = [];
336
+ const resolvedItems = new Set(resolvedIDs);
337
+ let remaining = this.allQueues;
338
+ while (true) {
339
+ if (remaining.length === 0)
340
+ break;
341
+ const nextBatch = collectNextBatch(resolvedItems, remaining);
342
+ if (nextBatch.collected.length === 0) {
343
+ const items = [];
344
+ remaining.forEach((q) => {
345
+ q.items.forEach((item) => {
346
+ items.push(`${item.id}: ${item.deps.join(", ")}`);
347
+ });
348
+ });
349
+ throw new Error(`unable to resolve dependencies, remaining items:\n${items.join("\n")}`);
350
+ }
351
+ for (const q of nextBatch.collected) {
352
+ for (const item of q.items) {
353
+ resolvedItems.add(item.id);
354
+ }
355
+ }
356
+ out.push(nextBatch.collected);
357
+ remaining = nextBatch.remaining;
358
+ }
359
+ return out;
360
+ }
361
+ numberOfItems() {
362
+ let n = 0;
363
+ for (const q of this.allQueues) {
364
+ n += q.items.length;
365
+ }
366
+ return n;
367
+ }
368
+ }
369
+ function makeQueue(batcher, name, itemProcessor, f) {
370
+ return ((...args) => {
371
+ const b = batcher.currentBatch;
372
+ let q = b.queues.get(name);
373
+ if (!q) {
374
+ q = new GenericQueueItemCollection(name, itemProcessor);
375
+ b.queues.set(name, q);
376
+ }
377
+ return f(q, ...args);
378
+ });
379
+ }
380
+ export class Mutator {
381
+ batches = [new Batch()];
382
+ opts;
383
+ constructor(opts) {
384
+ this.opts = opts || {};
385
+ }
386
+ get currentBatch() {
387
+ const n = this.batches.length;
388
+ return this.batches[n - 1];
389
+ }
390
+ barrier(desc, data, func) {
391
+ if (desc && func) {
392
+ this.currentBatch.barrier = { desc, data, func };
393
+ }
394
+ this.batches.push(new Batch());
395
+ }
396
+ shop = makeQueue(this, "shop", itemByItemProcessor(plur("shop(s) created"), (ctx, { item }) => {
397
+ return request(ctx, `POST:shops.json`).data([item.req]).sendUnwrap();
398
+ }), (q, req) => {
399
+ const uid = q.unID();
400
+ q.push(uid, { req });
401
+ return uid;
402
+ });
403
+ shopModify = makeQueue(this, "shopModify", itemByItemProcessor(plur("shop(s) modified"), async (ctx, { item }) => {
404
+ await request(ctx, `POST:shops.json`).shop_id(item.shopID).data([item.req]).sendUnwrap();
405
+ return null;
406
+ }), (q, shopID, req) => {
407
+ const uid = q.unID();
408
+ q.push(uid, { shopID, req });
409
+ });
410
+ shopSettings = makeQueue(this, "shopSettings", itemByItemProcessor(plur("shop settings applied"), async (ctx, { item }) => {
411
+ await request(ctx, `POST:shops/settings.json`).shop_id(item.shopID).data(item.req).sendUnwrap();
412
+ return null;
413
+ }), (q, shopID, req) => {
414
+ const uid = q.unID();
415
+ q.push(uid, { shopID, req });
416
+ });
417
+ taxRule = batchShopIDAndReqCreator(this, "taxRule", plur("tax rule(s) created"), (ctx) => request(ctx, `POST:tax_rules.json`));
418
+ taxRuleModify = batchShopIDAndReqModifier(this, "taxRuleModify", plur("tax rule(s) modified"), (ctx) => request(ctx, `POST:tax_rules.json`));
419
+ taxRuleDelete = batchShopIDAndIDDeletor(this, "taxRuleDelete", plur("tax rule(s) deleted"), (ctx) => request(ctx, `DELETE:tax_rules.json`));
420
+ taxRulesAddDefault = makeQueue(this, "taxRulesAddDefault", itemByItemProcessor(plur("default tax rule(s) added"), async (ctx, { item }) => {
421
+ await request(ctx, `POST:tax_rules/add_default.json`).shop_id(item.shopID).country(item.country).sendUnwrap();
422
+ return null;
423
+ }), (q, shopID, country) => {
424
+ const uid = q.unID();
425
+ q.push(uid, { shopID, country, req: null });
426
+ });
427
+ returnReason = batchShopIDAndReqCreator(this, "returnReason", plur("return reason(s) created"), (ctx) => request(ctx, `POST:return_reasons.json`));
428
+ returnReasonModify = batchShopIDAndReqModifier(this, "returnReasonModify", plur("return reason(s) modified"), (ctx) => request(ctx, `POST:return_reasons.json`));
429
+ returnReasonDelete = batchShopIDAndIDDeletor(this, "returnReasonDelete", plur("return reason(s) deleted"), (ctx) => request(ctx, `DELETE:return_reasons.json`));
430
+ returnReasonsAddDefault = makeQueue(this, "returnReasonsAddDefault", itemByItemProcessor(plur("default return reason(s) added"), async (ctx, { item }) => {
431
+ await request(ctx, `POST:return_reasons/add_default.json`).shop_id(item.shopID).sendUnwrap();
432
+ return null;
433
+ }), (q, shopID) => {
434
+ const uid = q.unID();
435
+ q.push(uid, { shopID, req: null });
436
+ });
437
+ returnInspectionsAddDefault = makeQueue(this, "returnInspectionsAddDefault", itemByItemProcessor(plur("default return inspection(s) added"), async (ctx, { item }) => {
438
+ await request(ctx, `POST:return_inspections/add_default.json`).shop_id(item.shopID).sendUnwrap();
439
+ return null;
440
+ }), (q, shopID) => {
441
+ const uid = q.unID();
442
+ q.push(uid, { shopID, req: null });
443
+ });
444
+ inventoryLocation = batchShopIDAndReqCreator(this, "inventoryLocation", plur("inventory location(s) created"), (ctx) => request(ctx, `POST:inventory_locations.json`));
445
+ inventoryLocationModify = batchShopIDAndReqAndLocaleModifier(this, "inventoryLocationModify", plur("inventory location(s) modified"), (ctx) => request(ctx, `POST:inventory_locations.json`));
446
+ gateway = makeQueue(this, "gateway", itemByItemProcessor(plur("gateway(s) created"), (ctx, { item }) => {
447
+ return request(ctx, `POST:gateways.json`).shop_id(item.shopID).data([item.req]).sendUnwrap();
448
+ }), (q, shopID, req) => {
449
+ const uid = q.unID();
450
+ q.push(uid, { shopID, req });
451
+ return uid;
452
+ });
453
+ gatewayModify = makeQueue(this, "gatewayModify", itemByItemProcessor(plur("gateway(s) modified"), (ctx, { item }) => {
454
+ const lctx = { ...ctx, locale: item.locale };
455
+ return request(lctx, `POST:gateways.json`).ids([item.id]).shop_id(item.shopID).data([item.req]).sendUnwrap();
456
+ }), (q, shopID, id, req, locale) => {
457
+ const uid = q.unID();
458
+ q.push(uid, { locale, shopID, id, req });
459
+ });
460
+ gatewayDelete = makeQueue(this, "gatewayDelete", itemByItemProcessor(plur("gateway(s) deleted"), async (ctx, { item }) => {
461
+ await request(ctx, `DELETE:gateways.json`).ids([item.id]).shop_id(item.shopID).sendUnwrap();
462
+ return null;
463
+ }), (q, shopID, id) => {
464
+ const uid = q.unID();
465
+ q.push(uid, { shopID, id, req: null });
466
+ });
467
+ webhook = batchShopIDAndReqCreator(this, "webhook", plur("webhook(s) created"), (ctx) => request(ctx, `POST:webhooks.json`));
468
+ webhookModify = batchShopIDAndReqModifier(this, "webhookModify", plur("webhook(s) modified"), (ctx) => request(ctx, `POST:webhooks.json`));
469
+ webhookDelete = batchShopIDAndIDDeletor(this, "webhookDelete", plur("webhook(s) deleted"), (ctx) => request(ctx, `DELETE:webhooks.json`));
470
+ shippingProvider = batchShopIDAndReqCreator(this, "shippingProvider", plur("shipping provider(s) created"), (ctx) => request(ctx, `POST:shipping_providers.json`));
471
+ shippingProviderModify = batchShopIDAndReqAndLocaleModifier(this, "shippingProviderModify", plur("shipping provider(s) modified"), (ctx) => request(ctx, `POST:shipping_providers.json`));
472
+ shippingProviderDelete = batchShopIDAndIDDeletor(this, "shippingProviderDelete", plur("shipping provider(s) deleted"), (ctx) => request(ctx, `DELETE:shipping_providers.json`));
473
+ shippingRule = batchShopIDAndReqCreator(this, "shippingRule", plur("shipping rule(s) created"), (ctx) => request(ctx, `POST:shipping_rules.json`));
474
+ shippingRuleModify = batchShopIDAndReqModifier(this, "shippingRuleModify", plur("shipping rule(s) modified"), (ctx) => request(ctx, `POST:shipping_rules.json`));
475
+ shippingRuleDelete = batchShopIDAndIDDeletor(this, "shippingRuleDelete", plur("shipping rule(s) deleted"), (ctx) => request(ctx, `DELETE:shipping_rules.json`));
476
+ promotion = batchShopIDAndReqCreator(this, "promotion", plur("promotion(s) created"), (ctx) => request(ctx, `POST:promotions.json`));
477
+ promotionModify = batchShopIDAndReqModifier(this, "promotionModify", plur("promotion(s) modified"), (ctx) => request(ctx, `POST:promotions.json`));
478
+ promotionDelete = batchShopIDAndIDDeletor(this, "promotionDelete", plur("promotion(s) deleted"), (ctx) => request(ctx, `DELETE:promotions.json`));
479
+ coupon = makeQueue(this, "coupon", batchProcessor(plur("coupon(s) created"), 30, (props) => `${props.shopID}:${props.promotionID}`, (ctx, props, items) => {
480
+ return request(ctx, `POST:coupons.json`)
481
+ .shop_id(props.shopID)
482
+ .promotion_id(props.promotionID)
483
+ .data(items.map((v) => v.item.req))
484
+ .sendUnwrap();
485
+ }), (q, shopID, promotionID, req) => {
486
+ const uid = q.unID();
487
+ q.push(uid, { shopID, promotionID, req });
488
+ return uid;
489
+ });
490
+ couponDelete = batchShopIDAndIDDeletor(this, "couponDelete", plur("coupon(s) deleted"), (ctx) => request(ctx, `DELETE:coupons.json`));
491
+ domain = batchShopIDAndReqCreator(this, "domain", plur("domain(s) created"), (ctx) => request(ctx, `POST:domains.json`));
492
+ domainDelete = batchShopIDAndIDDeletor(this, "domainDelete", plur("domain(s) deleted"), (ctx) => request(ctx, `DELETE:domains.json`));
493
+ reviewDimension = batchShopIDAndReqCreator(this, "reviewDimension", plur("review dimension(s) created"), (ctx) => request(ctx, `POST:review_dimensions.json`));
494
+ reviewDimensionModify = batchShopIDAndReqAndLocaleModifier(this, "reviewDimensionModify", plur("review dimension(s) modified"), (ctx) => request(ctx, `POST:review_dimensions.json`));
495
+ reviewDimensionDelete = batchShopIDAndIDDeletor(this, "reviewDimensionDelete", plur("review dimension(s) deleted"), (ctx) => request(ctx, `DELETE:review_dimensions.json`));
496
+ reviewDimensionSet = batchShopIDAndReqCreator(this, "reviewDimensionSet", plur("review dimension set(s) created"), (ctx) => request(ctx, `POST:review_dimension_sets.json`));
497
+ reviewDimensionSetModify = batchShopIDAndReqModifier(this, "reviewDimensionSetModify", plur("review dimension set(s) modified"), (ctx) => request(ctx, `POST:review_dimension_sets.json`));
498
+ reviewDimensionSetDelete = batchShopIDAndIDDeletor(this, "reviewDimensionSetDelete", plur("review dimension set(s) deleted"), (ctx) => request(ctx, `DELETE:review_dimension_sets.json`));
499
+ customer = batchShopIDAndReqCreator(this, "customer", plur("customer(s) created"), (ctx) => request(ctx, `POST:customers.json`));
500
+ customerModify = batchShopIDAndReqModifier(this, "customerModify", plur("customer(s) modified"), (ctx) => request(ctx, `POST:customers.json`));
501
+ customerDelete = batchShopIDAndIDDeletor(this, "customerDelete", plur("customer(s) deleted"), (ctx) => request(ctx, `DELETE:customers.json`));
502
+ category = batchShopIDAndReqCreator(this, "category", { singular: "category created", plural: "categories created" }, (ctx) => request(ctx, `POST:categories.json`));
503
+ categoryModify = makeQueue(this, "categoryModify", itemByItemProcessor({ singular: "category modified", plural: "categories modified" }, (ctx, { item }) => {
504
+ const lctx = { ...ctx, locale: item.locale };
505
+ return request(lctx, `POST:categories.json`).ids([item.id]).shop_id(item.shopID).data([item.req]).sendUnwrap();
506
+ }), (q, shopID, id, req, locale) => {
507
+ const uid = q.unID();
508
+ q.push(uid, { locale, shopID, id, req });
509
+ });
510
+ categoryDelete = batchShopIDAndIDDeletor(this, "categoryDelete", { singular: "category deleted", plural: "categories deleted" }, (ctx) => request(ctx, `DELETE:categories.json`));
511
+ brand = batchShopIDAndReqCreator(this, "brand", plur("brand(s) created"), (ctx) => request(ctx, `POST:brands.json`));
512
+ brandModify = makeQueue(this, "brandModify", itemByItemProcessor(plur("brand(s) modified"), (ctx, { item }) => {
513
+ const lctx = { ...ctx, locale: item.locale };
514
+ return request(lctx, `POST:brands.json`).ids([item.id]).shop_id(item.shopID).data([item.req]).sendUnwrap();
515
+ }), (q, shopID, id, req, locale) => {
516
+ const uid = q.unID();
517
+ q.push(uid, { locale, shopID, id, req });
518
+ });
519
+ brandDelete = batchShopIDAndIDDeletor(this, "brandDelete", plur("brand(s) deleted"), (ctx) => request(ctx, `DELETE:brands.json`));
520
+ contentBlock = batchShopIDAndReqCreator(this, "contentBlock", plur("content block(s) created"), (ctx) => request(ctx, `POST:content_blocks.json`));
521
+ contentBlockModify = makeQueue(this, "contentBlockModify", itemByItemProcessor(plur("content block(s) modified"), (ctx, { item }) => {
522
+ const lctx = { ...ctx, locale: item.locale };
523
+ return request(lctx, `POST:content_blocks.json`)
524
+ .ids([item.id])
525
+ .shop_id(item.shopID)
526
+ .data([item.req])
527
+ .sendUnwrap();
528
+ }), (q, shopID, id, req, locale) => {
529
+ const uid = q.unID();
530
+ q.push(uid, { locale, shopID, id, req });
531
+ });
532
+ contentBlockDelete = batchShopIDAndIDDeletor(this, "contentBlockDelete", plur("content block(s) deleted"), (ctx) => request(ctx, `DELETE:content_blocks.json`));
533
+ contentModel = batchShopIDAndReqCreator(this, "contentModel", plur("content model(s) created"), (ctx) => request(ctx, `POST:content_models.json`));
534
+ contentModelModify = batchShopIDAndReqAndLocaleModifier(this, "contentModelModify", plur("content model(s) modified"), (ctx) => request(ctx, `POST:content_models.json`));
535
+ contentModelDelete = batchShopIDAndIDDeletor(this, "contentModelDelete", plur("content model(s) deleted"), (ctx) => request(ctx, `DELETE:content_models.json`));
536
+ menu = makeQueue(this, "menu", itemByItemProcessor(plur("menu(s) created"), (ctx, { item }) => {
537
+ return request(ctx, `POST:menus.json`).shop_id(item.shopID).data([item.req]).sendUnwrap();
538
+ }), (q, shopID, req) => {
539
+ const uid = q.unID();
540
+ q.push(uid, { shopID, req });
541
+ return uid;
542
+ });
543
+ menuModify = makeQueue(this, "menuModify", itemByItemProcessor(plur("menu(s) modified"), (ctx, { item }) => {
544
+ const lctx = { ...ctx, locale: item.locale };
545
+ return request(lctx, `POST:menus.json`).ids([item.id]).shop_id(item.shopID).data([item.req]).sendUnwrap();
546
+ }), (q, shopID, id, req, locale) => {
547
+ const uid = q.unID();
548
+ q.push(uid, { locale, shopID, id, req });
549
+ });
550
+ menuDelete = batchShopIDAndIDDeletor(this, "menuDelete", plur("menu(s) deleted"), (ctx) => request(ctx, `DELETE:menus.json`));
551
+ option = batchShopIDAndReqCreator(this, "option", plur("option(s) created"), (ctx) => request(ctx, `POST:options.json`));
552
+ optionModify = batchShopIDAndReqAndLocaleModifier(this, "optionModify", plur("option(s) modified"), (ctx) => request(ctx, `POST:options.json`));
553
+ optionDelete = batchShopIDAndIDDeletor(this, "optionDelete", plur("option(s) deleted"), (ctx) => request(ctx, `DELETE:options.json`));
554
+ surveyQuestion = batchShopIDAndReqCreator(this, "surveyQuestion", plur("survey question(s) created"), (ctx) => request(ctx, `POST:survey_questions.json`));
555
+ surveyQuestionModify = batchShopIDAndReqAndLocaleModifier(this, "surveyQuestionModify", plur("survey question(s) modified"), (ctx) => request(ctx, `POST:survey_questions.json`));
556
+ surveyQuestionDelete = batchShopIDAndIDDeletor(this, "surveyQuestionDelete", plur("survey question(s) deleted"), (ctx) => request(ctx, `DELETE:survey_questions.json`));
557
+ uploadFile = makeQueue(this, "uploadFile", itemByItemProcessor(plur("file(s) uploaded"), async (ctx, { item }) => {
558
+ let result;
559
+ if (ctx.ws && ctx.token) {
560
+ result = await uploadFileWebsocket({
561
+ api: new CommerceFileUploadAPI(ctx),
562
+ data: item.data,
563
+ name: item.name,
564
+ contentType: item.contentType,
565
+ size: item.data.byteLength,
566
+ shopID: item.shopID,
567
+ storage: item.storage,
568
+ jwt: ctx.token,
569
+ ws: ctx.ws,
570
+ });
571
+ }
572
+ else {
573
+ result = await uploadFileGeneric({
574
+ api: new CommerceFileUploadAPI(ctx),
575
+ data: item.data,
576
+ name: item.name,
577
+ contentType: item.contentType,
578
+ size: item.data.byteLength,
579
+ shopID: item.shopID,
580
+ storage: item.storage,
581
+ });
582
+ }
583
+ if (result.kind !== "ok") {
584
+ throw new Error(`file upload failure: ${result.kind}`);
585
+ }
586
+ return [{ id: result.file.id }];
587
+ }), (q, shopID, name, data, contentType, storage) => {
588
+ const uid = q.unID();
589
+ q.push(uid, {
590
+ shopID,
591
+ name,
592
+ data,
593
+ contentType,
594
+ storage,
595
+ req: null,
596
+ });
597
+ return uid;
598
+ });
599
+ customerNote = makeQueue(this, "customerNote", batchProcessor(plur("customer note(s) created"), 30, (props) => `${props.shopID}:${props.customerID}`, (ctx, props, items) => {
600
+ return request(ctx, `POST:customer_notes.json`)
601
+ .customer_id(props.customerID)
602
+ .data(items.map((v) => v.item.req))
603
+ .shop_id(props.shopID)
604
+ .sendUnwrap();
605
+ }), (q, shopID, customerID, req) => {
606
+ const uid = q.unID();
607
+ q.push(uid, { shopID, customerID, req });
608
+ return uid;
609
+ });
610
+ customerNoteModify = makeQueue(this, "customerNoteModify", batchProcessor(plur("customer note(s) modified"), 30, (props) => `${props.shopID}:${props.customerID}`, (ctx, props, items) => {
611
+ return request(ctx, `POST:customer_notes.json`)
612
+ .ids(items.map((v) => v.item.id))
613
+ .customer_id(props.customerID)
614
+ .data(items.map((v) => v.item.req))
615
+ .shop_id(props.shopID)
616
+ .sendUnwrap();
617
+ }), (q, shopID, customerID, id, req) => {
618
+ const uid = q.unID();
619
+ q.push(uid, { shopID, id, customerID, req });
620
+ });
621
+ customerNoteDelete = makeQueue(this, "customerNoteDelete", batchProcessor(plur("customer note(s) deleted"), 30, (props) => `${props.shopID}:${props.customerID}`, async (ctx, props, items) => {
622
+ await request(ctx, `DELETE:customer_notes.json`)
623
+ .ids(items.map((v) => v.item.id))
624
+ .customer_id(props.customerID)
625
+ .shop_id(props.shopID)
626
+ .sendUnwrap();
627
+ return null;
628
+ }), (q, shopID, customerID, id) => {
629
+ const uid = q.unID();
630
+ q.push(uid, { shopID, id, customerID, req: null });
631
+ });
632
+ orderNote = makeQueue(this, "orderNote", batchProcessor(plur("order note(s) created"), 30, (props) => `${props.shopID}:${props.orderID}`, (ctx, props, items) => {
633
+ return request(ctx, `POST:order_notes.json`)
634
+ .order_id(props.orderID)
635
+ .data(items.map((v) => v.item.req))
636
+ .shop_id(props.shopID)
637
+ .sendUnwrap();
638
+ }), (q, shopID, orderID, req) => {
639
+ const uid = q.unID();
640
+ q.push(uid, { shopID, orderID, req });
641
+ return uid;
642
+ });
643
+ orderNoteModify = makeQueue(this, "orderNoteModify", batchProcessor(plur("order note(s) modified"), 30, (props) => `${props.shopID}:${props.orderID}`, (ctx, props, items) => {
644
+ return request(ctx, `POST:order_notes.json`)
645
+ .ids(items.map((v) => v.item.id))
646
+ .order_id(props.orderID)
647
+ .data(items.map((v) => v.item.req))
648
+ .shop_id(props.shopID)
649
+ .sendUnwrap();
650
+ }), (q, shopID, orderID, id, req) => {
651
+ const uid = q.unID();
652
+ q.push(uid, { shopID, id, orderID, req });
653
+ });
654
+ orderNoteDelete = makeQueue(this, "orderNoteDelete", batchProcessor(plur("order note(s) deleted"), 30, (props) => `${props.shopID}:${props.orderID}`, async (ctx, props, items) => {
655
+ await request(ctx, `DELETE:order_notes.json`)
656
+ .ids(items.map((v) => v.item.id))
657
+ .order_id(props.orderID)
658
+ .shop_id(props.shopID)
659
+ .sendUnwrap();
660
+ return null;
661
+ }), (q, shopID, orderID, id) => {
662
+ const uid = q.unID();
663
+ q.push(uid, { shopID, id, orderID, req: null });
664
+ });
665
+ purchaseOrderNote = makeQueue(this, "purchaseOrderNote", batchProcessor(plur("purchase order note(s) created"), 30, (props) => `${props.shopID}:${props.purchaseOrderID}`, (ctx, props, items) => {
666
+ return request(ctx, `POST:purchase_order_notes.json`)
667
+ .purchase_order_id(props.purchaseOrderID)
668
+ .data(items.map((v) => v.item.req))
669
+ .shop_id(props.shopID)
670
+ .sendUnwrap();
671
+ }), (q, shopID, purchaseOrderID, req) => {
672
+ const uid = q.unID();
673
+ q.push(uid, { shopID, purchaseOrderID, req });
674
+ return uid;
675
+ });
676
+ purchaseOrderNoteModify = makeQueue(this, "purchaseOrderNoteModify", batchProcessor(plur("purchase order note(s) modified"), 30, (props) => `${props.shopID}:${props.purchaseOrderID}`, (ctx, props, items) => {
677
+ return request(ctx, `POST:purchase_order_notes.json`)
678
+ .ids(items.map((v) => v.item.id))
679
+ .purchase_order_id(props.purchaseOrderID)
680
+ .data(items.map((v) => v.item.req))
681
+ .shop_id(props.shopID)
682
+ .sendUnwrap();
683
+ }), (q, shopID, purchaseOrderID, id, req) => {
684
+ const uid = q.unID();
685
+ q.push(uid, { shopID, id, purchaseOrderID, req });
686
+ });
687
+ purchaseOrderNoteDelete = makeQueue(this, "purchaseOrderNoteDelete", batchProcessor(plur("purchase order note(s) deleted"), 30, (props) => `${props.shopID}:${props.purchaseOrderID}`, async (ctx, props, items) => {
688
+ await request(ctx, `DELETE:purchase_order_notes.json`)
689
+ .ids(items.map((v) => v.item.id))
690
+ .purchase_order_id(props.purchaseOrderID)
691
+ .shop_id(props.shopID)
692
+ .sendUnwrap();
693
+ return null;
694
+ }), (q, shopID, purchaseOrderID, id) => {
695
+ const uid = q.unID();
696
+ q.push(uid, { shopID, id, purchaseOrderID, req: null });
697
+ });
698
+ transferNote = makeQueue(this, "transferNote", batchProcessor(plur("transfer note(s) created"), 30, (props) => `${props.shopID}:${props.transferID}`, (ctx, props, items) => {
699
+ return request(ctx, `POST:purchase_order_notes.json`)
700
+ .purchase_order_id(props.transferID)
701
+ .data(items.map((v) => v.item.req))
702
+ .shop_id(props.shopID)
703
+ .sendUnwrap();
704
+ }), (q, shopID, transferID, req) => {
705
+ const uid = q.unID();
706
+ q.push(uid, { shopID, transferID, req });
707
+ return uid;
708
+ });
709
+ transferNoteModify = makeQueue(this, "transferNoteModify", batchProcessor(plur("transfer note(s) modified"), 30, (props) => `${props.shopID}:${props.transferID}`, (ctx, props, items) => {
710
+ return request(ctx, `POST:transfer_notes.json`)
711
+ .ids(items.map((v) => v.item.id))
712
+ .transfer_id(props.transferID)
713
+ .data(items.map((v) => v.item.req))
714
+ .shop_id(props.shopID)
715
+ .sendUnwrap();
716
+ }), (q, shopID, transferID, id, req) => {
717
+ const uid = q.unID();
718
+ q.push(uid, { shopID, id, transferID, req });
719
+ });
720
+ transferNoteDelete = makeQueue(this, "transferNoteDelete", batchProcessor(plur("transfer note(s) deleted"), 30, (props) => `${props.shopID}:${props.transferID}`, async (ctx, props, items) => {
721
+ await request(ctx, `DELETE:transfer_notes.json`)
722
+ .ids(items.map((v) => v.item.id))
723
+ .transfer_id(props.transferID)
724
+ .shop_id(props.shopID)
725
+ .sendUnwrap();
726
+ return null;
727
+ }), (q, shopID, transferID, id) => {
728
+ const uid = q.unID();
729
+ q.push(uid, { shopID, id, transferID, req: null });
730
+ });
731
+ order = batchShopIDAndReqCreator(this, "order", plur("order(s) created"), (ctx) => request(ctx, `POST:orders.json`));
732
+ orderModify = batchShopIDAndReqModifier(this, "orderModify", plur("order(s) modified"), (ctx) => request(ctx, `POST:orders.json`));
733
+ orderDelete = batchShopIDAndIDDeletor(this, "orderDelete", plur("order(s) deleted"), (ctx) => request(ctx, `DELETE:orders.json`));
734
+ purchaseOrder = batchShopIDAndReqCreator(this, "purchaseOrder", plur("purchase order(s) created"), (ctx) => request(ctx, `POST:purchase_orders.json`));
735
+ purchaseOrderModify = batchShopIDAndReqModifier(this, "purchaseOrderModify", plur("purchase order(s) modified"), (ctx) => request(ctx, `POST:purchase_orders.json`));
736
+ purchaseOrderDelete = batchShopIDAndIDDeletor(this, "purchaseOrderDelete", plur("purchase order(s) deleted"), (ctx) => request(ctx, `DELETE:purchase_orders.json`));
737
+ transfer = batchShopIDAndReqCreator(this, "transfer", plur("transfer(s) created"), (ctx) => request(ctx, `POST:transfers.json`));
738
+ transferModify = batchShopIDAndReqModifier(this, "transferModify", plur("transfer(s) modified"), (ctx) => request(ctx, `POST:transfers.json`));
739
+ transferDelete = batchShopIDAndIDDeletor(this, "transferDelete", plur("transfer(s) deleted"), (ctx) => request(ctx, `DELETE:transfers.json`));
740
+ supplier = batchShopIDAndReqCreator(this, "supplier", plur("supplier(s) created"), (ctx) => request(ctx, `POST:suppliers.json`));
741
+ supplierModify = batchShopIDAndReqModifier(this, "supplierModify", plur("supplier(s) modified"), (ctx) => request(ctx, `POST:suppliers.json`));
742
+ supplierDelete = batchShopIDAndIDDeletor(this, "supplierDelete", plur("supplier(s) deleted"), (ctx) => request(ctx, `DELETE:suppliers.json`));
743
+ packaging = batchShopIDAndReqCreator(this, "packaging", plur("packaging configuration(s) created"), (ctx) => request(ctx, `POST:packaging.json`));
744
+ packagingModify = batchShopIDAndReqModifier(this, "packagingModify", plur("packaging configuration(s) modified"), (ctx) => request(ctx, `POST:packaging.json`));
745
+ packagingDelete = batchShopIDAndIDDeletor(this, "packagingDelete", plur("packaging configuration(s) deleted"), (ctx) => request(ctx, `DELETE:packaging.json`));
746
+ invitation = batchShopIDAndReqCreator(this, "invitation", plur("invitation(s) created"), (ctx) => request(ctx, `POST:invitations.json`));
747
+ invitationDelete = batchShopIDAndIDDeletor(this, "invitationDelete", plur("invitation(s) deleted"), (ctx) => request(ctx, `DELETE:invitations.json`));
748
+ buyLink = batchShopIDAndReqCreator(this, "buyLink", plur("buy link(s) created"), (ctx) => request(ctx, `POST:buy_links.json`));
749
+ buyLinkModify = batchShopIDAndReqModifier(this, "buyLinkModify", plur("buy link(s) modified"), (ctx) => request(ctx, `POST:buy_links.json`));
750
+ buyLinkDelete = batchShopIDAndIDDeletor(this, "buyLinkDelete", plur("buy link(s) deleted"), (ctx) => request(ctx, `DELETE:buy_links.json`));
751
+ customerGroup = batchShopIDAndReqCreator(this, "customerGroup", plur("customer group(s) created"), (ctx) => request(ctx, `POST:customer_groups.json`));
752
+ customerGroupModify = batchShopIDAndReqModifier(this, "customerGroupModify", plur("customer group(s) modified"), (ctx) => request(ctx, `POST:customer_groups.json`));
753
+ customerGroupDelete = batchShopIDAndIDDeletor(this, "customerGroupDelete", plur("customer group(s) deleted"), (ctx) => request(ctx, `DELETE:customer_groups.json`));
754
+ dataFeed = batchShopIDAndReqCreator(this, "dataFeed", plur("data feed(s) created"), (ctx) => request(ctx, `POST:data_feeds.json`));
755
+ dataFeedModify = batchShopIDAndReqModifier(this, "dataFeedModify", plur("data feed(s) modified"), (ctx) => request(ctx, `POST:data_feeds.json`));
756
+ dataFeedDelete = batchShopIDAndIDDeletor(this, "dataFeedDelete", plur("data feed(s) deleted"), (ctx) => request(ctx, `DELETE:data_feeds.json`));
757
+ inventoryRule = batchShopIDAndReqCreator(this, "inventoryRule", plur("inventory rule(s) created"), (ctx) => request(ctx, `POST:inventory_rules.json`));
758
+ inventoryRuleModify = batchShopIDAndReqModifier(this, "inventoryRuleModify", plur("inventory rule(s) modified"), (ctx) => request(ctx, `POST:inventory_rules.json`));
759
+ inventoryRuleDelete = batchShopIDAndIDDeletor(this, "inventoryRuleDelete", plur("inventory rule(s) deleted"), (ctx) => request(ctx, `DELETE:inventory_rules.json`));
760
+ returnInspection = batchShopIDAndReqCreator(this, "returnInspection", plur("return inspection(s) created"), (ctx) => request(ctx, `POST:return_inspections.json`));
761
+ returnInspectionModify = batchShopIDAndReqModifier(this, "returnInspectionModify", plur("return inspection(s) modified"), (ctx) => request(ctx, `POST:return_inspections.json`));
762
+ returnInspectionDelete = batchShopIDAndIDDeletor(this, "returnInspectionDelete", plur("return inspection(s) deleted"), (ctx) => request(ctx, `DELETE:return_inspections.json`));
763
+ scheduledFulfillment = makeQueue(this, "scheduledFulfillment", batchProcessor(plur("scheduled fulfillment(s) created"), 30, (props) => `${props.shopID}:${props.orderID}`, (ctx, props, items) => {
764
+ return request(ctx, `POST:scheduled_fulfillments.json`)
765
+ .shop_id(props.shopID)
766
+ .order_id(props.orderID)
767
+ .data(items.map((v) => v.item.req))
768
+ .sendUnwrap();
769
+ }), (q, shopID, orderID, req) => {
770
+ const uid = q.unID();
771
+ q.push(uid, { shopID, orderID, req });
772
+ return uid;
773
+ });
774
+ scheduledFulfillmentModify = makeQueue(this, "scheduledFulfillmentModify", batchProcessor(plur("scheduled fulfillment(s) modified"), 30, (props) => `${props.shopID}:${props.orderID}`, (ctx, props, items) => {
775
+ return request(ctx, `POST:scheduled_fulfillments.json`)
776
+ .ids(items.map((v) => v.item.id))
777
+ .shop_id(props.shopID)
778
+ .order_id(props.orderID)
779
+ .data(items.map((v) => v.item.req))
780
+ .sendUnwrap();
781
+ }), (q, shopID, orderID, id, req) => {
782
+ const uid = q.unID();
783
+ q.push(uid, { shopID, orderID, id, req });
784
+ });
785
+ scheduledFulfillmentDelete = makeQueue(this, "scheduledFulfillmentDelete", batchProcessor(plur("scheduled fulfillment(s) deleted"), 30, (props) => `${props.shopID}:${props.orderID}`, async (ctx, props, items) => {
786
+ await request(ctx, `DELETE:scheduled_fulfillments.json`)
787
+ .ids(items.map((v) => v.id))
788
+ .order_id(props.orderID)
789
+ .shop_id(props.shopID)
790
+ .sendUnwrap();
791
+ return null;
792
+ }), (q, shopID, orderID, id) => {
793
+ const uid = q.unID();
794
+ q.push(uid, { shopID, id, orderID, req: null });
795
+ });
796
+ role = batchShopIDAndReqCreator(this, "role", plur("role(s) created"), (ctx) => request(ctx, `POST:roles.json`));
797
+ roleModify = batchShopIDAndReqModifier(this, "roleModify", plur("role(s) modified"), (ctx) => request(ctx, `POST:roles.json`));
798
+ roleDelete = batchShopIDAndIDDeletor(this, "roleDelete", plur("role(s) deleted"), (ctx) => request(ctx, `DELETE:roles.json`));
799
+ returnPolicy = batchShopIDAndReqCreator(this, "returnPolicy", { plural: "return policies created", singular: "return policy created" }, (ctx) => request(ctx, `POST:return_policies.json`));
800
+ returnPolicyModify = batchShopIDAndReqModifier(this, "returnPolicyModify", { plural: "return policies modified", singular: "return policy modified" }, (ctx) => request(ctx, `POST:return_policies.json`));
801
+ returnPolicyDelete = batchShopIDAndIDDeletor(this, "returnPolicyDelete", { plural: "return policies deleted", singular: "return policy deleted" }, (ctx) => request(ctx, `DELETE:return_policies.json`));
802
+ optionSet = batchShopIDAndReqCreator(this, "optionSet", plur("option set(s) created"), (ctx) => request(ctx, `POST:option_sets.json`));
803
+ optionSetModify = batchShopIDAndReqModifier(this, "optionSetModify", plur("option set(s) modified"), (ctx) => request(ctx, `POST:option_sets.json`));
804
+ optionSetDelete = batchShopIDAndIDDeletor(this, "optionSetDelete", plur("option set(s) deleted"), (ctx) => request(ctx, `DELETE:option_sets.json`));
805
+ productFieldSet = batchShopIDAndReqCreator(this, "productFieldSet", plur("product field set(s) created"), (ctx) => request(ctx, `POST:product_field_sets.json`));
806
+ productFieldSetModify = batchShopIDAndReqAndLocaleModifier(this, "productFieldSetModify", plur("product field set(s) modified"), (ctx) => request(ctx, `POST:product_field_sets.json`));
807
+ productFieldSetDelete = batchShopIDAndIDDeletor(this, "productFieldSetDelete", plur("product field set(s) deleted"), (ctx) => request(ctx, `DELETE:product_field_sets.json`));
808
+ key = batchShopIDAndReqCreator(this, "key", plur("key(s) created"), (ctx) => request(ctx, `POST:keys.json`));
809
+ keyModify = batchShopIDAndReqModifier(this, "keyModify", plur("key(s) modified"), (ctx) => request(ctx, `POST:keys.json`));
810
+ keyDelete = batchShopIDAndIDDeletor(this, "keyDelete", plur("key(s) deleted"), (ctx) => request(ctx, `DELETE:keys.json`));
811
+ product = batchShopIDAndReqCreator(this, "product", plur("product(s) created"), (ctx) => request(ctx, `POST:products.json`));
812
+ productModify = batchShopIDAndReqAndLocaleModifier(this, "productModify", plur("product(s) modified"), (ctx) => request(ctx, `POST:products.json`));
813
+ productDelete = batchShopIDAndIDDeletor(this, "productDelete", plur("product(s) deleted"), (ctx) => request(ctx, `DELETE:products.json`));
814
+ variant = makeQueue(this, "variant", batchProcessor(plur("product variant(s) created"), 30, (props) => props.shopID, (ctx, props, items) => {
815
+ return request(ctx, `POST:product_variants.json`)
816
+ .shop_id(props.shopID)
817
+ .data(items.map((v) => ({ ...v.item.req, product_id: v.item.productID })))
818
+ .sendUnwrap();
819
+ }), (q, shopID, productID, req) => {
820
+ const uid = q.unID();
821
+ q.push(uid, { shopID, productID, req });
822
+ return uid;
823
+ });
824
+ variantModify = batchShopIDAndReqAndLocaleModifier(this, "variantModify", plur("product variant(s) modified"), (ctx) => request(ctx, `POST:product_variants.json`));
825
+ variantDelete = batchShopIDAndIDDeletor(this, "variantDelete", plur("product variant(s) deleted"), (ctx) => request(ctx, `DELETE:product_variants.json`));
826
+ currency = makeQueue(this, "currency", batchProcessor({ singular: "currency created", plural: "currencies created" }, 30, (props) => props.shopID, async (ctx, props, items) => {
827
+ await request(ctx, `POST:currencies.json`)
828
+ .shop_id(props.shopID)
829
+ .data(items.map((v) => v.item.req))
830
+ .sendUnwrap();
831
+ return null;
832
+ }), (q, shopID, req) => {
833
+ const uid = q.unID();
834
+ q.push(uid, { shopID, req });
835
+ return uid;
836
+ });
837
+ review = makeQueue(this, "review", batchProcessor(plur("review(s) created"), 30, (props) => `${props.shopID}:${props.req.product_id}`, (ctx, props, items) => {
838
+ return request(ctx, `POST:product_reviews.json`)
839
+ .shop_id(props.shopID)
840
+ .data(items.map((v) => v.item.req))
841
+ .sendUnwrap();
842
+ }), (q, shopID, req) => {
843
+ const uid = q.unID();
844
+ q.push(uid, { shopID, req });
845
+ return uid;
846
+ });
847
+ question = makeQueue(this, "question", batchProcessor(plur("question(s) created"), 30, (props) => `${props.shopID}:${props.req.product_id}`, (ctx, props, items) => {
848
+ return request(ctx, `POST:product_questions.json`)
849
+ .shop_id(props.shopID)
850
+ .data(items.map((v) => v.item.req))
851
+ .sendUnwrap();
852
+ }), (q, shopID, req) => {
853
+ const uid = q.unID();
854
+ q.push(uid, { shopID, req });
855
+ return uid;
856
+ });
857
+ variantInventory = makeQueue(this, "variantInventory", batchProcessor({ singular: "inventory entry set", plural: "inventory entries set" }, 30, (props) => `${props.shopID}:${props.variantID}`, async (ctx, props, items) => {
858
+ await request(ctx, `POST:variant_inventory.json`)
859
+ .shop_id(props.shopID)
860
+ .variant_id(props.variantID)
861
+ .data(items.map((v) => v.item.req))
862
+ .sendUnwrap();
863
+ return null;
864
+ }), (q, shopID, variantID, req) => {
865
+ const uid = q.unID();
866
+ q.push(uid, { shopID, variantID, req });
867
+ return uid;
868
+ });
869
+ countTotalNumberOfItems() {
870
+ let totalItems = 0;
871
+ for (const b of this.batches) {
872
+ totalItems += b.numberOfItems();
873
+ if (b.barrier) {
874
+ totalItems++;
875
+ }
876
+ }
877
+ return totalItems;
878
+ }
879
+ async execute(ctx, logger = new NullLogger()) {
880
+ const t0 = +new Date();
881
+ const resolvedIDs = new Map();
882
+ const ectx = {
883
+ batchNum: 0,
884
+ numTotal: this.countTotalNumberOfItems(),
885
+ numComplete: 0,
886
+ };
887
+ logger.line(`╒═══════════════════════════════════════════════════════════════════╕`);
888
+ logger.line(`│ Executing (${ectx.numTotal} items)`.padEnd(68, " ") + "│");
889
+ logger.line(`├───────────────────────────────────────────────────────────────────┘`);
890
+ for (const b of this.batches) {
891
+ for (const batch of b.topoSort(resolvedIDs.keys())) {
892
+ const batchStr = `Batch #${++ectx.batchNum}`;
893
+ const bar = logger.bar("└─ {job} [{bar}] | {percentage}% | ETA: {eta}s | {value}/{total}");
894
+ const statsExecuteContext = new StatsExecuteContext(batchStr, this.opts, (v) => {
895
+ bar.increment(v);
896
+ ectx.numComplete += v;
897
+ });
898
+ bar.start(ectx.numTotal, ectx.numComplete, { job: batchStr });
899
+ let result = [];
900
+ if (this.opts.sequential) {
901
+ for (const b of batch) {
902
+ result.push(await b.processor(statsExecuteContext, ctx, b.items, resolvedIDs));
903
+ }
904
+ }
905
+ else {
906
+ result = await Promise.all(batch.map((b) => b.processor(statsExecuteContext, ctx, b.items, resolvedIDs)));
907
+ }
908
+ statsExecuteContext.done();
909
+ bar.stop();
910
+ const newIDs = result.reduce((a, b) => a.concat(b), []);
911
+ for (const [key, val] of newIDs) {
912
+ resolvedIDs.set(key, val);
913
+ }
914
+ // report stats
915
+ const bstats = {};
916
+ const tree = {
917
+ [`${batchStr} [${statsExecuteContext.stats.secondsElapsed.toFixed(3)}s]`]: bstats,
918
+ };
919
+ for (const [name, stat] of Array.from(statsExecuteContext.stats.stats.entries())) {
920
+ const apiCalls = stat.apiCalls === 1 ? `1 api call` : `${stat.apiCalls} api calls`;
921
+ const nm = formatName(name, stat.objects);
922
+ bstats[`${stat.objects} ${nm} (${apiCalls}) [${stat.secondsElapsed.toFixed(3)}s]`] = "";
923
+ }
924
+ logger.tree(tree);
925
+ }
926
+ if (b.barrier) {
927
+ const barrierStr = `Barrier #${ectx.batchNum}: ${b.barrier.desc}`;
928
+ const bar = logger.bar("└─ {job} [{bar}] | {percentage}% | ETA: {eta}s | {value}/{total}");
929
+ bar.start(ectx.numTotal, ectx.numComplete, { job: barrierStr });
930
+ const statsExecuteContext = new StatsExecuteContext(barrierStr, this.opts);
931
+ applyResolvedIDs(b.barrier.data, resolvedIDs);
932
+ await b.barrier.func(b.barrier.data);
933
+ bar.increment();
934
+ ectx.numComplete++;
935
+ statsExecuteContext.done();
936
+ bar.stop();
937
+ const tree = {
938
+ [`${barrierStr} [${statsExecuteContext.stats.secondsElapsed.toFixed(3)}s]`]: {},
939
+ };
940
+ logger.tree(tree);
941
+ }
942
+ }
943
+ const t1 = +new Date();
944
+ const elapsed = (t1 - t0) / 1000;
945
+ logger.line(`├───────────────────────────────────────────────────────────────────┐`);
946
+ logger.line(`│ Total seconds elapsed: ${elapsed.toFixed(3)}s`.padEnd(68, " ") + "│");
947
+ logger.line(`╘═══════════════════════════════════════════════════════════════════╛`);
948
+ return {
949
+ resolvedIDs,
950
+ };
951
+ }
952
+ }