open-index/open-npm huggingface dataset:
npm package: @platformatic/rpc
Description: A fastify RPC plugin for typescript applications
Author: Platformatic Inc.
Latest version: 2.75.2

# Platformatic RPC

Fastify plugin to generate a server RPC api for a Fastify application.

> [!WARNING]  
> Platformatic RPC API is in the experimental stage. The feature is not subject to semantic versioning rules.
> Non-backward compatible changes or removal may occur in any future release.
> Use of the feature is not recommended in production environments.

## Installation

```bash
npm install @platformatic/rpc-cli
npm install --save-dev @platformatic/rpc-cli
```

## Usage

1. Register the plugin in your Fastify typescript application. Pass the OpenAPI schema as an option.
OpenAPI schema will be automatically generated by the CLI command.

```ts
import { join } from 'node:path'
import { readFile } from 'node:fs/promises'
import fastify from 'fastify'
import fastifyRpc from '@platformatic/rpc'

const app = fastify()

app.register(async (app) => {
  const openapiSchemaPath = join(__dirname, 'openapi.json')
  const openapiSchemaFile = await readFile(openapiSchemaPath, 'utf8')
  const openapiSchema = JSON.parse(openapiSchemaFile)
  
  await app.register(fastifyRpc, {
    openapi: openapiSchema,
    prefix: '/rpc',
  })
})

app.listen({ port: 3042 }, (err) => {
  if (err) {
    console.error(err)
    process.exit(1)
  }
  console.log(`Server listening on http://localhost:3042`)
})
```

2. Define RPC handlers in your Fastify application. An RPC handler is a function that takes an optional options object.
All parameters will be passed as properties of the options object.

```ts
import { join } from 'node:path'
import { readFile } from 'node:fs/promises'
import fastify from 'fastify'
import fastifyRpc from '@platformatic/rpc'

const app = fastify()

app.register(async (app) => {
  const openapiSchemaPath = join(__dirname, 'openapi.json')
  const openapiSchemaFile = await readFile(openapiSchemaPath, 'utf8')
  const openapiSchema = JSON.parse(openapiSchemaFile)
  
  await app.register(fastifyRpc, {
    openapi: openapiSchema,
    prefix: '/rpc',
  })

  app.register(async (app) => {
    type User = {
      name: string
      age: number
    }

    const users = [
      { name: 'Alice', age: 30 },
      { name: 'Bob', age: 25 },
      { name: 'Charlie', age: 35 },
    ]
    
    app.rpc('getUsers', async (options: { maxAge: number }): Promise<User[]> => {
      return users.filter(user => user.age <= options.maxAge)
    })
  })
})

app.listen({ port: 3042 }, (err) => {
  if (err) {
    console.error(err)
    process.exit(1)
  }
  console.log(`Server listening on http://localhost:3042`)
})
```

3. Run the CLI command to generate the OpenAPI schema.

```bash
npx plt-rpc --ts-config ./tsconfig.json --path ./openapi.json
```

4. Start the Fastify application.

Your RPC handlers are exposed as http routes under the `/rpc` prefix. All RPC routes are POST routes.

```bash
curl -X POST http://localhost:3042/rpc/getUsers -H 'Content-Type: application/json' -d '{"maxAge": 30}'
```
npm package: @platformatic/rpc-cli
Description: A fastify RPC plugin for typescript applications
Author: Platformatic Inc.
Latest version: 2.75.2

# Platformatic RPC CLI

Fastify CLI command to generate a server RPC api for a Fastify application.

> [!WARNING]  
> Platformatic RPC API is in the experimental stage. The feature is not subject to semantic versioning rules.
> Non-backward compatible changes or removal may occur in any future release.
> Use of the feature is not recommended in production environments.

## Installation

```bash
npm install @platformatic/rpc-cli
npm install --save-dev @platformatic/rpc-cli
```

## Usage

1. Register an RPC plugin in your Fastify typescript application.
See the [Platformatic RPC](https://github.com/platformatic/platformatic/tree/v2.x/packages/rpc#usage) documentation for more information.

3. Run the CLI command to generate the OpenAPI schema.

```bash
npx plt-rpc --ts-config ./tsconfig.json --path ./openapi.json
```

4. Start the Fastify application.

Your RPC handlers are exposed as http routes under the `/rpc` prefix. All RPC routes are POST routes.

```bash
curl -X POST http://localhost:3042/rpc/getUsers -H 'Content-Type: application/json' -d '{"maxAge": 30}'
```
npm package: @platformatic/runtime
Description: Check out the full documentation for Platformatic Runtime on [our website](https://docs.platformatic.dev/docs/reference/runtime/overview).
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/runtime

Check out the full documentation for Platformatic Runtime on [our website](https://docs.platformatic.dev/docs/reference/runtime/overview).

## Install

```sh
npm install @platformatic/runtime
```

## License

Apache 2.0
npm package: @platformatic/scalar-theme
Description: Platformatic's Scalar theme for @scalar/fastify-api-reference
Author: Marc Laventure
Latest version: 3.52.0

# @platformatic/scalar-theme

Platformatic's [Scalar](https://scalar.com/) theme for `@scalar/fastify-api-reference`.

Check out the full documentation on [our website](https://docs.platformatic.dev).

## Install

```sh
npm install @platformatic/scalar-theme @scalar/fastify-api-reference
```

## Usage


## License

Apache 2.0
npm package: @platformatic/semaforo-ui
Description: Install it with `npm install @platformatic/semaforo-ui`
Author: Marco Piraccini
Latest version: 1.0.0

# Semaforo React 

Install it with `npm install @platformatic/semaforo-ui`

## `useFlags` hook

Assuming that the `newfeature` flag can be set for some users, we can define different routes for them:

```js
const flags = useFlags();

