Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
76060dc
fix: force deployment to use npm version of sdk by renaming local pac…
Codimow Feb 15, 2026
d1e925a
feat: scaffold MCP server with SSE transport and SDK integration
Codimow Feb 15, 2026
bc6c6cd
feat: implement portable Hono SSE transport for MCP server
Codimow Feb 15, 2026
fdc1acd
feat(sdk): initial integration of Effect into PayArk SDK
Codimow Feb 17, 2026
6f36d47
feat(sdk): finalize Effect integration and resources
Codimow Feb 17, 2026
0d4af0d
docs(sdk): add Effect API guide to README
Codimow Feb 17, 2026
c8e173f
refactor: extract effect sdk implementation to @payark/sdk-effect
Codimow Feb 17, 2026
472da55
refactor: apply Effect best practices to @payark/sdk-effect
Codimow Feb 17, 2026
d774baa
chore: sync monorepo with released versions
Codimow Feb 17, 2026
196b113
chore: sync
Codimow Feb 17, 2026
1763813
chore: sync
Codimow Feb 17, 2026
2dbbccf
fix: base link test
Codimow Feb 17, 2026
b4634c0
docs: clean up emojis and branding in READMEs and documentation
Codimow Feb 18, 2026
cb0bd97
docs: clean up sdk readme
Codimow Feb 18, 2026
b99ccc5
feat: implement customers and subscriptions infrastructure, api route…
Codimow Feb 19, 2026
202920d
feat(phase-8): implement DELETE /v1/customers/:id + SDK update/delete…
Codimow Feb 28, 2026
8f9d4fb
test(phase-8): add customer lifecycle integration + SDK unit tests
Codimow Feb 28, 2026
f60546d
feat(sdk): add auto-pagination via AsyncIterators
Codimow Feb 28, 2026
0877483
docs(sdk): 100% TSDoc coverage for customers and subscriptions resources
Codimow Feb 28, 2026
a56a9f5
chore: clean up codebase, remove unused imports and fix lint warnings
Codimow Mar 1, 2026
5bab47c
chore: bump sdk versions to 0.1.2
Codimow Mar 1, 2026
ceef651
refactor(sdk): remove deprecated webhooks.verify method
google-labs-jules[bot] Mar 1, 2026
fe6e159
refactor(sdk): internalize Effect for HTTP transport
Codimow Mar 1, 2026
183939a
refactor(sdk): internalize Effect for HTTP transport and fix unit tests
Codimow Mar 1, 2026
ba3db25
chore: commit effect http client fixes
Codimow Mar 1, 2026
7c27d86
refactor(api): implement Phase 09 Wave 2 refactor
Codimow Mar 1, 2026
b441e5b
feat(sdk): complete functional sdk refactor and finalize phase 09
Codimow Mar 2, 2026
f504e8e
fix(sdk): resolve build and lint issues in SDK and SDK-Effect
Codimow Mar 2, 2026
3c74a45
feat(10): establish observability foundation, advanced testing, and 1…
Codimow Mar 2, 2026
0eee5ca
feat(10): unify industrial API and SDK with HttpApi and Scalar docs
Codimow Mar 2, 2026
19fc812
fix(sdk): add proper exports for schemas
Codimow Mar 2, 2026
0dab533
fix(api): improve error handling, status codes, and sandbox mode support
Codimow Mar 3, 2026
7d10730
fix(sdk): exclude NaN from currency PBT to avoid flake
Codimow Mar 3, 2026
a63c6f0
feat(10): complete industrial API migration and resolve all workspace…
Codimow Mar 4, 2026
cd3468b
chore(sdk): sync with remote state to resolve subtree conflicts
Codimow Mar 4, 2026
9745011
refactor(sdk): unify type system and expose customer/subscription res…
Codimow Mar 4, 2026
9d100f6
fix(sdk): update test imports after type system unification
Codimow Mar 4, 2026
ea1d0d6
chore: cleanup sdk out.txt
Codimow Mar 4, 2026
6177744
Revert "chore: cleanup sdk out.txt"
Codimow Mar 4, 2026
06de4d2
chore: remove sdk out.txt
Codimow Mar 4, 2026
a503d1f
fix(sdk): resolve lint issues and optimize 429 retry-after strategy
Codimow Mar 4, 2026
604de87
refactor(sdk): optimize 429 retry logic to respect Retry-After and av…
Codimow Mar 4, 2026
d7a2eeb
chore: sync sdk stabilization and documentation
Codimow Mar 4, 2026
daa3786
fix(sdk): replace Effect-dependent types.ts with pure TS interfaces, …
Codimow Mar 4, 2026
67fa1ec
fix(sdk): honor Retry-After for 429 retries
Codimow Mar 4, 2026
7e86caf
chore(sdk): sync retry fixes and base URL from sdk repo
Codimow Mar 4, 2026
e9c58c7
fix(ci): align effect deps and repair security gates
Codimow Mar 5, 2026
0460858
docs(phase-10): complete and verify Phase 10 Industrial Grade X
Codimow Mar 7, 2026
0503a21
fix(api,db): resolve database null data issue and missing RLS policies
Codimow Mar 7, 2026
3895ccf
fix(sdk): improve DX for customer helpers, mock supabase correctly, e…
Codimow Mar 8, 2026
164a33b
chore(release): publish new versions of sdk and sdk-effect
Codimow Mar 8, 2026
aada5e4
fix(sdk): add @payark/sdk-effect as a direct dependency for standalon…
Codimow Mar 8, 2026
4a014b2
fix(sdk): update sdk-effect exports and version to unblock github act…
Codimow Mar 8, 2026
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
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun install

