open-index/open-npm huggingface dataset:
npm package: @subway-js/subway
Description: Subway is a personal project from [danilorossi](https://github.com/danilorossi) that explores the idea of bringing **event sourcing & CQRS** to the browser for micro-frontends development.
Author: Danilo Rossi
Latest version: 0.17.2


# SubwayJS  &middot; [![Build & Unit Tests](https://github.com/subway-js/subway/workflows/Build%20&%20Unit%20Tests/badge.svg?branch=master)](https://github.com/subway-js/subway/actions?query=workflow%3A%22Build+%26+Unit+Tests%22) [![Codecov](https://codecov.io/gh/subway-js/subway/branch/master/graph/badge.svg)](https://codecov.io/gh/subway-js/subway) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/subway-js/subway/blob/master/LICENSE) [![npm version](https://badge.fury.io/js/%40subway-js%2Fsubway.svg)](https://badge.fury.io/js/%40subway-js%2Fsubway) ![npm version](https://img.shields.io/badge/stability-alpha-green)



Subway is a personal project from [danilorossi](https://github.com/danilorossi) that explores the idea of bringing some of the patterns and benefits of **Domain Driven Design, Event Sourcing and CQRS** to the browsers, for frontend and micro-frontends development.

That's a big statement, so let's first of all clarify how those patterns inspire Subway.

From **Domain Driven Design**:
- Subway promotes a software design that identifies clear sub-systems and boundaries, which not only leads to a more self-explaining codebase structure, it also helps shaping your development team structure, and prepares you for an easy transition to a micro-frontends model

From **Event Sourcing and CQRS**:
- Subway provides a *commands & events* way to describe a system behaviour that's easy to understand and to talk about. It also promotes the decoupling of each sub-system, which makes it easy to switch implementations and add new features


## Disclaimer

> **SubwayJS is an early stage work in progress** 

I am working on some projects (check the SubwayJS GitHub account or keep reading) as a way to shape the final API, architecture, and features of SubwayJS: please be aware that

- the codebase structure, API and this documentation are in a very dynamic state at the moment
- the projects I am working on shouldn't be consider a final example of how to use this library or how to write/organize a codebase in general
- projects themselves are changing frequently and may not be using the latest SubwayJS version when you read this

## Documentation

1. [SubwayJS concepts and design](./docs/concepts.md)
  
    Visit this section to understand what SubwayJS is and the model behind it

2. [Projects](./docs/projects.md)
    List of projects/examples I am working on to shape SubwayJS

3. [How to install & API](./docs/usage.md)

    Very basic API documentation


## Next steps

- Finalise the API design and documentation
- Codebase refactoring & testing
- add CI/CD pipeline
- ...
npm package: @subway-js/subway-react
Description: Tools for developing your SubwayJS app with React
Author: subway-js
Latest version: 0.1.2

# subway-react

> Tools for developing your SubwayJS app with React

[![NPM](https://img.shields.io/npm/v/subway-react.svg)](https://www.npmjs.com/package/subway-react) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save @subway-js/subway-react
```

## Usage

```jsx
import React, { Component } from 'react'

import { 
  Subway,
  useConsumeComponent,
  useObserveAggregateState,
  useReactToEvent
} from 'subway-react'

const Example = () => {
  // ...
}
```
Check [subway-react-ecommerce](https://github.com/subway-js/subway-react-ecommerce) for real usage examples.

## License

MIT © [subway-js](https://github.com/subway-js)

---

This hook is created using [create-react-hook](https://github.com/hermanya/create-react-hook).
npm package: @subx-dev/sdk
Description: SubX JavaScript SDK for subscription management
Latest version: 0.2.1

**English** | [한국어](README.ko.md)

# @subx-dev/sdk

Core JavaScript/TypeScript SDK for [SubX](https://subx.dev) — in-app subscription management platform.

This package provides a low-level HTTP client for the SubX API. For React Native apps, use [`@subx-dev/react-native`](https://github.com/mikusnuz/subx-sdk/tree/main/packages/react-native) instead.

## Installation

```bash
npm install @subx-dev/sdk
```

## Quick Start

```ts
import { SubXClient } from '@subx-dev/sdk';

const client = new SubXClient({
  apiKey: 'your_subx_api_key',
  baseUrl: 'https://api.subx.dev', // optional
});

// Fetch offerings
const { currentOffering, allOfferings } = await client.getOfferings();

// Identify a subscriber
const subscriber = await client.upsertSubscriber('user-123', {
  plan: 'pro',
});

// Submit a receipt
const result = await client.submitReceipt('user-123', {
  store: 'app_store',
  receiptData: 'base64...',
  productId: 'com.app.pro.monthly',
});

// Grant/revoke entitlements
await client.grantEntitlement('user-123', 'pro');
await client.revokeEntitlement('user-123', 'pro');

// Track events
await client.trackEvent({
  appUserId: 'user-123',
  eventName: 'paywall_viewed',
  properties: { source: 'settings' },
});
```

## API Reference

### `new SubXClient(config)`

| Option | Type | Required | Description |
|--------|------|----------|-------------|
| `apiKey` | `string` | Yes | SubX API key |
| `baseUrl` | `string` | No | API base URL (default: `https://api.subx.dev`) |

### Methods

| Method | Returns | Description |
|--------|---------|-------------|
| `getOfferings()` | `OfferingsResponse` | Fetch all offerings |
| `getOfferingPaywalls(offeringId)` | `PaywallsResponse` | Fetch paywalls for an offering |
| `getSubscriber(appUserId)` | `SubscriberResponse` | Get subscriber info |
| `upsertSubscriber(appUserId, attributes?)` | `SubscriberResponse` | Create or update subscriber |
| `submitReceipt(appUserId, receipt)` | `ReceiptResponse` | Submit store receipt |
| `getSubscriberOfferings(appUserId)` | `OfferingsResponse` | Get subscriber-specific offerings |
| `grantEntitlement(appUserId, entitlementId, expiresAt?)` | `{ message }` | Grant entitlement |
| `revokeEntitlement(appUserId, entitlementId)` | `{ message }` | Revoke entitlement |
| `trackEvent(event)` | `void` | Track analytics event |

### Types

All types are exported from the package:

```ts
import type {
  SubXConfig,
  Offering,
  Package,
  Product,
  OfferingsResponse,
  Subscription,
  Entitlement,
  SubscriberResponse,
  Paywall,
  PaywallsResponse,
  ReceiptData,
  ReceiptResponse,
  TrackEventData,
  SubXError,
} from '@subx-dev/sdk';
```

## Related Packages

| Package | Description |
|---------|-------------|
| [`@subx-dev/react-native`](https://github.com/mikusnuz/subx-sdk/tree/main/packages/react-native) | React Native SDK with hooks and provider |

## License

MIT