@lana-commerce/core 13.1.0-alpha.4 → 13.1.0-alpha.6

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.
package/CHANGELOG.md CHANGED
@@ -12,11 +12,13 @@ This project adheres to [Semantic Versioning][semantic versioning].
12
12
  - Add "clear" event to "modules/advancedSearch".
13
13
  - Extend "invoiceFormat" to support storage fees (internal thing).
14
14
  - A bunch of internal APIs were removed. While it's a major change, I put it here, because we know for sure that nobody was using those.
15
+ - Add "wrapWebSocket" function to "websocket" lib.
15
16
 
16
17
  ### Patch Changes
17
18
 
18
19
  - Fix a bug in "modules/advancedSearch". Locale changes were incorrectly ignored in effect body.
19
20
  - Avoid using findDOMNode in popper.js related code.
21
+ - Fix broken ESM import paths in "json/commerce" and "json/storefront".
20
22
 
21
23
  ## [Released]
22
24
 
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.request = exports.prettyPrintResponseError = exports.requestErrorPrefix = exports.isExpanded = exports.assertExpanded = void 0;
4
4
  const common_js_1 = require("./common.js");
5
- var common_1 = require("./common");
6
- Object.defineProperty(exports, "assertExpanded", { enumerable: true, get: function () { return common_1.assertExpanded; } });
7
- Object.defineProperty(exports, "isExpanded", { enumerable: true, get: function () { return common_1.isExpanded; } });
8
- Object.defineProperty(exports, "requestErrorPrefix", { enumerable: true, get: function () { return common_1.requestErrorPrefix; } });
9
- Object.defineProperty(exports, "prettyPrintResponseError", { enumerable: true, get: function () { return common_1.prettyPrintResponseError; } });
5
+ var common_js_2 = require("./common.js");
6
+ Object.defineProperty(exports, "assertExpanded", { enumerable: true, get: function () { return common_js_2.assertExpanded; } });
7
+ Object.defineProperty(exports, "isExpanded", { enumerable: true, get: function () { return common_js_2.isExpanded; } });
8
+ Object.defineProperty(exports, "requestErrorPrefix", { enumerable: true, get: function () { return common_js_2.requestErrorPrefix; } });
9
+ Object.defineProperty(exports, "prettyPrintResponseError", { enumerable: true, get: function () { return common_js_2.prettyPrintResponseError; } });
10
10
  exports.request = common_js_1.requestFunction;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.request = exports.prettyPrintResponseError = exports.requestErrorPrefix = exports.isExpanded = exports.assertExpanded = void 0;
4
4
  const common_js_1 = require("./common.js");
5
- var common_1 = require("./common");
6
- Object.defineProperty(exports, "assertExpanded", { enumerable: true, get: function () { return common_1.assertExpanded; } });
7
- Object.defineProperty(exports, "isExpanded", { enumerable: true, get: function () { return common_1.isExpanded; } });
8
- Object.defineProperty(exports, "requestErrorPrefix", { enumerable: true, get: function () { return common_1.requestErrorPrefix; } });
9
- Object.defineProperty(exports, "prettyPrintResponseError", { enumerable: true, get: function () { return common_1.prettyPrintResponseError; } });
5
+ var common_js_2 = require("./common.js");
6
+ Object.defineProperty(exports, "assertExpanded", { enumerable: true, get: function () { return common_js_2.assertExpanded; } });
7
+ Object.defineProperty(exports, "isExpanded", { enumerable: true, get: function () { return common_js_2.isExpanded; } });
8
+ Object.defineProperty(exports, "requestErrorPrefix", { enumerable: true, get: function () { return common_js_2.requestErrorPrefix; } });
9
+ Object.defineProperty(exports, "prettyPrintResponseError", { enumerable: true, get: function () { return common_js_2.prettyPrintResponseError; } });
10
10
  exports.request = common_js_1.requestFunction;
package/cjs/websocket.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.webSocket = exports.error = exports.value = exports.WebSocketAsync = void 0;
3
+ exports.wrapWebSocket = exports.webSocket = exports.error = exports.value = exports.WebSocketAsync = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const refreshTimeout_js_1 = require("./refreshTimeout.js");
6
6
  const sleep_js_1 = require("./sleep.js");
