open-index/open-npm huggingface dataset:
npm package: @qte/cra-template
Description: A cra-template with react-redux, routing, config, and more!
Latest version: 1.2.1

# @qte/cra-template

A custom create-react-app template with sensible default code already done for you!

The project contains the following

- Typescript
- Redux and react-redux
- React-router
- A config module with support for multiple environments
- Eslint & Prettier
- Testing with jest
- Github workflows

## Installation

When creating a new react-project, run the following command:

```sh
yarn create react-app my-app --template @qte
```
npm package: @qte/nest-axios
Description: This small library is a rewrite of [@nestjs/axios](https://github.com/nestjs/axios) returning `Promises` instead of `Observables`.
Author: Jakob Råhlén
Latest version: 1.0.3

# @qte/nest-axios
This small library is a rewrite of [@nestjs/axios](https://github.com/nestjs/axios) returning `Promises` instead of `Observables`.

## Installation
```bash
$ yarn add @qte/nest-axios
```

## License
@qte/nest-axios is [MIT licensed](LICENSE).
npm package: @qte/nest-border-patrol
Description: A package for validating NestJS HTTP controller endpoints using zod. Integrates with NestJS swagger.
Latest version: 0.3.0

# Nest Border Patrol

A package for validating NestJS HTTP controller endpoints using zod. Integrates
with NestJS swagger.

## Getting started

Install the package:

```bash
npm i @qte/nest-border-patrol
```

```bash
yarn add @qte/nest-border-patrol
```

```bash
pnpm add @qte/nest-border-patrol
```

You also will need the following dependencies if you haven't installed them
already

- @nestjs/common
- @nestjs/swagger
- rxjs
- zod

## Usage

Create a `new HttpBorder(options)` instance. Options are the following

- `requestBody` (optional) - Any Zod schema
- `parameters` (optional)
  - `path` (optional) - A string record of Zod schemas where the key is the name
    of your URL parameters
  - `query` (optional) - A string record of Zod schemas
- `responses` - A record with keys of `HttpStatus` and values of any zod schema

To make use of the newly created `HttpBorder` you decorate your controller
endpoint with the `@UseHttpBorder()` decorator. This will in turn validate the
incoming request and outgoing responses with the supplied schemas in the
`HttpBorder` constructor.

The `@UseHttpBorder()` decorator will also decorate your controller method with
matching `@nestjs/swagger` decorators for generating OpenAPI schemas.

### Example

```ts
import { Body, Controller, HttpStatus, Param, Post, Query } from '@nestjs/common';
import { z } from 'zod';
import {
  HttpBorder,
  InferFromHttpBorder
} from '@qte/nest-border-patrol';

// Create a border
const border = new HttpBorder({
  requestBody: z.object({
    name: z.string(),
  }),
  parameters: {
    path:  {
      someParam: z.string(),
    },
    query: {
      someQueryParam: z.string().optional(),
    },
  }
  responses: {
    [HttpStatus.CREATED]: z.object({
      publicData: z.string(),
    }),
  }
});

@Controller()
export class SampleController {
  @Post('/:someParam')
  @UseBorder(border)
  public async post(
    // Will be typed as:
    //  { name: string }
    @Body() body: InferFromHttpBorder<typeof border, 'requestBody'>,
    // Will be typed as:
    // { someQueryParam: string | undefined; }
    @Query() query: InferFromHttpBorder<typeof border, 'queryParameters'>,
    // Will be typed as:
    // { someParam: string; }
    @Param() params: InferFromHttpBorder<typeof border, 'pathParameters'>
  ): // Will be typed as:
  // HttpBorderResponse<HttpStatus.CREATED, { publicData: string; }>
  Promise<InferFromHttpBorder<typeof border, 'response'>> {
    return border.createResponse(HttpStatus.CREATED, {
      publicData: 'Hello world',
      // This property will stripped from the response as
      // it is not defined in the response schema.
      sensitiveData: 'password',
    });
  }
}
```

## Versioning

Until the package reaches 1.0.0 all updates may be breaking.

## Potential roadmap

- Validating headers incoming and outgoing
- OpenAPI example values
- Test typings using `// @ts-expect-error`
- Validate query params as an object (OpenAPI issues)
- Validate unnamed query params
npm package: @qte/nest-config
Description: A module for advanced configurations in Nest, supporting YAML, Env values, and Google Secret Manager secrets. The module aims to provide flexibility, while also providing a great deal of safety. One of the guiding principles is to fail fast. The module wi
Author: Jakob Råhlén
Latest version: 1.0.2

# @qte/nest-config
A module for advanced configurations in Nest, supporting YAML, Env values, and Google Secret Manager secrets.
The module aims to provide flexibility, while also providing a great deal of safety. One of the guiding principles is to fail fast. The module will throw early errors crashing the application if anything goes wrong.

## Installation

```bash
$ yarn add @qte/nest-config
```

Note that `zod` is a peer-dependency and must be installed separately.

## Quick start
Import and configure the module in the following way
```ts
import { ConfigModule, ConfigService, DEVELOPMENT } from '@qte/nest-config'
import { z } from 'zod'

const mySchema = z.object({
  port: z.number()
}).strict()
type Config = z.infer<typeof mySchema>

// The module is global
ConfigModule.forRoot({
  env: DEVELOPMENT,
  schema: mySchema,
  configPath: './config' // Optional argument, defaults to the ./config directory relative to the running node process
})

// Later on in any other Nest provider or controller
const myConfig = ConfigService.getConfig<Config>()
```

You must create the following files
```bash
touch ./config/index.yaml # This is your base configuration
touch ./config/env.development.yaml # This file is loaded if env is DEVELOPMENT
touch ./config/env.staging.yaml # This file is loaded if env is STAGING
touch ./config/env.production.yaml # This file is loaded if env is PRODUCTION
```

The final configuration is built from first parsing `index.yaml`, then merging it with the environment specific configuration.

### Duplicate keys
Duplicate object keys are merged recursively, while all other duplicates are overriden, and the environment configuration is prioritised.

```yaml
# index.yaml
database:
  user: postgres
  password: development
```
```yaml
# env.production.yaml
database:
  password: super-secret-prod-password # Ideally read from a secret
```
Merges to
```ts
const config = {
  database: {
    user: 'postgres',
    password: 'super-secret-prod-password',
  }
}
```

### Env and Secrets
Configuration files can contain `ENV` values and Google Secrets Manager secrets. See examples below
```yaml
database:
  host:
    $from:
      env: DATABASE_ENV # Will read PROCESS.ENV.DATABASE_ENV
  password:
    $from:
      secret: projects/some-gcp-project/secrets/some-secret/versions/latest # Will read the secret from GCP
```

the parsed configuration will match the following schema
```ts
z.object({
  database: z.object({
    host: z.string(),
    password: z.string(),
  }),
})
```

## Cache
The package caches secrets in development mode. Clear the cache by running
```sh
rm -rf $TMPDIR/nest-config
```

You can also disable caching by setting `cache: false` in the module options

## License
@qte/nest-config is [MIT licensed](LICENSE).
npm package: @qte/nest-google-calendar
Description: Thin wrapper around Google Calendar API for Nest.
Author: Jakob Råhlén
Latest version: 1.0.0

# Nest Google Calendar API wrapper

Thin wrapper around Google Calendar API for Nest.

## Installation

```bash
yarn add @qte/nest-google-calendar
```

## Usage

```typescript
// *.module.ts
import { Module } from '@nestjs/common'
import { GoogleCalendarModule } from '@qte/nest-google-calendar'

@Module({
  imports: [GoogleCalendarModule],
  // ...
})
export class AppModule {}
```

```typescript
// *.service.ts
import { Injectable } from '@nestjs/common'
import { GoogleCalendarService } from '@qte/nest-google-calendar'

@Injectable()
export class MyService {
  constructor(private readonly googleCalendarService: GoogleCalendarService) {}

  async getEvents() {
    const events = await this.googleCalendarService.getEvents({
      timeMin: new Date('2023-01-01'), // Get all events that start after this date
      timeMax: new Date('2023-12-31'), // Get all events that start before this date
      access_token: '...', // Google OAuth2 access token
    })
    return events
  }
}
```

# API Reference

The package uses the [Google Calendar v3 API](https://developers.google.com/calendar/api/v3/reference)
npm package: @qte/nest-google-secret-manager
Description: A module for reading Google Secret Manager secrets in Nest.
Author: Jakob Råhlén
Latest version: 1.0.1

# @qte/nest-google-secret-manager
A module for reading Google Secret Manager secrets in Nest.

## Installation

```bash
$ yarn add @qte/nest-google-secret-manager
```

## Quick start
Import and use the module with a list of secrets to preload.
```ts
SecretManagerModule.register({
  secrets: ['project/some-project/secrets/some-secret/versions/latest'],
})
```

Use the `SecretManagerService` to get any preloaded secret, or to dynamically load more secrets.

## License
@qte/nest-google-secret-manager is [MIT licensed](LICENSE).
npm package: @qte/nest-spar-personsok
Description: Nest module for SPAR Personsök.
Author: Jakob Råhlén
Latest version: 1.2.4

# Nest SPAR Personsök

Nest module for SPAR Personsök.

## Installation

```bash
yarn add @qte/nest-spar-personsok
```

## Usage

```typescript
import { Module } from '@nestjs/common'
import { SparPersonsokModule } from '@qte/nest-spar-personsok'
import * as fs from 'fs'

const pfx = fs.readFileSync('path/to/pfx')

@Module({
  imports: [
    // Note that register accepts an empty object in non-production environments
    SparPersonsokModule.register({
      pfx: pfx,
      passphrase: 'passphrase',
      production: true,
      identifieringsinformation: {
        KundNrLeveransMottagare: '500243',
        KundNrSlutkund: '500243',
        UppdragId: '637',
        SlutAnvandarId: 'qte-230819',
      },
    }),
  ],
})
export class AppModule {}
```

```typescript
import { SparPersonsokService } from '@qte/nest-spar-personsok'

@Injectable()
export class AppService {
  constructor(private readonly sparPersonsokService: SparPersonsokService) {}

  async search() {
    const result = await this.sparPersonsokService.personsok({
      IdNummer: '198007199295',
    })
    console.log(result)
  }
}
```
npm package: @qte/qns
Description: qte node service
Author: Jakob Råhlén
Latest version: 0.0.5

qns
=============
![Unit Tests](https://github.com/qteab/qns/workflows/Unit%20Tests/badge.svg)

# Installation
Install the package with
```bash
yarn add @qte/qns
```
or
```bash
npm install @qte/qns
```
npm package: @qte/react-native-firebase-chat
Description: test
Author: QTE Development AB
Latest version: 0.5.15

# @qte/react-native-firebase-chat

Firebase chats the qte way

## Installation

```sh
npm install @qte/react-native-firebase-chat
```

## Usage

Add the google-services.json to example/android/app and GoogleService-Info.plist to example/ios. These you can get from firebase

## Firebase Data structure from @qte/nest-firebase-chat

```sh
├── users
│   └── userId
│       ├── name (string)
│       └── avatar (URL string)
└── chats
    └── chatId
        ├── creatorId (string)
        ├── creatorRef (reference to user document)
        ├── memberIds (array of references to user documents)
        ├── name (string)
        ├── lastMessage (reference to message document)
        ├── createdAt (ISO string)
        ├── updatedAt (ISO string)
        └── messages
            └── messageId
                ├── senderId (string)
                ├── senderRef (reference to user document)
                ├── content (string)
                ├── readByIds (array of references to user documents)
                ├── createdAt (ISO string)
                └── updatedAt (ISO string)
```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

---

Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
npm package: @qteatime/glomp
Description: Pack arbitrary files as single-file web archives.
Author: Q.
Latest version: 0.1.1

# Glomp

Glomp is a very straight-forward packaging tool for JavaScript projects. It does not (and will not ever) support plugins, semantics are fixed and minimal so that it can be realistically audited by other humans _and_ used in the compilation toolchain for a trusted, security-oriented platform.

Glomp supports:

- Resolving modules using Node's module algorithm **for relative paths**;

- Static require() calls to JavaScript and JSON files.

Glomp does not support:

- Resolving references to node_modules packages. This restriction might be lifted in the future, but for now Glomp leaves them as-is in the code and lets Node.js do the resolution at runtime. Browsers will throw an error at runtime for these references, if they're evaluated.

- AMD or any module system different from Node's built-in one. Browser packages are expected to rely on an exported global name.

- Sourcemaps;

- Automatic polyfilling or magic requires, which may load unaudited modules;

- Plugins or any other form of user extension of its semantics, as we can't prove those are sensible with the rest of the compiler — you should not be putting unaudited packages anywhere near trusted/secure packages anyway;

- Native ECMAScript modules (Glomp works with CommonJS);

- Dead code elimination, traced as in tree-shaking or not;

- Hot-patching, incremental builds, and other developer niceties. While they aren't impossible to secure, they increase the code size considerably and make it harder to audit or reason about the compilation pipeline. Use glomp to generate production builds.

- Minification. Kate and Crochet do not need to worry about module sizes as they're aimed at offline use cases, and minification requires a substantially more complex compiler.

## Usage

With the CLI tool:

```shell
$ glomp my-file.js --out my-bundle.js --name MyBundle
```

With the Node module:

```js
const FS = require("fs");
const { pack } = require("@qteatime/glomp");
const root_dir = process.cwd();
// 'root_dir' is used as the root directory for resolving filenames,
// and affects only the '__dirname' and '__filename' magic variables on
// compiled modules.
const code = pack(FS.readFileSync("my-file.js"), root_dir, "MyBundle");
FS.writeFileSync("my-bundle.js", code);
```

This will generate a bundle that can be require'd on either browsers or Node.

## Known issues

Glomp currently transforms JavaScript using regular expressions. This is reasonable if all your files are trusted and you're not including any third-party code (which _is_ the case for Kate). You should not use it if your dependency graph includes code that wasn't written by you until Glomp adds a proper JavaScript parser.

## Licence

Glomp is (c) Q. and released under the MIT license.
npm package: @qtikit/mathml-to-latex
Description: A JavaScript tool to convert mathml string to LaTeX string
Author: Alexandre Nunes
Latest version: 1.3.7

# mathml-to-latex

It converts [MathML](https://en.wikipedia.org/wiki/MathML) to [LaTeX](https://pt.wikipedia.org/wiki/LaTeX).

## Instalation

If you use NPM

```
npm install mathml-to-latex --save
```

If you use Yarn

```
yarn add mathml-to-latex
```

## Usage

```javascript
const Mathml2latex = require('mathml-to-latex');

const mathml = `
      <math>
        <mrow>
          <mn>a</mn>
          <mo>+</mo>
          <mn>b</mn>
        </mrow>
      </math>
      `;

Mathml2latex.convert(mathml);
// => a + b
```

```javascript
const Mathml2latex = require('mathml-to-latex');

const mathml = `
    <math>
        <mrow>
            <mi>A</mi>
            <mo>=</mo>
            <mfenced open = "[" close="]">
            <mtable>
                <mtr>
                <mtd><mi>x</mi></mtd>
                <mtd><mi>y</mi></mtd>
                </mtr>
                <mtr>
                <mtd><mi>z</mi></mtd>
                <mtd><mi>w</mi></mtd>
                </mtr>
            </mtable>
            </mfenced>
        </mrow>
    </math>
    `;

Mathml2latex.convert(mathml);
// => A = \begin{bmatrix} x & y \\ z & w \end{bmatrix}
```
npm package: @qtk-ui/qb-verify
Description: A simple scroll verify vue component for vanchu tech. Readme for usage. 
Author: Alan Huang
Latest version: 0.2.1

# qb-verify

## Installing

Using npm:

```bash
$ npm install qb-verify
```

## Usage
    
(In main.js)
```js
import QbVerify from 'qb-verify'

Vue.use(QbVerify, {
  appId: 'your appId' // require
})
```

(In your controller)
```js
// getVerifyCode
  let params = {
    mobile: 'user mobile', // require
    type: 'register'       // require, such as 'register'
  }
  this.$verification.getVerifyCode(params).then(_ => {
    // 飘字提示 发送成功
  }).catch(err => {
    if (err && err.status) {
      switch (err.status) {
        case 1: // denied 禁止发送验证码
          // 飘字提示
          break
        case 3: // FREQUENCY_LIMIT(频率限制)
          // 飘字提示
          break
        default:
          break
      }
    } else {
      // 未知错误
    }
  })

// checkVerifyCode
  let params = {
    mobile: 'user mobile', // require
    verifyCode: '1234',    // require, captcha
    type: 'register'       // require, such as 'register'
  }
  this.$verification.checkVerifyCode(params).then(res => {
  }).catch(err => {
  })
```
npm package: @qtk/tcp-framework
Description: qtk微服务框架体系一环，为最底层的异步tcp请求框架。框架内部维护连接心跳，默认每20秒发送一个心跳包，30秒连接无响应超时。 **请求体/响应体必须为Buffer形式，框架不解析请求体/响应体内容，故数据协议开发者可以自行定义**。
Author: sophia && skip
Latest version: 3.0.1

# qtk-tcp-framework
qtk微服务框架体系一环，为最底层的异步tcp请求框架。框架内部维护连接心跳，默认每20秒发送一个心跳包，30秒连接无响应超时。 **请求体/响应体必须为Buffer形式，框架不解析请求体/响应体内容，故数据协议开发者可以自行定义**。

## Server初始化
- **host:** 监听ip，默认localhost
- **port:** 监听端口
- **heartbeat:** 心跳包间隔(单位秒)，默认20
- **timeout:** 连接无响应超时(单位秒)，默认30。**(服务端不响应客户端请求情况不算连接超时，此时还有心跳包，故不会触发超时)**

```js
const server = new Server({ port: 8212 });
```

## Client初始化
- **host:** 服务端ip，默认localhost
- **port:** 服务端端口
- **timeout:** 连接无响应超时(单位秒)，默认30。**(服务端不响应客户端请求情况不算连接超时，此时还有心跳包，故不会触发超时)**

```js
const client = new Client({ port: 8212 });
```

## 客户端发送请求
- **uuid:** 36位uuid(含-), 每次请求的唯一标识
- **data:** 请求体buffer


```js
client.send({ uuid: uuid(), data: Buffer.from('echo') });
```

## 服务端接受请求
服务端监听data事件，回调函数包含两个参数:
- **socket:** 客户端socket对象
- **请求体信息:**
    - **uuid:** 客户端某次请求的uuid
    - **data:** 请求体buffer

```js
server.on('data', (socket, {uuid, data}) => {

})
```

## 服务端响应请求
服务端监听data事件，收到请求后，调用``send``方法响应本次客户端请求。``send``方法包含两个参数:

- **socket:** 客户端socket对象
- **响应体信息:**
    - **uuid:** 响应客户端某次请求的uuid
    - **data:** 响应体buffer

```js
server.on('data', (socket, {uuid, data}) => {
    server.send(socket, {uuid, data}); //原封不动返回data
})
```

## 客户端接受服务端响应
客户端监听data事件，回调函数包含一个参数:
- **响应体信息:**
    - **uuid:** 客户端某次请求的uuid
    - **data:** 响应体buffer

```js
client.on('data', ({uuid, data}) => {

})
```

## 系统事件

### Server
- **started:** 服务端启动
- **stopped:** 服务端停止
- **connected:** 新的客户端连接，参数: (socket)
- **closed:** 客户端断开，参数: (socket)
- **exception:** 系统出错，参数: (socket, error)
- **data:** 客户端请求, 参数: (socket, {uuid, data})

### Client
- **connected:** 连接服务端成功
- **closed:** 连接关闭
- **exception:** 系统出错，参数: (error)
- **data:** 服务端响应, 参数: ({uuid, data})

## Demo
```js
//server.js
const Server = require('@qtk/tcp-framework').Server;
const server = new Server({ port: 8212 });

server.on('data', (socket, {uuid, data}) => {
    switch(data.toString('utf8')) {
        case "echo":
            server.send(socket, {uuid, data});
            break;
        case "delayed_echo":
            setTimeout(() => {
                server.send(socket, {uuid, data});
            }, 3000);
            break;
        default:
            break;
    }
});

server.start();

//client.js
const Client = require('@qtk/tcp-framework').Client;
const uuid = require('uuid').v1;
const port = 8212;

client.on('data', ({uuid, data}) => {
    console.log(`got response, uuid: ${uuid}, data: ${data.toString('utf8')}`);
});

client.send({ uuid: uuid(), data: Buffer.from('echo') });

```

## 备注
- 3.0版本与之前的版本协议不兼容，请勿混合使用
- 3.0版本比2.0版性能提升13%