- name: Lint
run: bun run lint

- name: Build
run: bun run build

- name: Test
run: bun test
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
dist
.turbo
.DS_Store
*.log
coverage
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ console.log(session.checkout_url);
const payark = new PayArk({
apiKey: "sk_test_...", // Required – your project secret key
sandbox: true, // Optional – enable Sandbox Mode (default: false)
baseUrl: "http://localhost:3001", // Optional – for local dev
baseUrl: "https://payark-api.codimo-dev.workers.dev", // Optional – for local dev
timeout: 10_000, // Optional – request timeout in ms (default: 30s)
maxRetries: 2, // Optional – retries on 5xx errors (default: 2)
});
Expand Down Expand Up @@ -206,7 +206,12 @@ try {

## Retries & Idempotency

The SDK automatically retries **server errors (500, 502, 503, 504)** with exponential back-off and jitter. Client errors (4xx) fail immediately since they are deterministic.
The SDK automatically retries:

- **Server errors (`500`, `502`, `503`, `504`)** with exponential back-off and jitter.
- **Rate limits (`429`)** only when the API provides a valid `Retry-After` header.

Other client errors (`4xx`) fail immediately since they are deterministic.

- Default: 2 retries
- Back-off: 500ms → 1s → 2s (+ random jitter)
Expand Down Expand Up @@ -261,6 +266,23 @@ tests/
└── sdk.test.ts – End-to-end workflows (checkout → payment → recovery)
```

## Effect API 🚀

For users of the **[Effect](https://effect.website/)** ecosystem, we provide a dedicated package **[@payark/sdk-effect](https://www.npmjs.com/package/@payark/sdk-effect)**.

This package offers a fully functional, type-safe API with:

- **Zero Promise overhead**: Uses `@effect/platform/HttpClient` natively.
- **Runtime Validation**: Validates all responses using `@effect/schema`.
- **Typed Errors**: Tagged errors for clean matching.
- **Observability**: Built-in support for Effect's tracing and spans.

```bash
bun add @payark/sdk-effect
```

See the [@payark/sdk-effect documentation](../sdk-effect/README.md) for more details.

## License

MIT
38 changes: 38 additions & 0 deletions docs/PLAN-EFFECT-SDK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Plan: Extract @payark/sdk-effect into a standalone package

## Goal

Restore @payark/sdk to a zero-dependency package and create a high-performance @payark/sdk-effect package.

## Phase 1: Infrastructure

- [ ] Create `packages/sdk-effect` directory.
- [ ] Initialize `package.json` with `@effect/*` dependencies.
- [ ] Setup `tsup.config.ts`, `tsconfig.json`, and `bun` testing.
- [ ] Copy shared types from `packages/sdk/src/types.ts` to reaching accessible location or link them.

## Phase 2: Code Migration

- [ ] Move `src/effect/*` from `sdk` to `sdk-effect/src`.
- [ ] Refactor `http.ts` in `sdk-effect` to be completely independent of `sdk/src/client`.
- [ ] Remove `effect` dependencies from `packages/sdk/package.json`.
- [ ] Clean up `packages/sdk/src/effect` (delete directory).
- [ ] Update `packages/sdk/src/client.ts` to remove the `.effect` property.

## Phase 3: Optimization & Polish

- [ ] Implement `Effect.withSpan` for all resource methods for observability.
- [ ] Add `Config` provider for global API keys.
- [ ] Implement `Stream` support for `list` methods (for effortless pagination).
- [ ] Update `sdk-effect` tests and ensure they pass in the new location.

## Phase 4: Documentation

- [ ] Create `packages/sdk-effect/README.md`.
- [ ] Update `packages/sdk/README.md` to point to the new package.

## Verification

- [ ] `bun run build` in both packages.
- [ ] `bun test` in both packages.
- [ ] Zero-dependency check for `@payark/sdk`.
68 changes: 68 additions & 0 deletions docs/PLAN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Plan: Implement Effect in PayArk SDK

This document outlines the strategy for integrating the [Effect](https://effect.website/) ecosystem into the PayArk SDK to provide a type-safe, functional, and robust developer experience.

## Objectives

- Integrate `effect` as a core dependency for internal logic (HTTP, Error handling).
- Expose an `Effect`-based API side-by-side with the current Promise-based API.
- Leverage Effect Schema for robust runtime validation and type-safe error reporting.
- Implement specialized "Effectful" resources (e.g., `checkout.effect`, `payments.effect`).

## 1. Analysis & Infrastructure

- [ ] Research Effect Ecosystem: Study `Schema`, `HttpClient`, `Effect` patterns for SDKs.
- [ ] Define Core Effect Types: Map existing `PayArkError` to Effect `Data.Error` or tagged unions.
- [ ] Define API Schema: Use `@effect/schema` to define request/response shapes for better runtime safety.

## 2. Implementation: Core Layers

- [ ] **HTTP Layer (`HttpClient`)**:
- Optional: Refactor internal `HttpClient` to use `@effect/platform/HttpClient`.
- Map HTTP errors to specialized Effect types.
- [ ] **Error Handling**:
- Convert `errors.ts` definitions to be Effect-compatible.
- Implement a centralized error mapper from raw API responses to Effect errors.

## 3. Implementation: Resource Extension

- [ ] Update `BaseResource`: Add support for Effect-returning methods.
- [ ] **Checkout Resource**:
- Implement `checkout.createEffect()` or `checkout.effect`.
- [ ] **Payments Resource**:
- Implement `payments.listEffect()`, `payments.getEffect()`.
- [ ] **Project Resource**:
- Implement `projects.listEffect()`.

## 4. API Exposure & Documentation

- [ ] Update `PayArk` class to expose the Effect flavor.
- [ ] Update `index.ts` re-exports.
- [ ] Update README with examples of using the Effect API.
- [ ] Add `examples/` folder showing Effect integration in Next.js/Express.

## 5. Verification & Testing

- [ ] Unit Tests: Validate Effect-based methods return correct results/errors.
- [ ] Integration Tests: Use TestHttpClient to mock API responses and verify Effect behavior.
- [ ] Ensure backward compatibility with existing Promise API.

---

## Decisions

- **Namespaced API**: We will expose the Effect API via `payark.effect.*` (e.g., `payark.effect.checkout.create`). This keeps the top-level API clean while providing a sandbox for functional patterns.
- **Internal Refactor**: We will implement a new `EffectHttpClient` that leverages `@effect/platform/HttpClient`. This allows us to use Effect's native retry, timeout, and tracing capabilities without touching the legacy `fetch` logic for the Promise API.
- **Schema First**: We will integrate `@effect/schema` for the Effect API. This ensures that any data coming from the Effect side is validated at runtime, providing much better error messages than a simple `try/catch`.

## Status

- [x] Initial Research
- [x] Plan Created
- [x] `effect` package added to `packages/sdk/package.json`
- [x] Implementation Strategy Finalized
- [x] Infrastructure (Errors, HTTP Client, Config Service)
- [x] Schema Definitions (Checkout, Payment, Project, Paginated)
- [x] Resource Implementation (Checkout, Payments, Projects)
- [x] Verification (Unit & High-Level Tests)
- [x] Documentation (README)
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payark/sdk",
"version": "0.1.0",
"version": "0.1.7",
"description": "Official TypeScript SDK for the PayArk payment gateway API.",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -38,5 +38,10 @@
"tsup": "^8.0.0",
"typescript": "^5.7.0",
"@types/node": "^20.0.0"
},
"dependencies": {
"@effect/platform": "^0.94.5",
"@payark/sdk-effect": "^0.1.6",
"effect": "^3.19.19"
}
}
}
Loading