@@ -177,3 +177,17 @@ function webSocket(url) {
177
177
  });
178
178
  }
179
179
  exports.webSocket = webSocket;
180
+ function wrapWebSocket(ws) {
181
+ return new Promise((resolve) => {
182
+ ws.onopen = () => {
183
+ resolve(value(new WebSocketAsync(ws)));
184
+ };
185
+ ws.onerror = () => {
186
+ resolve(error("socket error"));
187
+ };
188
+ ws.onclose = () => {
189
+ resolve(error("socket closed"));
190
+ };
191
+ });
192
+ }
193
+ exports.wrapWebSocket = wrapWebSocket;
@@ -1,3 +1,3 @@
1
1
  import { requestFunction } from "./common.js";
2
- export { assertExpanded, isExpanded, requestErrorPrefix, prettyPrintResponseError, } from "./common";
2
+ export { assertExpanded, isExpanded, requestErrorPrefix, prettyPrintResponseError, } from "./common.js";
3
3
  export const request = requestFunction;
@@ -1,3 +1,3 @@
1
1
  import { requestFunction } from "./common.js";
2
- export { assertExpanded, isExpanded, requestErrorPrefix, prettyPrintResponseError, } from "./common";
2
+ export { assertExpanded, isExpanded, requestErrorPrefix, prettyPrintResponseError, } from "./common.js";
3
3
  export const request = requestFunction;
package/esm/websocket.js CHANGED
@@ -167,3 +167,16 @@ export function webSocket(url) {
167
167
  };
168
168
  });
169
169
  }
