@ecomweb/sdk 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ecomweb
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # @ecomweb/sdk
2
+
3
+ Shared TypeScript SDK for the EcomWeb storefront API — request builders,
4
+ response types and the vocabulary (collection rules, payment methods, order
5
+ shapes) that the API and its consumers must agree on.
6
+
7
+ > Part of a seven-repo system. For the whole picture see
8
+ > [`../ecomweb/docs/getting-started/SETUP.md`](../ecomweb/docs/getting-started/SETUP.md).
9
+
10
+ ## Source in the workspace, `dist/` on npm
11
+
12
+ Inside the storefront workspace, `exports` points at `./src/index.ts` and the
13
+ app compiles the source itself (`transpilePackages`). `pnpm build` (tsup)
14
+ produces `dist/` (ESM + `.d.ts`); `publishConfig.exports` swaps that in when
15
+ the package is published, so npm consumers never compile it.
16
+
17
+ ```bash
18
+ pnpm --filter @ecomweb/sdk typecheck
19
+ pnpm --filter @ecomweb/sdk test
20
+ pnpm --filter @ecomweb/sdk build
21
+ ```
22
+
23
+ ## How consumers get it
24
+
25
+ | Consumer | Specifier |
26
+ |---|---|
27
+ | `ecomweb-storefront` (this workspace) | `workspace:*` |
28
+ | Ejected merchant storefronts | npm `@ecomweb/sdk` (caret range) |
29
+ | `@ecomweb/contracts` / `ecomweb-dashboard` | npm `@ecomweb/sdk` (GitHub until the first publish) |
30
+
31
+ Admin-only types and constants (permissions, purchase orders, sales channels,
32
+ timelines, …) are **not** here: they live in the private `@ecomweb/contracts`
33
+ package (the `ecomweb-sdk` repo).
34
+
35
+ ### Working on the SDK locally
36
+
37
+ The SDK lives in the storefront's pnpm workspace (`packages/sdk`). The app
38
+ imports its source directly, so edits are visible immediately. Run
39
+ `pnpm --filter @ecomweb/sdk test` before you push.
40
+
41
+ ## Layout
42
+
43
+ ```
44
+ src/
45
+ ├── core/ HTTP client, error types, shared plumbing
46
+ ├── modules/ One directory per domain (products, orders, cart, search, …)
47
+ ├── types/ Shared types and schemas
48
+ └── index.ts Public surface — the only entry point
49
+ ```
50
+
51
+ Anything not exported from `src/index.ts` is not public API.
52
+
53
+ ## Conventions
54
+
55
+ - **The SDK owns the shared vocabulary.** Where the API and SDK both describe
56
+ the same concept (collection rule fields, payment method codes, order
57
+ statuses), the SDK is the source of truth and the API pins itself to it.
58
+ - **Widening an enum here is not enough.** The dashboard keeps private copies
59
+ of some of this vocabulary; changing it in the SDK and API can still leave
60
+ the merchant UI unable to use the new value. Grep the dashboard too.
61
+ - No user-facing strings. Consumers localise from error codes.