Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

# Publishes @xedo/sdk to npm whenever a version tag (e.g. v0.1.1) is pushed.
# Auth uses npm Trusted Publishing (OIDC) — no NPM_TOKEN secret to manage.
on:
push:
tags:
- 'v*'

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # required for OIDC trusted publishing + provenance
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
cache: npm

# Full quality gate before anything reaches the registry.
- run: npm ci
- run: npm run generate
- run: npm run lint
- run: npm run typecheck
- run: npm test
- run: npm run build

# Fail early if the git tag doesn't match the package.json version.
- name: Check tag matches package version
run: |
PKG_VERSION="v$(node -p "require('./package.json').version")"
if [ "$GITHUB_REF_NAME" != "$PKG_VERSION" ]; then
echo "Tag $GITHUB_REF_NAME does not match package version $PKG_VERSION" >&2
exit 1
fi

# Trusted Publishing needs npm >= 11.5.1; provenance is emitted automatically.
- run: npm install -g npm@latest
- run: npm publish
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ xedo.lastRateLimit; // { limit, remaining, reset } from the last call
| `xedo.collections` | `list`, `listAll`, `retrieve`, `retrieveBySlug` |
| `xedo.orders` | `list`, `listAll`, `retrieve`, `invoice` (PDF) |
| `xedo.carts` | `list`, `listAll`, `retrieve`, `preview`, `create`, `pay`, `createAndPay` |
| `xedo.deliveryAreas` | `list` → `DeliveryArea[]` |
| `xedo.marketplace` | `retrieve` → `MarketplaceProfile` |

Every entity is fully typed (`Product`, `Order`, `Cart`, `Collection`, …). Note
that `list()`/`listAll()` return lightweight summary rows (`OrderListItem`,
`CartListItem`) while `retrieve()` returns the full detail object (`Order`,
`Cart`).

### Pagination

Expand All @@ -67,6 +74,13 @@ for await (const order of xedo.orders.listAll()) {
}
```

### Delivery areas & marketplace

```ts
const profile = await xedo.marketplace.retrieve(); // payment config, business category…
const areas = await xedo.deliveryAreas.list(); // use area.id as delivery.deliveryAreaId
```

### Checkout

```ts
Expand Down
18 changes: 12 additions & 6 deletions examples/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@ async function main() {
const ping = await xedo.ping();
console.log('marketplace', ping.marketplaceId, '(', xedo.environment, ')');

// 2. Iterate the whole catalogue, page by page.
// 2. Inspect the merchant configuration and delivery areas.
const profile = await xedo.marketplace.retrieve();
console.log('split payment enabled:', profile.enableSplitPayment);
const areas = await xedo.deliveryAreas.list();
console.log('delivery areas:', areas.map((a) => `${a.name} (${a.deliveryCost})`));

// 3. Iterate the whole catalogue, page by page.
for await (const product of xedo.products.listAll({ perPage: 100 })) {
console.log(product.publicId, product.name);
console.log(product.publicId, product.name, product.price, `stock=${product.stockQuantity}`);
}

// 3. Preview a cart (stateless — no cart is created).
// 4. Preview a cart (stateless — no cart is created).
const totals = await xedo.carts.preview({
items: [{ publicProductId: 'PRD-XPK39ZQA01', quantity: 2 }],
delivery: { deliveryType: 'DELIVERY', deliveryAreaId: 11 },
delivery: { deliveryType: 'DELIVERY', deliveryAreaId: areas[0]?.id },
paymentMethod: 'external_wallet',
});
console.log('totals', totals);
console.log('total', totals.total, 'delivery', totals.deliveryCost);

// 4. Robust single-resource lookup.
// 5. Robust single-resource lookup.
try {
await xedo.products.retrieve('PRD-does-not-exist');
} catch (err) {
Expand Down
Loading
Loading