170
+ export function wrapWebSocket(ws) {
171
+ return new Promise((resolve) => {
172
+ ws.onopen = () => {
173
+ resolve(value(new WebSocketAsync(ws)));
174
+ };
175
+ ws.onerror = () => {
176
+ resolve(error("socket error"));
177
+ };
178
+ ws.onclose = () => {
179
+ resolve(error("socket closed"));
180
+ };
181
+ });
182
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lana-commerce/core",
3
- "version": "13.1.0-alpha.4",
3
+ "version": "13.1.0-alpha.6",
4
4
  "description": "Lana JS Core",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -1,3 +1,3 @@
1
1
  import type { ReqFunction } from "./commerceTypes.js";
2
- export { assertExpanded, isExpanded, requestErrorPrefix, prettyPrintResponseError, APIRequest, APIResponse, Context, Extractor, RequestDetails, Response, SystemErrorType, } from "./common";
2
+ export { assertExpanded, isExpanded, requestErrorPrefix, prettyPrintResponseError, APIRequest, APIResponse, Context, Extractor, RequestDetails, Response, SystemErrorType, } from "./common.js";
3
3
  export declare const request: ReqFunction;
@@ -861,6 +861,21 @@ export interface CurrencyFormatCreate {
861
861
  /** What to use as thousands separator */
862
862
  thousands_separator?: string | null;
863
863
  }
864
+ export interface CurrencyHistory {
865
+ /** Currency code */
866
+ code: string;
867
+ entries: Array<CurrencyHistoryEntry>;
868
+ }
869
+ export interface CurrencyHistoryEntry {
870
+ /** Additional fee to add when converting to and from this currency (in percents) */
871
+ conversion_fee: number | null;
872
+ /** Custom exchange rate to use when converting from primary to this currency */
873
+ custom_exchange_rate: number | null;
874
+ /** The timestamp for this history record */
875
+ date: string;
876
+ /** Automatic exchange rate to use when converting from primary to this currency */
877
+ exchange_rate: number;
878
+ }
864
879
  export interface CurrencyInfo {
865
880
  /** Currency code */
866
881
  code: string;
@@ -1750,6 +1765,20 @@ export interface FileSearchResult {
1750
1765
  id: string;
1751
1766
  } | File | null>;
1752
1767
  }
1768
+ export interface FileStats {
1769
+ /** Upper limit of bytes consumed for customer files */
1770
+ customer_files_max: string;
1771
+ /** Bytes consumed for customer files */
1772
+ customer_files_total: string;
1773
+ /** Upper limit of bytes consumed for private files */
1774
+ private_files_max: string;
1775
+ /** Bytes consumed for private files */
1776
+ private_files_total: string;
1777
+ /** Upper limit of bytes consumed for public files */
1778
+ public_files_max: string;
1779
+ /** Bytes consumed for public files */
1780
+ public_files_total: string;
1781
+ }
1753
1782
  export type FileStorage = "general" | "private";
1754
1783
  export interface FileURL {
1755
1784
  /** Publically accessible URL, valid for few hours */
@@ -5356,6 +5385,12 @@ export interface ProductVariantPage {
5356
5385
  /** Key of the last item for keyset based iteration */
5357
5386
  last_key: string;
5358
5387
  }
5388
+ export interface ProductVariantPriceHistory {
5389
+ /** The timestamp for this history record */
5390
+ date: string;
5391
+ /** The price of the product variant */
5392
+ price: number;
5393
+ }
5359
5394
  export interface ProductVariantSearchResult {
5360
5395
  /** Total number of items in the collection */
5361
5396
  count: number;
@@ -10107,6 +10142,15 @@ export interface EndpointCurrenciesModify extends Endpoint<EndpointCurrenciesMod
10107
10142
  data(v: Array<CurrencyModify>): EndpointCurrenciesModify;
10108
10143
  extract(v: Extractor<Array<Currency>>): EndpointCurrenciesModify;
10109
10144
  }
10145
+ export interface EndpointCurrenciesHistory extends Endpoint<EndpointCurrenciesHistory, Array<CurrencyHistory>> {
10146
+ /** Filter output by currencies */
10147
+ currencies(v: Array<string>): EndpointCurrenciesHistory;
10148
+ from(v: string): EndpointCurrenciesHistory;
10149
+ /** Unique shop identifier. See also: [Unique Identifiers](/overview/concepts/unique-identifiers) */
10150
+ shop_id(v: string): EndpointCurrenciesHistory;
10151
+ to(v: string): EndpointCurrenciesHistory;
10152
+ extract(v: Extractor<Array<CurrencyHistory>>): EndpointCurrenciesHistory;
10153
+ }
10110
10154
  export interface EndpointCustomerBalance extends Endpoint<EndpointCustomerBalance, CustomerBalance> {
10111
10155
  /** Unique customer identifier. See also: [Unique Identifiers](/overview/concepts/unique-identifiers) */
10112
10156
  customer_id(v: string): EndpointCustomerBalance;
@@ -10778,6 +10822,11 @@ export interface EndpointFilesSign extends Endpoint<EndpointFilesSign, PDFSignat
10778
10822
  shop_id(v: string): EndpointFilesSign;
10779
10823
  extract(v: Extractor<PDFSignature>): EndpointFilesSign;
10780
10824
  }
10825
+ export interface EndpointFilesStats extends Endpoint<EndpointFilesStats, FileStats> {
10826
+ /** Unique shop identifier. See also: [Unique Identifiers](/overview/concepts/unique-identifiers) */
10827
+ shop_id(v: string): EndpointFilesStats;
10828
+ extract(v: Extractor<FileStats>): EndpointFilesStats;
10829
+ }
10781
10830
  export interface EndpointFilesUpload extends Endpoint<EndpointFilesUpload, FileURL> {
10782
10831
  /** Output filtering */
10783
10832
  fields(v: Array<string>): EndpointFilesUpload;
@@ -12269,6 +12318,19 @@ export interface EndpointProductVariantsPage extends Endpoint<EndpointProductVar
12269
12318
  expand(v: ProductVariantPageExpansionMap): EndpointProductVariantsPage;
12270
12319
  extract(v: Extractor<ProductVariantPage>): EndpointProductVariantsPage;
12271
12320
  }
12321
+ export interface EndpointProductVariantsPriceHistory extends Endpoint<EndpointProductVariantsPriceHistory, Array<ProductVariantPriceHistory>> {
12322
+ /** Query price history in specific currency */
12323
+ currency(v: string): EndpointProductVariantsPriceHistory;
12324
+ /** Query price history of a customer group */
12325
+ customer_group_id(v: string): EndpointProductVariantsPriceHistory;
12326
+ from(v: string): EndpointProductVariantsPriceHistory;
12327
+ /** Unique shop identifier. See also: [Unique Identifiers](/overview/concepts/unique-identifiers) */
12328
+ shop_id(v: string): EndpointProductVariantsPriceHistory;
12329
+ to(v: string): EndpointProductVariantsPriceHistory;
12330
+ /** Unique variant identifier. See also: [Unique Identifiers](/overview/concepts/unique-identifiers) */
12331
+ variant_id(v: string): EndpointProductVariantsPriceHistory;
12332
+ extract(v: Extractor<Array<ProductVariantPriceHistory>>): EndpointProductVariantsPriceHistory;
12333
+ }
12272
12334
  export interface EndpointProductsDelete extends Endpoint<EndpointProductsDelete, void> {
12273
12335
  /** List of product ids. See also: [Unique Identifiers](/overview/concepts/unique-identifiers) */
12274
12336
  ids(v: Array<string>): EndpointProductsDelete;
@@ -14717,6 +14779,7 @@ export interface ReqFunction {
14717
14779
  (ctx: Context, v: "DELETE:currencies.json"): EndpointCurrenciesDelete;
14718
14780
  (ctx: Context, v: "GET:currencies.json"): EndpointCurrencies;
14719
14781
  (ctx: Context, v: "POST:currencies.json"): EndpointCurrenciesCreate;
14782
+ (ctx: Context, v: "GET:currencies/history.json"): EndpointCurrenciesHistory;
14720
14783
  (ctx: Context, v: "GET:customer_balance.json"): EndpointCustomerBalance;
14721
14784
  (ctx: Context, v: "POST:customer_balance/apply_gift_card.json"): EndpointCustomerBalanceApplyGiftCard;
14722
14785
  (ctx: Context, v: "GET:customer_balance/history.json"): EndpointCustomerBalanceHistory;
@@ -14774,6 +14837,7 @@ export interface ReqFunction {
14774
14837
  (ctx: Context, v: "GET:files/lookup.json"): EndpointFilesLookup;
14775
14838
  (ctx: Context, v: "GET:files/page.json"): EndpointFilesPage;
14776
14839
  (ctx: Context, v: "POST:files/sign.json"): EndpointFilesSign;
14840
+ (ctx: Context, v: "GET:files/stats.json"): EndpointFilesStats;
14777
14841
  (ctx: Context, v: "POST:files/upload.json"): EndpointFilesUpload;
14778
14842
  (ctx: Context, v: "POST:files/uploaded.json"): EndpointFilesUploaded;
14779
14843
  (ctx: Context, v: "DELETE:gateways.json"): EndpointGatewaysDelete;
@@ -14910,6 +14974,7 @@ export interface ReqFunction {
14910
14974
  (ctx: Context, v: "GET:product_variants.json"): EndpointProductVariants;
14911
14975
  (ctx: Context, v: "POST:product_variants.json"): EndpointProductVariantsCreate;
14912
14976
  (ctx: Context, v: "GET:product_variants/page.json"): EndpointProductVariantsPage;
14977
+ (ctx: Context, v: "GET:product_variants/price_history.json"): EndpointProductVariantsPriceHistory;
14913
14978
  (ctx: Context, v: "DELETE:products.json"): EndpointProductsDelete;
14914
14979
  (ctx: Context, v: "GET:products.json"): EndpointProducts;
14915
14980
  (ctx: Context, v: "POST:products.json"): EndpointProductsCreate;
@@ -1,3 +1,3 @@
1
1
  import type { ReqFunction } from "./storefrontTypes.js";
2
- export { assertExpanded, isExpanded, requestErrorPrefix, prettyPrintResponseError, APIRequest, APIResponse, Context, Extractor, RequestDetails, Response, SystemErrorType, } from "./common";
2
+ export { assertExpanded, isExpanded, requestErrorPrefix, prettyPrintResponseError, APIRequest, APIResponse, Context, Extractor, RequestDetails, Response, SystemErrorType, } from "./common.js";
3
3
  export declare const request: ReqFunction;
@@ -31,3 +31,4 @@ export type Result<T> = ResultValue<T> | ResultError;
31
31
  export declare function value<T>(value: T): ResultValue<T>;
32
32
  export declare function error(error: string): ResultError;
33
33
  export declare function webSocket(url: string): Promise<Result<WebSocketAsync>>;
34
+ export declare function wrapWebSocket(ws: WebSocket): Promise<Result<WebSocketAsync>>;