Skip to content

Commit 7dd54c8

Browse files
SALAHEXSALAHEX
authored andcommitted
feat: initialize storefront kit package for public release
1 parent 6faacdd commit 7dd54c8

14 files changed

Lines changed: 1741 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
quality:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Setup pnpm
16+
uses: pnpm/action-setup@v4
17+
with:
18+
version: 10.28.0
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
cache: pnpm
25+
26+
- name: Install
27+
run: pnpm install --frozen-lockfile
28+
29+
- name: Typecheck
30+
run: pnpm typecheck
31+
32+
- name: Build
33+
run: pnpm build
34+
35+
- name: Package smoke
36+
run: npm pack --dry-run

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
id-token: write
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup pnpm
20+
uses: pnpm/action-setup@v4
21+
with:
22+
version: 10.28.0
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
registry-url: https://registry.npmjs.org
29+
cache: pnpm
30+
31+
- name: Install
32+
run: pnpm install --frozen-lockfile
33+
34+
- name: Build
35+
run: pnpm build
36+
37+
- name: Publish
38+
run: npm publish --access public --provenance
39+
env:
40+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
dist/
3+
package-lock.json

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
## 0.1.0
4+
5+
- Initial release.
6+
- Added `resolveVariantSelection` and variant matching helpers.
7+
- Added `normalizeProductCard` and `normalizeCartSummary`.
8+
- Added promotion classification helpers:
9+
- `classifyPromotionStatus`
10+
- `promotionStatusLabel`

README.md

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,73 @@
1-
# ecommaps-storefront-kit
2-
Framework-agnostic storefront business logic kit for Ecommaps.
1+
# @ecommaps/storefront-kit
2+
3+
Framework-agnostic commerce logic primitives for Ecommaps storefront applications.
4+
5+
![npm version](https://img.shields.io/npm/v/@ecommaps/storefront-kit)
6+
7+
## 1. Positioning
8+
9+
Use this package for reusable business logic that should not depend on:
10+
- Next.js
11+
- React
12+
- AI SDK
13+
14+
This package is intended for server actions, API routes, workers, and backend services.
15+
16+
## 2. Installation
17+
18+
```bash
19+
pnpm add @ecommaps/storefront-kit
20+
```
21+
22+
## 3. Public API
23+
24+
### Variant resolution
25+
26+
- `resolveVariantSelection(product, input)`
27+
- `variantMatchesColorAndSize(product, variant, color, size)`
28+
29+
Behavior:
30+
- supports multilingual color/size synonyms
31+
- enforces exact size semantics (prevents wrong size fallback)
32+
- returns `requires_selection` when match is ambiguous
33+
34+
### Normalizers
35+
36+
- `normalizeProductCard(product)`
37+
- `normalizeCartSummary(cart)`
38+
39+
### Promotions
40+
41+
- `classifyPromotionStatus(promotion, context)`
42+
- `promotionStatusLabel(status)`
43+
44+
## 4. Usage example
45+
46+
```ts
47+
import {
48+
resolveVariantSelection,
49+
normalizeProductCard,
50+
normalizeCartSummary,
51+
classifyPromotionStatus,
52+
} from "@ecommaps/storefront-kit";
53+
54+
const selection = resolveVariantSelection(product, {
55+
variant_id: undefined,
56+
color: "red",
57+
size: "L",
58+
});
59+
60+
const card = normalizeProductCard(product);
61+
const cart = normalizeCartSummary(rawCart);
62+
63+
const promoState = classifyPromotionStatus(
64+
{ code: "DISCOUNT20", min_order_amount: 5000 },
65+
{ enteredCode: "DISCOUNT20", cartTotal: 7000, explicitValidationPassed: true },
66+
);
67+
```
68+
69+
## 5. Compatibility
70+
71+
- Runtime: Node.js 20+
72+
- No UI framework dependency
73+
- Semver-stable function contracts

package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "@ecommaps/storefront-kit",
3+
"version": "0.1.0",
4+
"description": "Reusable storefront business logic utilities for Ecommaps.",
5+
"main": "./dist/index.js",
6+
"module": "./dist/index.mjs",
7+
"types": "./dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"import": "./dist/index.mjs",
12+
"require": "./dist/index.js"
13+
},
14+
"./package.json": "./package.json"
15+
},
16+
"files": [
17+
"dist",
18+
"README.md",
19+
"CHANGELOG.md",
20+
"package.json"
21+
],
22+
"scripts": {
23+
"build": "tsup src/index.ts --format cjs,esm --dts",
24+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
25+
"typecheck": "tsc --noEmit",
26+
"lint": "eslint src/",
27+
"clean": "rm -rf dist node_modules"
28+
},
29+
"devDependencies": {
30+
"@types/node": "^25.3.0",
31+
"tsup": "^8.0.2",
32+
"typescript": "^5.4.5"
33+
},
34+
"license": "ISC",
35+
"repository": {
36+
"type": "git",
37+
"url": "https://github.com/labobankcom/ecommaps-storefront-kit.git"
38+
},
39+
"bugs": {
40+
"url": "https://github.com/labobankcom/ecommaps-storefront-kit/issues"
41+
},
42+
"homepage": "https://github.com/labobankcom/ecommaps-storefront-kit#readme",
43+
"engines": {
44+
"node": ">=20"
45+
},
46+
"publishConfig": {
47+
"access": "public",
48+
"registry": "https://registry.npmjs.org/"
49+
},
50+
"packageManager": "pnpm@10.28.0"
51+
}

0 commit comments

Comments
 (0)