open-index/open-npm huggingface dataset:
npm package: @fleker/gents
Description: A simple types pre-processor for TypeScript
Author: Nick Felker
Latest version: 1.1.1

# 🎩 Gents

This is a project borne out of some of the limitations I found in the
TypeScript types system.

Namely, there are times when I have a map of key-value pairs that I want to use
elsewhere in the code with the benefit of type-safety. However, you can't just
convert keys of a map into a type. However, trying to maintain a separate list
of types to use in the map is cumbersome and annoying. It doesn't scale.

Gents basically helps out here. Files with the `.gents` file extension will,
when this tool is run, be executed using Node. You use `console.log` to
generate the output, which is then saved as the same filename but as the `.ts`
extension instead.

## Library Usage

```typescript
import { assert } from '@fleker/gents'

interface Item {
  label: string
}

export const ITEM_MAP = {
  potion: assert<Item>({
    label: 'Potion'
  })
}

export type ItemId = keyof typeof ITEM_MAP
```

## Example

### all-items.ts

```typescript
export const ITEM_MAP: Record<string, Item> = {
  potion: {
    label: 'Potion',
    description: 'Heals 50 HP',
    recovery: 50,
  },
  elixir: {
    label: 'Elixir',
    description: 'Heals 100 HP',
    recovery: 100,
  },
  wishdust: {
    label: 'Wish Dust',
    description: 'Heals all HP',
    recovery: Infinity
  },
}
```

### item-usage.ts

```typescript
export function useItem(player: Character, selection: ItemId) {
  const item = ITEM_MAP[selection] // I want to ensure this value is going to be a known item
  player.heal(item.recovery)
}
```

### battle-rewards.ts

```typescript
export function giveRewardAfterBattle() {
  const possibleRewards: ItemId[] = [
    'potion',
    'elixir',
    // 'wishdust', // No this is too powerful for a normal reward
  ]
}
```

Here in this example I want to ensure that every reward and item being used
is going to be a known type. If it hasn't been registered, I should be alerted.
This will also help me catch potential typos.

Over time, the number of items may grow too high to justify maintaining a
manual `ItemId` type. Rather, I'd like to go the other way, where the map then
creates the type automatically.

### type-item.gents

```javascript
const {ITEM_MAP} = require('./all-items') // Need JS transpilation of 'all-item.ts'

const validItems = Object.keys(ITEM_MAP)

console.log(`export type ItemId =`)
console.log(' ', validItems.map(item => `'${item}'`).join(' |\n  '))
```

To execute:

```
$ ./node_modules/.bin/tsc *.ts # Compile files to first!
$ node gents.js /path/to/folder
```

The output becomes:

```
$ gents ./example
Generate example/type-item.gents as example/type-item.ts
    OK
```

### type-item.ts

```typescript
export type ItemId =
  'potion' |
  'elixir' |
  'wishdust'
```

As you control the contents of the `.gents` file, you have a lot of flexibility
over what the generated file looks like.

The benefit is that, after running this process, you can then simply just:

```typescript
import {ItemId} from './type-item'
```

## Build

```
yarn build
```
npm package: @fleker/mcp-stdlib
Description: Standard library of tools that can run in MCP
Author: Nick Felker
Latest version: 1.1.0

# Felker MCP

This is a collection of tools I've written in Node.js which I can run in a local server and connect to my Gemini CLI installation or some other sort of LLM.

## Setup

You can add this MCP server by:

1. Add this setup to your LLM CLI settings:

```json
"mcpServers": {
  "mcp-stdlib": {
    "command": "npx",
    "args": ["@fleker/mcp-stdlib@latest"]
  }
}
```

2. Setup the MCP project:

- Run `npm install`
- Run `npm run execute`

It will compile and run the tools on port `8080`.

You can also go into `src/index.ts` to comment/remove any tools you don't want to run.

## Debugging

```json
  "mcp stdlib": {
    "command": "node",
    "args": ["/mnt/c/Users/handn/Development/mcp-stdlib/dist/index.js"]
  }
```
npm package: @fleker/salamander
Description: A type-safe wrapper for Firestore operations
Author: Nick Felker
Latest version: 1.0.3

# 🦎 Salamander

Salamander is a type-safe wrapper for [Cloud Firestore](https://firebase.google.com/docs/firestore).
This means that gets, sets, and updates use [TypeScript generics](https://www.typescriptlang.org/docs/handbook/2/generics.html)
to give you a bit more assurance that you're performing the correct operation.

```
npm install --save @fleker/salamander
```

## Examples

### Get

```typescript
const _db = admin.firestore()
const db = salamander(_db)

const doc = await db.collection('users').doc(uid).get<User>()
// Type-inference means that `doc` will be properly typed
```

### Set

```typescript
const _db = admin.firestore()
const db = salamander(_db)

const doc = await db.collection('users').doc(uid).set<User>({
  // Validates fields are present
  firstName: 'Nick', // Validates types of fields
})
```

### Update

```typescript
const _db = admin.firestore()
const db = salamander(_db)

const doc = await db.collection('users').doc(uid).update<User>({
  // Validates no invalid fields present
  'settings.theme': 'DARK', // Validates types of fields
})
```

### Transactions

```typescript
const _db = admin.firestore()
const db = salamander(_db)

db.runTransaction(async t => {
  const ref = db.collection('users').doc(uid)
  // Currently transactions require `ref._raw` field, exposing
  // the underlying Firestore object. This will be fixed in
  // https://github.com/Fleker/salamander/issues/1
  const user = await t.get<User>(ref._raw)
  if (user.medals === undefined) {
    user.medals = 1
  } else {
    user.medals++
  }
  // Verifies types of transaction fields exist and are proper types
  transaction.update<User>(ref._raw, {medals: user.medals})
})
```

### Queries

```typescript
interface DemoInterface {
  required: boolean
  optional?: boolean
}

const users = db.collection('users')
const ref = users.doc('user1234')
const doc = await ref.get<DemoInterface>()
const data = doc.data()

const search = await users.where('field', '==', 'query').get<DemoInterface>()
const first = new SalamanderQuery<DemoInterface>(search.docs[0])
console.log(first.data().required)
```

## Build

```
yarn build
```