@lightspeed/ecom-headless 0.1.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - 2025-08-06
4
+
5
+ ### Added
6
+
7
+ - Add support for REST API :: Store Profile :: Get store Profile.
8
+ - Add support for REST API :: Products :: Search products
9
+ - Add support for REST API :: Products :: Get product
10
+ - Add support for REST API :: Products :: Product files :: Download product file
11
+ - Add support for REST API :: Categories :: Search categories
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # @lightspeed/ecom-headless
2
+
3
+ `@lightspeed/ecom-headless` is a client-side JavaScript/TypeScript library for interacting with the Ecwid resources. It provides a strongly-typed, modern interface to access store data and trigger UI functionalities within third-party applications, themes, or custom integrations.
4
+
5
+ This library is designed for both browser and Node.js environments.
6
+
7
+ ## Key Features
8
+
9
+ - **TypeScript First:** Strong typing for a better developer experience.
10
+ - **npm Package:** Easy to integrate via `@lightspeed/ecom-headless`.
11
+ - **Read-Only Data Access:** Securely access Products, Categories, Store Profile, etc.
12
+ - **Modern JS:** ESM, tree-shakable, using `axios` for HTTP requests.
13
+ - **Cross-Platform:** Works in modern browsers and Node.js.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @lightspeed/ecom-headless
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ Here's a base example of how to initialize the API client and retrieve a store profile:
24
+
25
+ ```typescript
26
+ import { initStorefrontApi, getStoreProfile, GetStoreProfileResponse } from '@lightspeed/ecom-headless/api';
27
+ import { getStoreId } from '@lightspeed/ecom-headless/storefront';
28
+
29
+ initStorefrontApi({
30
+ publicToken: 'YOUR_PUBLIC_TOKEN',
31
+ storeId: 'YOUR_STORE_ID',
32
+ baseURL: 'https://app.ecwid.com/api/v3/'
33
+ });
34
+
35
+ const storeId = await getStoreId();
36
+ const response: GetStoreProfileResponse = await getStoreProfile({ storeId });
37
+ ```
38
+
39
+ ## API Overview
40
+
41
+ This library provides a client-side interface for a subset of the functionalities available in the Ecwid REST API. For a complete list of all available backend API endpoints and their detailed documentation, refer to the official [Ecwid API Reference](https://docs.ecwid.com/api-reference).
42
+
43
+ The underlying HTTP client is `axios`. The library focuses on fetching fresh data and does not implement persistent caching.
44
+
45
+ ### Key Exports and Functionalities
46
+
47
+ - **Configuration:**
48
+ - `getApiConfig(): ApiConfig` – Retrieves or sets the current API configuration.
49
+ - **Products:**
50
+ - `searchProducts(params?: SearchProductsParams): Promise<SearchProductsResponse>` – Searches for products based on various criteria.
51
+ - `getProduct(params: GetProductParams): Promise<GetProductResponse>` – Fetches a single product by its ID.
52
+ - *(Other product-related methods are available and exported from `src/api/products/` as implemented.)*
53
+ - **Shared Types:**
54
+ - `PaginatedResponse<T>` – Generic type for API responses that include pagination details.
55
+ - `SearchParams` – Basic type for search parameter objects.
56
+ - `SortBy` – Enum for available product sort orders.
57
+ - All product-specific types under `Product`, `ProductAttribute`, etc., are available and exported from `src/api/products/types/`.
58
+
59
+ *(The list of available methods will expand as more API endpoints are implemented and exported from the root `index.ts` file.)*
60
+
61
+ ## Request Handling
62
+
63
+ Each call to an API method will result in a new HTTP request. The library does not implement request deduplication or persistent caching.
64
+
65
+ ## Error Handling
66
+
67
+ Methods that return Promises will reject in case of errors (e.g., network issues, invalid parameters, API errors from the backend). Errors will typically be instances of `Error` or a custom error type derived from it, containing relevant information about the failure. Use `try...catch` blocks for asynchronous operations.
68
+
69
+ ## Security
70
+
71
+ All API methods provided by this library are public and read-only. Access requires a valid public token, which is used to authenticate requests. The library does not handle or store authentication tokens beyond what is required for public API access. All data transmission is performed over HTTPS.
72
+
73
+ ## Platform Compatibility
74
+
75
+ - **Browsers:** Designed for and tested in modern web browser environments (e.g., latest versions of Chrome, Firefox, Safari, Edge).
76
+ - **Node.js:** Suitable for use in Node.js environments for server-side interactions or scripting. `axios` provides HTTP request capabilities in Node.js.
77
+
78
+ ## Versioning & Changelog
79
+
80
+ This library adheres to [Semantic Versioning (SemVer)](https://semver.org/).
81
+ A `CHANGELOG.md` file is maintained in the package root to document changes, additions, and fixes for each version.
82
+
package/UPGRADE.md ADDED
File without changes
@@ -0,0 +1 @@
1
+ "use strict";const index=require("../shared/ecom-headless.Cr34mwOt.cjs");require("../storefront/index.cjs"),require("axios"),exports.downloadProductFile=index.downloadProductFile,exports.getApiConfig=index.getApiConfig,exports.getProduct=index.getProduct,exports.getStoreProfile=index.getStoreProfile,exports.initStorefrontApi=index.initStorefrontApi,exports.searchCategories=index.searchCategories,exports.searchProducts=index.searchProducts;