const getRoutes = flags => {
  if (flags.newfeature) {
    return <Routes>yy
      <Route
        path='/'
        element={<App />}
      />
      <Route
       path='/applications/:id'
       element={<ProtectedRoute component={Detail} />}
      />
    </Routes>
  } 
return <Routes> 
  // default routes
</Routes>
}
```
Or we can change content dynamically:


```js
const flags = useFlags();
  return <>
    {flags.newfeature && <p>You are a basic user!</p>}
  </>
``` 

## `<EnableFeature/>`
This can be used to return a component conditionally depending on a feature flag. If the flag is not set, it returns the default.

```js
<Route
  path='/applications/:id'
    element={
      <EnableFeature
        feature="newfeature"
        component={<ProtectedRoute component={BasicDetail} />}
        default={<ProtectedRoute component={Detail} />}
      />
    }
/>
```

### Flags and `namespace`
This library assumes that flags are in `user['https://platformatic.dev/flags']` so the `namespace` is `https://platformatic.dev`. If you want to change this, you must pass the `namespace` param to both `useFlags` and `<EnableFeature />`, e.g.:

```js
const flags = useFlags("https://mynamespace")
return <>
  {flags.newfeature && <p>You are a basic user!</p>}
</>

```

```js
<Route
  path='/applications/:id'
    element={
      <EnableFeature
        feature="newfeature"
        component={<ProtectedRoute component={BasicDetail} />}
        default={<ProtectedRoute component={Detail} />}
        namespace="https://mynamespace"
      />
    }
/>
```
The namespace must match the one configured in the Auth0 rule.
npm package: @platformatic/service
Description: Platformatic Service is an HTTP service built on top of [Fastify](https://fastify.dev/) that provides a foundation for building APIs with auto-generated OpenAPI documentation and GraphQL support.
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/service

Platformatic Service is an HTTP service built on top of [Fastify](https://fastify.dev/) that provides a foundation for building APIs with auto-generated OpenAPI documentation and GraphQL support.

Check out the full documentation on [our website](https://docs.platformatic.dev/docs/reference/service/overview).

## Install

```sh
npm install @platformatic/service
```

## License

Apache 2.0
npm package: @platformatic/sql-events
Description: Emit events via MQEmitter
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/sql-events

Emit entity change events via [MQEmitter](https://github.com/mcollina/mqemitter) when database records are created, updated, or deleted.

Check out the full documentation on [our website](https://docs.platformatic.dev/docs/reference/sql-events/overview).

## Install

```sh
npm install @platformatic/sql-events
```

## License

Apache 2.0
npm package: @platformatic/sql-graphql
Description: Map SQL dbs to GraphQL
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/sql-graphql

Check out the full documentation on [our website](https://docs.platformatic.dev/docs/reference/sql-graphql/overview).

## Install

```sh
npm install @platformatic/sql-graphql
```

## License

Apache 2.0
npm package: @platformatic/sql-mapper
Description: A data mapper utility for SQL databases
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/sql-mapper

Check out the full documentation on [our website](https://docs.platformatic.dev/docs/reference/sql-mapper/overview).

## Install

```sh
npm install @platformatic/sql-mapper
```

## License

Apache 2.0
npm package: @platformatic/sql-openapi
Description: Map a SQL database to OpenAPI, for Fastify
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/sql-openapi

Check out the full documentation on [our website](https://docs.platformatic.dev/docs/reference/sql-openapi/overview).

## Install

```sh
npm install @platformatic/sql-openapi
```

## License

Apache 2.0
npm package: @platformatic/swagger-ui-theme
Description: Platformatic's Swagger UI theme for @fastify/swagger-ui
Author: Matteo Collina
Latest version: 1.53.4

# @platformatic/swagger-ui-theme

Check out the full documentation on [our website](https://docs.platformatic.dev/docs/packages/sql-openapi/overview).

## Install

```sh
npm install @platformatic/swagger-ui-theme @fastiy/swagger-ui
```

## Usage


## License

Apache 2.0
npm package: @platformatic/telemetry
Description: OpenTelemetry integration for Platformatic
Author: Platformatic Inc.
Latest version: 3.52.0

# @platformatic/telemetry

[OpenTelemetry](https://opentelemetry.io/) integration for Platformatic, providing distributed tracing and metrics collection.

Check out the guides on [our website](https://docs.platformatic.dev/docs/guides/distributed-tracing).

## Install

```sh
npm install @platformatic/telemetry
```

## License

Apache 2.0
npm package: @platformatic/ui-components
Description: Platformatic UI Components
Latest version: 0.20.0

# Platformatic UI Components

**Please be aware that project is under heavy work in progress** 😇

Provides React UI Components for Platformatic Dashboards.

## Init

```
$ npm install
```

## Run demo
The project uses Vite to build and run the dev server. It's already configured to build TailwindCSS file, located in `src/styles/main.css`

```
$ npm run dev
```

## Storybook

Storybook is still a work in progress, you can start it with

```
$ npm run storybook
```

## Storybook public link

https://ui.platformatic.cloud/


## New version: commands list

```
git checkout main
git pull
npm install
npm version patch
git push origin main
npm publish
```
npm package: @platformatic/undici-cache-memory
Description: Memory cache store for the undici cache interceptor
Author: Platformatic Inc.
Latest version: 0.9.0

# @platformatic/undici-cache-memory

Memory cache store implementation for the undici cache interceptor, providing efficient in-memory caching of HTTP responses.

[![npm version](https://img.shields.io/npm/v/@platformatic/undici-cache-memory)](https://www.npmjs.com/package/@platformatic/undici-cache-memory)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)

## Installation

```bash
npm install @platformatic/undici-cache-memory
```

## Usage

```js
const { Client, interceptors } = require('undici')
const MemoryCacheStore = require('@platformatic/undici-cache-memory')

// Create a client with the cache interceptor
const client = new Client('https://example.com')
  .compose(interceptors.cache({
    store: new MemoryCacheStore()
  }))

// Make a request - first request will hit the origin
const response1 = await client.request({
  method: 'GET',
  path: '/'
})

// Second request to the same URL will be served from cache if cacheable
const response2 = await client.request({
  method: 'GET',
  path: '/'
})
```

## Configuration

The `MemoryCacheStore` constructor accepts an options object with the following properties:

```js
const store = new MemoryCacheStore({
  // Maximum number of entries to store (default: 1024)
  maxCount: 1000,
  
  // Maximum total size in bytes (default: 100MB)
  maxSize: 1024 * 1024 * 10, // 10MB
  
  // Maximum size of a single entry in bytes (default: 5MB)
  maxEntrySize: 1024 * 1024, // 1MB
  
  // Header name to parse for cache tags (default: undefined)
  cacheTagsHeader: 'cache-tag'
})
```

## Cache Invalidation

### By Cache Tag

```js
// Create the store with a header to parse for cache tags
const store = new MemoryCacheStore({
  cacheTagsHeader: 'cache-tag'
})

// Add the store to the client
const client = new Client('https://example.com')
  .compose(interceptors.cache({ store }))

// Later, invalidate all cached responses with specific tags
store.deleteTags(['product-123', 'category-456'])
```

### By Request Key

```js
// Invalidate specific paths
store.deleteKeys([
  { origin: 'example.com', path: '/products/123', method: 'GET' },
  { origin: 'example.com', path: '/categories', method: 'GET' }
])

// Or delete a specific entry
store.delete({ origin: 'example.com', path: '/products/123', method: 'GET' })
```

## Advanced Features

This implementation supports:

- Caching based on standard HTTP cache semantics
- Respect for `Vary` headers for content negotiation
- Support for `stale-while-revalidate` and `stale-if-error` directives
- Memory management with configurable limits
- Cache tag-based invalidation for efficient cache purging

## License

Licensed under [Apache-2.0](./LICENSE).
npm package: @platformatic/wasm-utils
Description: High-performance WebAssembly utilities for Node.js.
Author: Platformatic Inc.
Latest version: 0.2.1

# @platformatic/wasm-utils

High-performance WebAssembly utilities for Node.js.

This package provides fast native-style primitives implemented in Rust and shipped as a `.wasm` module:

- CRC32C checksums
- LZ4 frame compression/decompression
- Snappy compression/decompression

## Requirements

- Node.js `>= 22.19.0`

## Installation

```bash
npm i @platformatic/wasm-utils
```

## Usage

```js
import { crc32c, lz4Compress, lz4Decompress, snappyCompress, snappyDecompress } from '@platformatic/wasm-utils'

const input = Buffer.from('test data for compression')

const crc = crc32c(input)
console.log(crc) // 32-bit unsigned integer

const lz4 = lz4Compress(input)
const lz4Back = lz4Decompress(lz4)

const snappy = snappyCompress(input)
const snappyBack = snappyDecompress(snappy)

console.log(lz4Back.toString()) // test data for compression
console.log(snappyBack.toString()) // test data for compression
```

## API

### `crc32c(data)`

Computes CRC32C for the input.

- **Input:** `Buffer | Uint8Array | DynamicBuffer`
- **Output:** `number` (unsigned 32-bit)

### `lz4Compress(data)`

Compresses input using LZ4 frame format.

- **Input:** `Buffer | DynamicBuffer`
- **Output:** `Buffer`

### `lz4Decompress(data)`

Decompresses LZ4 frame data.

- **Input:** `Buffer | DynamicBuffer`
- **Output:** `Buffer`

### `snappyCompress(data)`

Compresses input using Snappy.

- **Input:** `Buffer | DynamicBuffer`
- **Output:** `Buffer`

### `snappyDecompress(data)`

Decompresses Snappy data.

- **Input:** `Buffer | DynamicBuffer`
- **Output:** `Buffer`

## Development

```bash
pnpm install
pnpm test
```

### Build

```bash
pnpm build
```

`pnpm build` compiles TypeScript and rebuilds the native WebAssembly module (via Docker in `native/docker-compose.yml`).

## License

Apache-2.0 - See [LICENSE](LICENSE) for more information.
npm package: @platformatic/watt-plugin-kafka-health
Description: Watt health plugin for @platformatic/kafka
Author: Platformatic Inc.
Latest version: 0.1.0

# @platformatic/watt-plugin-kafka-health

A plugin for monitoring `@platformatic/kafka` consumers lag in Watt applications.

## Overview

This plugin monitors consumers lag and sends health signals when consumers are lagging behind the acceptable threshold.

It integrates with Watt's health monitoring system to provide real-time alerts when Kafka consumers cannot keep up with message production.

## Features

- **Consumer Lag Monitoring**: Tracks lag for all Kafka consumers in your application
- **Configurable Thresholds**: Set global and per-topic maximum allowed lag values
- **Smart Health Signals**: Only sends alerts when lag is excessive AND there are available consumers to scale
- **Grace Period**: Configurable delay before monitoring begins to avoid false positives during startup
- **Auto-discovery**: Automatically monitors all Kafka consumers created in the application

## Installation

```bash
npm install @platformatic/watt-plugin-kafka-health
```

## Usage

### Basic Usage

```javascript
import { create } from '@platformatic/watt-plugin-kafka-health'

// Create the health plugin with basic configuration
const healthPlugin = create({
  maxAllowedLag: 1000, // Global max lag threshold
  interval: 60000, // Check interval in milliseconds
  gracePeriod: 5000, // Wait before starting monitoring
  topics: {
    'high-priority': 500, // Custom lag threshold for specific topics
    'low-priority': 2000
  }
})
```

### Configuration Options

| Option          | Type                   | Default | Description                                        |
| --------------- | ---------------------- | ------- | -------------------------------------------------- |
| `maxAllowedLag` | number                 | 1000    | Global maximum allowed consumer lag                |
| `interval`      | number                 | 60000   | Interval for lag monitoring checks in milliseconds |
| `gracePeriod`   | number                 | 1000    | Delay before monitoring starts in milliseconds     |
| `topics`        | Record<string, number> | {}      | Per-topic lag thresholds                           |

### Health Signals

When lag exceeds thresholds, the plugin emits health signals with the following structure:

```javascript
{
  type: 'kafka:topics:lag',
  value: 1500,  // Current lag value
  description: 'Member consumer-123 of consumers group my-group is lagging for topic my-topic and there are available consumers in the group.'
}
```

## Requirements

- Node.js >= 22.19.0
- `@platformatic/kafka` ^1.20.0 as peer dependency

## License

Apache-2.0 - See [LICENSE](LICENSE) for more information.

## Contributing

Contributions are welcome! Please check the [issues page](https://github.com/platformatic/watt-plugin-kafka-health/issues) for known issues and feature requests.

## Support

- [GitHub Issues](https://github.com/platformatic/watt-plugin-kafka-health/issues)
- [Platformatic Documentation](https://docs.platformatic.dev/)
npm package: @platformatic/world
Description: Platformatic World adapter for Vercel Workflow DevKit — drop-in World implementation for self-hosted Kubernetes
Latest version: 0.6.2

# @platformatic/world

Drop-in [World](https://useworkflow.dev/docs/deploying) implementation for [Vercel Workflow DevKit](https://useworkflow.dev) on self-hosted Kubernetes. Routes workflow state through a central [Workflow Service](https://github.com/platformatic/platformatic-world/tree/main/packages/workflow) that pins each run to the deployment version that started it.

## Installation

```bash
npm install @platformatic/world
```

## Usage

### With the Vercel Workflow SDK

Set two environment variables and the SDK discovers the world automatically:

```bash
WORKFLOW_TARGET_WORLD=@platformatic/world
PLT_WORLD_SERVICE_URL=http://localhost:3042
```

Your app needs to call `world.start()` once on server startup to register a queue handler. In Next.js, use `instrumentation.ts`:

```typescript
// instrumentation.ts
export async function register() {
  if (process.env.PLT_WORLD_SERVICE_URL) {
    const { createWorld } = await import('@platformatic/world')
    const world = createWorld()
    await world.start?.()
  }
}
```

For other frameworks, call `world.start()` during your server's startup.

In Kubernetes with [ICC](https://icc.platformatic.dev/), handler registration is automatic — `world.start()` is a no-op.

### Direct usage

```typescript
import { createWorld } from '@platformatic/world'

const world = createWorld({
  serviceUrl: 'http://localhost:3042',
  appId: 'my-app',
  deploymentVersion: 'v1',
})

// world implements the full World interface:
// storage (runs, events, steps, hooks), queue, streams, encryption
```

## Configuration

### `createWorld(options?)`

High-level factory with automatic config resolution from environment variables.

| Option | Env var | Default | Description |
|---|---|---|---|
| `serviceUrl` | `PLT_WORLD_SERVICE_URL` | *required* | Workflow Service URL |
| `appId` | `PLT_WORLD_APP_ID` | `package.json` name | Application identifier |
| `deploymentVersion` | `PLT_WORLD_DEPLOYMENT_VERSION` | K8s label or `'local'` | Deployment version |

In Kubernetes, the deployment version is auto-detected from the pod's `plt.dev/version` label via the K8s API.

### `createPlatformaticWorld(config)`

Low-level factory — all fields required, no env var resolution.

```typescript
import { createPlatformaticWorld } from '@platformatic/world'

const world = createPlatformaticWorld({
  serviceUrl: 'http://localhost:3042',
  appId: 'my-app',
  deploymentVersion: 'v1',
})
```

## License

Apache-2.0