open-index/open-npm huggingface dataset:
npm package: @leancodepl/api-binary
Description: Core binary data types for API communication
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/api-binary

Type-safe binary data handling for API communication.

## Installation

```bash
npm install @leancodepl/api-binary
# or
yarn add @leancodepl/api-binary
```

## API

### `toRaw(apiBinary)`

Converts ApiBinary to raw string representation.

**Parameters:**

- `apiBinary: ApiBinary` - The ApiBinary value to convert

**Returns:** Raw string representation of the binary data

### `fromRaw(apiBinaryRaw)`

Converts raw string to ApiBinary type.

**Parameters:**

- `apiBinaryRaw: ApiBinaryRaw` - The raw string representation to convert

**Returns:** ApiBinary instance from the raw string

## Usage Examples

### Basic Conversion

```typescript
import { fromRaw, toRaw } from "@leancodepl/api-binary"

const binary = fromRaw("SGVsbG8gV29ybGQ=")
const raw = toRaw(binary)
console.log(raw) // 'SGVsbG8gV29ybGQ='
```
npm package: @leancodepl/api-binary-blob
Description: Binary data conversion utilities for Blob handling
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/api-binary-blob

Blob conversion utilities for ApiBinary with file handling support.

## Installation

```bash
npm install @leancodepl/api-binary-blob
# or
yarn add @leancodepl/api-binary-blob
```

## API

### `fromBlob(blob)`

Converts Blob to ApiBinary asynchronously.

**Parameters:**

- `blob: Blob` - The Blob to convert to ApiBinary

**Returns:** Promise resolving to ApiBinary or undefined if blob is undefined

### `toBlob(apiBinary, contentType)`

Converts ApiBinary to Blob with optional content type.

**Parameters:**

- `apiBinary: ApiBinary` - The ApiBinary to convert to Blob
- `contentType?: string` - Optional MIME type for the Blob

**Returns:** Blob instance or undefined if apiBinary is null/undefined

## Usage Examples

### File Upload

```typescript
import { fromBlob, toBlob } from "@leancodepl/api-binary-blob"

const handleFileUpload = async (file: File) => {
  const binary = await fromBlob(file)

  await api.post("/upload", {
    fileName: file.name,
    content: binary,
  })
}
```

### File Download

```typescript
import { toBlob } from "@leancodepl/api-binary-blob"

const downloadFile = async (binary: ApiBinary, filename: string) => {
  const blob = toBlob(binary, "application/octet-stream")
  const url = URL.createObjectURL(blob)

  const link = document.createElement("a")
  link.href = url
  link.download = filename
  link.click()

  URL.revokeObjectURL(url)
}
```

### Image Processing

```typescript
import { fromBlob, toBlob } from "@leancodepl/api-binary-blob"

const processImage = async (imageFile: File) => {
  const binary = await fromBlob(imageFile)

  const processedBlob = toBlob(binary, "image/jpeg")
  const preview = URL.createObjectURL(processedBlob)

  const img = document.createElement("img")
  img.src = preview
  document.body.appendChild(img)
}
```
npm package: @leancodepl/api-date
Description: Core date and time types for API serialization
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/api-date

Type definitions for API date and time handling.

## Installation

```bash
npm install @leancodepl/api-date
# or
yarn add @leancodepl/api-date
```

## API

### `ApiDateOnly`

Type representing date-only values for API communication.

### `ApiDateTime`

Type representing date and time values for API communication.

### `ApiTimeSpan`

Type representing time span values for API communication.

### `ApiTimeOnly`

Type representing time-only values for API communication.

### `ApiDateTimeOffset`

Type representing date and time with offset values for API communication.

## Usage Examples

### Type Definitions

```typescript
import { ApiDateOnly, ApiDateTime, ApiTimeSpan, ApiTimeOnly, ApiDateTimeOffset } from "@leancodepl/api-date"

interface UserProfile {
  birthDate: ApiDateOnly
  createdAt: ApiDateTime
  sessionDuration: ApiTimeSpan
  preferredTime: ApiTimeOnly
  lastLogin: ApiDateTimeOffset
}
```
npm package: @leancodepl/api-date-datefns
Description: Date-fns integration for API date type conversion
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/api-date-datefns

Date conversion utilities using date-fns for API date types.

## Installation

```bash
npm install @leancodepl/api-date-datefns
# or
yarn add @leancodepl/api-date-datefns
```

## API

### `fromApiDate(date)`

Converts ApiDateOnly to JavaScript Date using date-fns.

**Parameters:**

- `date: ApiDateOnly` - The API date string to convert

**Returns:** JavaScript Date object

### `toApiDate(date)`

Converts JavaScript Date to ApiDateOnly using date-fns.

**Parameters:**

- `date: Date` - The JavaScript Date to convert

**Returns:** ApiDateOnly string

### `fromApiTime(time)`

Converts ApiTimeOnly to JavaScript Date using date-fns.

**Parameters:**

- `time: ApiTimeOnly` - The API time string to convert

**Returns:** JavaScript Date object

### `toApiTime(time)`

Converts JavaScript Date to ApiTimeOnly using date-fns.

**Parameters:**

- `time: Date` - The JavaScript Date to convert

**Returns:** ApiTimeOnly string

### `fromApiDateTimeOffset(dateTimeOffset)`

Converts ApiDateTimeOffset to JavaScript Date using date-fns.

**Parameters:**

- `dateTimeOffset: ApiDateTimeOffset` - The API datetime with offset string to convert

**Returns:** JavaScript Date object

### `toApiDateTimeOffset(dateTimeOffset)`

Converts JavaScript Date to ApiDateTimeOffset using date-fns.

**Parameters:**

- `dateTimeOffset: Date` - The JavaScript Date to convert

**Returns:** ApiDateTimeOffset string

### `fromApiTimeSpan(timeSpan)`

Converts ApiTimeSpan to milliseconds using date-fns.

**Parameters:**

- `timeSpan: ApiTimeSpan` - The API timespan string to convert

**Returns:** Duration in milliseconds

### `toApiTimeSpan(differenceInMilliseconds)`

Converts milliseconds to ApiTimeSpan using date-fns.

**Parameters:**

- `differenceInMilliseconds: number` - The duration in milliseconds to convert

**Returns:** ApiTimeSpan string

## Usage Examples

### Date Conversion

```typescript
import { fromApiDate, toApiDate } from "@leancodepl/api-date-datefns"

const apiDate = "2023-12-25"
const jsDate = fromApiDate(apiDate)
console.log(jsDate) // Date object

const convertedBack = toApiDate(jsDate)
console.log(convertedBack) // '2023-12-25'
```

### Time Conversion

```typescript
import { fromApiTime, toApiTime } from "@leancodepl/api-date-datefns"

const apiTime = "14:30:00"
const jsDate = fromApiTime(apiTime)
const convertedBack = toApiTime(jsDate)
console.log(convertedBack) // '14:30:00'
```

### DateTime with Offset

```typescript
import { fromApiDateTimeOffset, toApiDateTimeOffset } from "@leancodepl/api-date-datefns"

const apiDateTime = "2023-12-25T14:30:00+01:00"
const jsDate = fromApiDateTimeOffset(apiDateTime)
const convertedBack = toApiDateTimeOffset(jsDate)
console.log(convertedBack) // '2023-12-25T14:30:00+01:00'
```
npm package: @leancodepl/api-date-utils
Description: Utility functions for API date parsing and validation
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/api-date-utils

Utilities for parsing and working with API date types.

## Installation

```bash
npm install @leancodepl/api-date-utils
# or
yarn add @leancodepl/api-date-utils
```

## API

### `parseApiTimeSpan(timespan)`

Parses ApiTimeSpan string into structured time components.

**Parameters:**

- `timespan: ApiTimeSpan` - The ApiTimeSpan string to parse

**Returns:** Object with sign and time component values

## Usage Examples

### Basic Parsing

```typescript
import { parseApiTimeSpan } from "@leancodepl/api-date-utils"

const result = parseApiTimeSpan("1.23:45:67.890")
console.log(result.values.hours) // 23
console.log(result.values.days) // 1
console.log(result.sign) // undefined (positive)
```

### Negative TimeSpan

```typescript
import { parseApiTimeSpan } from "@leancodepl/api-date-utils"

const result = parseApiTimeSpan("-2.10:30:45.123")
console.log(result.sign) // '-'
console.log(result.values.days) // 2
console.log(result.values.hours) // 10
console.log(result.values.minutes) // 30
console.log(result.values.milliseconds) // 123
```

### Duration Calculations

```typescript
import { parseApiTimeSpan } from "@leancodepl/api-date-utils"

const calculateTotalMilliseconds = (timespan: ApiTimeSpan) => {
  const parsed = parseApiTimeSpan(timespan)
  const { days, hours, minutes, seconds, milliseconds } = parsed.values

  const total = days * 86400000 + hours * 3600000 + minutes * 60000 + seconds * 1000 + milliseconds

  return parsed.sign === "-" ? -total : total
}
```
npm package: @leancodepl/axios-cqrs-client
Description: HTTP CQRS client implementation using Axios
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/axios-cqrs-client

CQRS client with Axios for HTTP communication and command/query handling.

## Installation

```bash
npm install @leancodepl/axios-cqrs-client
# or
yarn add @leancodepl/axios-cqrs-client
```

## API

### `mkCqrsClient(cqrsEndpoint, tokenProvider, axiosOptions, tokenHeader)`

Creates CQRS client with Axios for HTTP communication and command/query handling.

**Parameters:**

- `cqrsEndpoint: string` - Base URL for CQRS API endpoints
- `tokenProvider?: TokenProvider` - Optional token provider for authentication
- `axiosOptions?: CreateAxiosDefaults` - Optional Axios configuration options
- `tokenHeader?: string` - Header name for authentication token (default: "Authorization")

**Returns:** Object with `createQuery`, `createOperation`, and `createCommand` methods

### `mkUncapitalizedCqrsClient(params)`

Creates CQRS client with automatic response key uncapitalization using "@leancodepl/utils".

**Parameters:**

- `params: MkCqrsClientParameters` - Configuration object for CQRS client
- `params.cqrsEndpoint: string` - Base URL for CQRS API endpoints
- `params.tokenProvider?: TokenProvider` - Optional token provider for authentication
- `params.axiosOptions?: CreateAxiosDefaults` - Optional Axios configuration options
- `params.tokenHeader?: string` - Header name for authentication token (default: "Authorization")

**Returns:** CQRS client with response key transformation

## Usage Examples

### Basic Setup

```typescript
import { mkCqrsClient } from "@leancodepl/axios-cqrs-client"

const client = mkCqrsClient({
  cqrsEndpoint: "https://api.example.com",
  tokenProvider: {
    getToken: () => Promise.resolve(localStorage.getItem("token")),
    invalidateToken: () => Promise.resolve(true),
  },
})
```

### Query Operations

```typescript
interface GetUserQuery {
  userId: string
}

interface UserResult {
  id: string
  name: string
  email: string
}

const getUser = client.createQuery<GetUserQuery, UserResult>("GetUser")

const response = await getUser({ userId: "123" })

if (response.isSuccess) {
  console.log("User:", response.result)
}
```

### Command Operations

```typescript
interface CreateUserCommand {
  name: string
  email: string
}

const errorCodes = { EmailExists: 1, InvalidEmail: 2 } as const
const createUser = client.createCommand<CreateUserCommand, typeof errorCodes>("CreateUser", errorCodes)

const response = await createUser({ name: "John", email: "john@example.com" })

createUser
  .handle({ name: "John", email: "john@example.com" })
  .handle("success", () => console.log("User created"))
  .handle("EmailExists", () => console.log("Email already exists"))
  .check()
```

### Uncapitalized Client

```typescript
import { mkUncapitalizedCqrsClient } from "@leancodepl/axios-cqrs-client"

const client = mkUncapitalizedCqrsClient({
  cqrsEndpoint: "https://api.example.com",
})

// Automatically transforms { UserId: '123' } to { userId: '123' }
const response = await client.createQuery("GetUser")({ userId: "123" })
```
npm package: @leancodepl/config
Description: Utility for creating configuration getters that access Vite-injected values in development and environment variables in production
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/config - Utility for creating configuration getters that access Vite-injected values in development and environment variables in production.

Provides a function to create getters for accessing configuration values prefixed with 'VITE\_' from `import.meta.env`
during development. In production, it retrieves values directly from environment variables, with support for tools like
nginx-base from "leancodepl/tools" for parsing.

## Installation

```bash
npm install @leancodepl/config
```

or

```bash
yarn add @leancodepl/config
```

## API

### `mkGetInjectedConfig()`

Creates a getter function for accessing Vite-injected configuration values from environment variables on development, on
production it will return the value from the environment variables. You can check "@leancodepl/tools" repository for
more information. There's nginx-base defined which parses it out.

The keys are automatically prefixed with 'VITE\_' when accessing import.meta.env.

**Returns:** An object containing the `getInjectedConfig` method.

**It's important to not rename `getInjectedConfig` as it's used later as a pattern to search for**

## Usage Examples

### Accessing Configuration Values

```typescript
import { mkGetInjectedConfig } from "@leancodepl/config";

const { getInjectedConfig } = mkGetInjectedConfig<"API_URL" | "API_KEY">();

export const const apiUrl = getInjectedConfig("API_URL");
```
npm package: @leancodepl/contractsgenerator-typescript-plugin
Description: This library was generated with [Nx](https://nx.dev).
Latest version: 1.1.3

# plugin

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test plugin` to execute the unit tests via [Jest](https://jestjs.io).

## Running lint

Run `nx lint plugin` to execute the lint via [ESLint](https://eslint.org/).
npm package: @leancodepl/contractsgenerator-typescript-plugin-admin
Description: Plugin for generating api components schema from `AdminQuery` queries. This schema object is exported with `export default` so this plugin should not be used together with other plugins with default exported components.
Latest version: 1.1.3
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @leancodepl/contractsgenerator-typescript-plugin-admin

Plugin for generating api components schema from `AdminQuery` queries. This schema object is exported with
`export default` so this plugin should not be used together with other plugins with default exported components.

## Config

- `input` - configuration passed to [Contracts Generator Server](https://github.com/leancodepl/contractsgenerator). All
  paths are relative to directory from your current CWD. Unless you are using JavaScript files - in that case you can
  use `__dirname` and `path.join`/`path.resolve` for paths relative to configuration file.

  - `base` - base path for your backend code source. If you provide that then all the other properties are relative to
    this directory.

  Then you can provide one of:

  - `file`  
    or
  - `include` and `exclude` - single globs or arrays of globs to match specific .cs files  
    or
  - `project` - can be multiple

  For details on these options please refer to
  [Contracts Generator Server](https://github.com/leancodepl/contractsgenerator).

## Example

### Config

```js
module.exports = {
  generates: {
    "output.ts": {
      plugins: ["admin"],
    },
  },
  config: {
    input: {
      base: "../../../backend/src",
      project: ["Core/Project.Core.Contracts/Project.Core.Contracts.csproj"],
    },
  },
};
```

### Output

```js
const schema = {
    "components": [
        {
            "type": "table",
            "table": {
                "query": "TenantManagersList",
                "columns": [
                    {
                        "id": "Email",
                        "title": "E-mail",
                        "sortable": false,
                        "type": 1
                    }
                ]
            }
        },
    ],
    "enumsMaps": {}
} as const;

export default schema;
```
npm package: @leancodepl/contractsgenerator-typescript-plugin-contracts
Description: Plugin for generating TypeScript types of contracts.
Latest version: 1.1.3

# @leancodepl/contractsgenerator-typescript-plugin-contracts

Plugin for generating TypeScript types of contracts.

## Config

- `input` - configuration passed to [Contracts Generator Server](https://github.com/leancodepl/contractsgenerator). All
  paths are relative to directory from your current CWD. Unless you are using JavaScript files - in that case you can
  use `__dirname` and `path.join`/`path.resolve` for paths relative to configuration file.

  - `base` - base path for your backend code source. If you provide that then all the other properties are relative to
    this directory.

  Then you can provide one of:

  - `file`  
    or
  - `include` and `exclude` - single globs or arrays of globs to match specific .cs files  
    or
  - `project` - can be multiple

  For details on these options please refer to
  [Contracts Generator Server](https://github.com/leancodepl/contractsgenerator).

- `customTypes` - dictionary of custom types configuration where keys are the name of Known Type and value is custom
  type name. Valid custom types include: String, Guid, Uri, Boolean, UInt8, Int8, Int16, UInt16, Int32, UInt32, Int64,
  UInt64, Float32, Float64, DateOnly, TimeOnly, DateTimeOffset, TimeSpan.

- `nameTransform` - function `(fullName: string) => string` which allows you to transform full name of the DTO (like
  `LeanCode.Core.Contracts.User.UserDetailsDTO`). This is especially useful when you want to map namespaces, for e.g.
  when you have conflicts, want to remove parts of the namespace (`LeanCode.Core.User.UserDetailsDTO` instead of
  `LeanCode.Core.`**`Contracts`**`.User.UserDetailsDTO`).

## Example

### Config

```js
module.exports = {
  generates: {
    "output.ts": {
      plugins: ["contracts"],
    },
  },
  config: {
    input: {
      base: "../../../backend/src",
      project: ["Core/Project.Core.Contracts/Project.Core.Contracts.csproj"],
      nameTransform: nameWithNamespace => nameWithNamespace.split(".").at(-1),
    },
  },
};
```

### Output

```js
/**
 * @attribute LeanCode.Contracts.Security.AuthorizeWhenHasAnyOfAttribute
 */
export interface Clients {
}
export namespace Clients {
    export const AdminApp = "admin_app";
    export const ClientApp = "client_app";
}
export interface KnownClaims {
}
export namespace KnownClaims {
    export const UserId = "sub";
    export const Role = "role";
}
export interface Roles {
}
export namespace Roles {
    export const User = "user";
    export const Admin = "admin";
}
export interface AddLeagueManager extends Command {
    TenantId: string;
    TenantName?: string | null;
    TenantLogoUri?: string | null;
    UserName: string;
    Password: string;
}
export namespace AddLeagueManager {
    export const ErrorCodes = {
        TenantNotFoundOrAlreadyExists: 1,
        TenantNameTooLong: 2,
        TenantLogoUriTooLong: 3,
        InvalidUserName: 4,
        InvalidPassword: 5,
        UserAlreadyExists: 6
    } as const;
    export type ErrorCodes = typeof ErrorCodes;
}
```
npm package: @leancodepl/contractsgenerator-typescript-plugin-raw
Description: Plugin for prepending/appending text to a file generated by Contracts Generator.
Latest version: 1.1.3

# @leancodepl/contractsgenerator-typescript-plugin-raw

Plugin for prepending/appending text to a file generated by Contracts Generator.

## Config

- `prepend` - text to be added at the beginning of the file
- `output` - text to be added after content of the plugin specified before this
- `append` - text to be added at the end of the file

## Example

### Config

```js
const prepend1 = "Prepend 1\n";
const prepend2 = "Prepend 2\n";

const output1 = "Output 1\n";
const output2 = "\nOutput 2\n";

const append1 = "Append 1\n";
const append2 = "Append 2\n";

module.exports = {
  generates: {
    "output.ts": {
      plugins: [
        { raw: { prepend: prepend1, output: output1, append: append1 } },
        "admin",
        { raw: { prepend: prepend2, output: output2, append: append2 } },
      ],
    },
  },
  config: {
    input: {},
  },
};
```

### Output

```
Prepend 1
Prepend 2
Output 1
const schema = {
    "components": [],
    "enumsMaps": {}
} as const;

export default schema;
Output 2
Append 1
Append 2

```
npm package: @leancodepl/cqrs-client-base
Description: Base types and interfaces for CQRS client implementations
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/cqrs-client-base

Base types and interfaces for CQRS clients.

## Installation

```bash
npm install @leancodepl/cqrs-client-base
# or
yarn add @leancodepl/cqrs-client-base
```

## API

### `TokenProvider`

Interface for token providers used in CQRS clients.

**Properties:**

- `getToken: () => Promise<string | undefined>` - Returns authentication token
- `invalidateToken: () => Promise<boolean>` - Invalidates and refreshes token

### `ValidationError<TErrorCodes>`

Represents validation errors from commands.

**Properties:**

- `PropertyName: string` - Property that failed validation
- `ErrorMessage: string` - Human-readable error message
- `ErrorCode: TErrorCodes[keyof TErrorCodes]` - Error code from provided map

### `CommandResult<TErrorCodes>`

Union type for command results.

**Types:**

- `SuccessfulCommandResult` - When command succeeds
- `FailedCommandResult<TErrorCodes>` - When command fails with validation errors

### `ApiResponse<TResult>`

Union type for API responses.

**Types:**

- `ApiSuccess<TResult>` - Successful response with result
- `ApiError` - Error response

## Usage Examples

### Token Provider Implementation

```typescript
import { TokenProvider } from "@leancodepl/cqrs-client-base"

const tokenProvider: TokenProvider = {
  getToken: async () => {
    return localStorage.getItem("authToken")
  },
  invalidateToken: async () => {
    localStorage.removeItem("authToken")
    return true
  },
}
```

### Command Error Handling

```typescript
import { CommandResult, ValidationError } from "@leancodepl/cqrs-client-base"

interface UserErrorCodes {
  EmailExists: 1
  InvalidEmail: 2
}

function handleCommandResult(result: CommandResult<UserErrorCodes>) {
  if (result.WasSuccessful) {
    console.log("Command succeeded")
  } else {
    result.ValidationErrors.forEach((error: ValidationError<UserErrorCodes>) => {
      console.log(`${error.PropertyName}: ${error.ErrorMessage}`)
    })
  }
}
```

### API Response Handling

```typescript
import { ApiResponse } from "@leancodepl/cqrs-client-base"

function handleApiResponse<T>(response: ApiResponse<T>) {
  if (response.isSuccess) {
    return response.result
  } else {
    throw new Error("API call failed")
  }
}
```
npm package: @leancodepl/cx
Description: This library was generated with [Nx](https://nx.dev).
Latest version: 8.3.6
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @leancodepl/cx

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test @leancodepl/cx` to execute the unit tests via [Jest](https://jestjs.io).
npm package: @leancodepl/eslint-config
Description: ESLint configuration for LeanCode projects
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/eslint-config

ESLint configurations for TypeScript and React projects.

## Installation

```bash
npm install --save-dev @leancodepl/eslint-config
# or
yarn add --dev @leancodepl/eslint-config
```

## Available Configurations

- `base` - Core TypeScript rules with sorting and code quality
- `baseReact` - React-specific rules and JSX formatting
- `imports` - Import/export organization and unused import detection
- `a11y` - Accessibility rules for React components

## Usage Examples

### React TypeScript Project

```javascript
// eslint.config.js
import { base, baseReact, imports, a11y } from "@leancodepl/eslint-config"

export default [...base, ...baseReact, ...imports, ...a11y]
```

### Custom Rules

```javascript
// eslint.config.js
import { base, baseReact } from "@leancodepl/eslint-config"

export default [
  ...base,
  ...baseReact,
  {
    rules: {
      "max-params": ["error", { max: 6 }],
      "no-console": "off",
    },
  },
]
```

## Migration from CommonJS to ES Modules

Starting from 10.0.0 version, the package is built as an ES Module. If your ESLint configuration currently uses CommonJS
syntax, follow these steps to migrate:

- Rename `eslint.config.js` to `eslint.config.mjs` (if your `package.json` does not have `"type": "module"`)
- Convert `require` statements to `import` syntax
- Replace CommonJS variables like `__dirname` with ES Module equivalents:

  ```javascript
  import { dirname } from "node:path"
  import { fileURLToPath } from "node:url"

  const __filename = fileURLToPath(import.meta.url)
  const __dirname = dirname(__filename)

  // or

  const __filename = import.meta.filename
  const __dirname = import.meta.dirname
  ```

- If importing a CommonJS package with named imports fails, import the default export and destructure separately:

  ```javascript
  import commonjsPackage from "commonjs-package"
  const { someExport } = commonjsPackage
  ```
npm package: @leancodepl/eslint-plugin
Description: ESLint plugin for LeanCode projects
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/eslint-plugin

ESLint plugin with custom rules for LeanCode projects.

## Installation

```bash
npm install --save-dev @leancodepl/eslint-plugin
# or
yarn add --dev @leancodepl/eslint-plugin
```

## Usage

```javascript
// eslint.config.js
import { leancodePlugin } from "@leancodepl/eslint-plugin"

export default [
  {
    plugins: {
      leancode: leancodePlugin,
    },
    rules: {
      "leancode/switch-case-braces": "error",
    },
  },
]
```

## Rules

### `switch-case-braces`

Enforces consistent use of braces in switch case statements. Requires braces when lexical declarations (const, let,
class, function) are present, and suggests removing braces when they are not needed.

**Valid:**

```javascript
switch (value) {
  case "a":
    console.log("a")
    break
  case "b": {
    const x = 1
    console.log(x)
    break
  }
}
```

**Invalid:**

```javascript
switch (value) {
  case "a": {
    console.log("a") // Unnecessary braces
    break
  }
  case "b":
    const x = 1 // Missing braces for lexical declaration
    console.log(x)
    break
}
```
npm package: @leancodepl/feature-flags-react-client
Description: React client for feature flag management and evaluation
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/feature-flags-react-client

React hooks for type-safe feature flag management using OpenFeature.

## Installation

```bash
npm install @leancodepl/feature-flags-react-client
# or
yarn add @leancodepl/feature-flags-react-client
```

## API

### `mkFeatureFlags(flags, provider)`

Creates React hooks for type-safe feature flag management using OpenFeature.

**Parameters:**

- `flags: TFlags` - Feature flags configuration object with default values
- `provider: Provider` - OpenFeature provider instance

**Returns:** Object containing `useFeatureFlag` hook and `FeatureFlagsProvider` component

## Usage Examples

### Basic Setup (ConfigCat)

```typescript
//featureFlags.ts
import { mkFeatureFlags } from "@leancodepl/feature-flags-react-client"
import { ConfigCatWebProvider } from "@openfeature/config-cat-web-provider"

const flags = {
  enableNewFeature: { defaultValue: false },
  maxRetries: { defaultValue: 3 },
}

const provider = ConfigCatWebProvider.create("sdk-key")
export const { FeatureFlagsProvider, useFeatureFlag } = mkFeatureFlags(flags, provider)
```

### Basic Setup (PostHog)

```typescript
//featureFlags.ts
import { mkFeatureFlags } from "@leancodepl/feature-flags-react-client"
import { OpenFeaturePosthogProvider } from "@leancodepl/openfeature-posthog-provider"
import posthog from "posthog-js"

const flags = {
  enableNewFeature: { defaultValue: false },
  maxRetries: { defaultValue: 3 },
}

posthog.init("YOUR_API_KEY")
const provider = new OpenFeaturePosthogProvider(posthog)
export const { FeatureFlagsProvider, useFeatureFlag } = mkFeatureFlags(flags, provider)
```

### Component Usage

```typescript
import React from 'react';
import { FeatureFlagsProvider, useFeatureFlag } from './featureFlags';

function App() {
  return (
    <FeatureFlagsProvider>
      <Dashboard />
    </FeatureFlagsProvider>
  );
}

function Dashboard() {
  const { value: isEnabled } = useFeatureFlag('enableNewFeature');
  const { value: retries } = useFeatureFlag('maxRetries');

  return (
    <div>
      {isEnabled ? <NewDashboard /> : <LegacyDashboard />}
      <div>Max retries: {retries}</div>
    </div>
  );
}
```

### With Default Override

```typescript
import React from 'react';
import { useFeatureFlag } from './featureFlags';

function Settings() {
  const { value: retries } = useFeatureFlag('maxRetries', 5);

  return <div>Retries: {retries}</div>;
}
```
npm package: @leancodepl/gtag
Description: Google Tag Manager integration utilities for web analytics
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/gtag

Type-safe Google Tag Manager data layer integration.

## Installation

```bash
npm install @leancodepl/gtag
# or
yarn add @leancodepl/gtag
```

## API

### `mkgtag()`

Creates a type-safe Google Tag Manager data layer push function.

**Returns:** Function that accepts data layer arguments and pushes to GTM

## Usage Examples

### Basic Event Tracking

```typescript
import { mkgtag } from "@leancodepl/gtag"

const gtag = mkgtag<{ event: "page_view"; page_title: string }>()

gtag({
  event: "page_view",
  page_title: "Home Page",
})
```

### Custom Events with Callbacks

```typescript
import { mkgtag } from "@leancodepl/gtag"

interface CustomEvent {
  event: "button_click"
  element_id: string
}

const gtag = mkgtag<CustomEvent>()

gtag({
  event: "button_click",
  element_id: "signup-button",
  eventCallback: containerId => {
    console.log("Event sent to container:", containerId)
  },
  eventTimeout: 2000,
})
```
npm package: @leancodepl/i18n
Description: This library was generated with [Nx](https://nx.dev).
Latest version: 8.3.6
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# i18n

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test i18n` to execute the unit tests via [Jest](https://jestjs.io).
npm package: @leancodepl/linting
Description: Meta-package for LeanCode linting configurations
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/linting

Linting and formatting setup for TypeScript and React projects.

## Installation

```bash
npm install --save-dev @leancodepl/linting
# or
yarn add --dev @leancodepl/linting
```

## Included Packages

- `@leancodepl/eslint-config` - ESLint rules for TypeScript and React
- `@leancodepl/prettier-config` - Prettier formatting configuration
- `@leancodepl/stylelint-config` - Stylelint rules for CSS and SCSS
- `@leancodepl/resolve-eslint-flat-config` - TypeScript resolver for ESlint flat config

## Usage Examples

### ESLint Configuration

```javascript
// eslint.config.js
import { base, baseReact, imports, a11y } from "@leancodepl/eslint-config"

export default [...base, ...baseReact, ...imports, ...a11y]
```

### Prettier Configuration

```javascript
// prettier.config.js
module.exports = require("@leancodepl/prettier-config")
```

### Stylelint Configuration

```javascript
// stylelint.config.js
module.exports = {
  extends: "@leancodepl/stylelint-config",
}
```

### ESlint flat config resolver

```javascript
// eslint.config.js
const { resolveFlatConfig } = require("@leancodepl/resolve-eslint-flat-config")

const customConfigs = [
  { plugins: { custom: customPlugin }, rules: { "custom/rule": "error" } },
  { plugins: { another: anotherPlugin }, rules: { "another/rule": "warn" } },
]

module.exports = resolveFlatConfig(customConfigs)
```
npm package: @leancodepl/nx-plugins
Description: Collection of Nx plugins for LeanCode projects
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/nx-plugins

Collection of Nx inference plugins for LeanCode projects.

## Installation

```bash
npm install -D @leancodepl/nx-plugins
```

## Available Plugins

### Contracts Plugin

Automatically infers a `contracts` target for projects containing a `contractsgenerator-typescript.config.js` file.

```json
{
  "plugins": [
    {
      "plugin": "@leancodepl/nx-plugins/contracts",
      "options": {
        "targetName": "contracts"
      }
    }
  ]
}
```

### Intl Plugin

Automatically infers translation targets for projects containing an `intl.config.js` file.

```json
{
  "plugins": [
    {
      "plugin": "@leancodepl/nx-plugins/intl",
      "options": {
        "localTargetName": "intl",
        "uploadTargetName": "intl-upload",
        "downloadTargetName": "intl-download",
        "syncTargetName": "intl-sync",
        "diffTargetName": "intl-diff"
      }
    }
  ]
}
```

Inferred targets:

- `intl` - Extract and compile translations locally
- `intl-upload` - Upload terms to POEditor
- `intl-download` - Download translations from POEditor
- `intl-sync` - Upload and download translations
- `intl-diff` - Compare local terms with POEditor

### Proxy Plugin

Automatically infers a `proxy` target for projects containing a `dev/docker-compose.yml` file.

```json
{
  "plugins": [
    {
      "plugin": "@leancodepl/nx-plugins/proxy",
      "options": {
        "targetName": "proxy"
      }
    }
  ]
}
```

The proxy target has two configurations:

- `up` (default): Starts the proxy container
- `rebuild`: Rebuilds the proxy image from Azure Container Registry
npm package: @leancodepl/openfeature-posthog-provider
Description: OpenFeature provider that delegates feature flag evaluation to PostHog
Author: LeanCode
Latest version: 10.2.0

# openfeature-posthog-provider

OpenFeature provider that delegates feature flag evaluation to PostHog. Use PostHog feature flags through the OpenFeature standard API.

## Installation

```bash
npm install @leancodepl/openfeature-posthog-provider
```

## API

### `OpenFeaturePosthogProvider(client)`

Delegates feature flag evaluation to PostHog (posthog-js). Use this to access PostHog feature flags through the OpenFeature standard API. Flags return default values until PostHog has loaded and feature flags are available.

**Parameters:**

- `client` - `PostHog` - Initialized PostHog client instance

## Usage Examples

### Basic setup with OpenFeature

```typescript
import posthog from 'posthog-js';
import { OpenFeature } from '@openfeature/web-sdk';
import { OpenFeaturePosthogProvider } from '@leancodepl/openfeature-posthog-provider';

posthog.init('YOUR_API_KEY');
OpenFeature.setProvider(new OpenFeaturePosthogProvider(posthog));
const client = OpenFeature.getClient();
const isEnabled = await client.getBooleanValue('my-feature', false);
```

### Evaluating different flag types

```typescript
import { OpenFeature } from '@openfeature/web-sdk';

const client = OpenFeature.getClient();
const stringValue = await client.getStringValue('welcome-message', 'Hello');
const numberValue = await client.getNumberValue('max-items', 10);
const jsonValue = await client.getObjectValue('config', { theme: 'light' });
```
npm package: @leancodepl/prettier-config
Description: Prettier configuration for consistent code formatting
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/prettier-config

Prettier configuration for code formatting.

## Installation

```bash
npm install --save-dev @leancodepl/prettier-config
# or
yarn add --dev @leancodepl/prettier-config
```

## Usage Examples

### Basic Setup

```javascript
// prettier.config.js
module.exports = require("@leancodepl/prettier-config")
```

### With Overrides

```javascript
// prettier.config.js
const baseConfig = require("@leancodepl/prettier-config")

module.exports = {
  ...baseConfig,
  printWidth: 100,
  singleQuote: true,
}
```
npm package: @leancodepl/resolve-eslint-flat-config
Description: Resolve ESlint flat config plugin collisions
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/resolve-eslint-flat-config

A TypeScript library for resolving ESLint flat config plugin collisions.

## Installation

```bash
npm install --save-dev @leancodepl/resolve-eslint-flat-config
# or
yarn add --dev @leancodepl/resolve-eslint-flat-config
```

## API

### `resolveFlatConfig(allModules)`

Resolves ESLint flat config by merging plugins and separating configurations.

**Parameters:**

- `allModules` (`Linter.Config[]`, **required**) - Array of ESLint flat config objects to merge

**Returns:** Array containing merged plugins object followed by individual configs

## Usage Examples

```javascript
// eslint.config.js
const { resolveFlatConfig } = require("@leancodepl/resolve-eslint-flat-config")

const customConfigs = [
  { plugins: { custom: customPlugin }, rules: { "custom/rule": "error" } },
  { plugins: { another: anotherPlugin }, rules: { "another/rule": "warn" } },
]

module.exports = resolveFlatConfig(customConfigs)
```
npm package: @leancodepl/rx-pipe-client
Description: RxJS-based client for real-time data streaming using @leancodepl/pipe
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/rx-pipe-client

RxJS-based topic functions for real-time data subscriptions using @leancodepl/pipe.

## Installation

```bash
npm install @leancodepl/rx-pipe-client
# or
yarn add @leancodepl/rx-pipe-client
```

## API

### `mkPipeClient(pipe)`

Creates topic functions for data subscriptions using @leancodepl/pipe.

**Parameters:**

- `pipe: Pipe` - Pipe instance from @leancodepl/pipe

**Returns:** Object containing `createTopic` method for creating typed observables

## Usage Examples

### Basic Setup

```typescript
import { mkPipeClient } from "@leancodepl/rx-pipe-client"
import { createPipe } from "@leancodepl/pipe"

const pipe = createPipe({
  url: "wss://api.example.com/pipe",
  getAccessToken: () => localStorage.getItem("token"),
})

const pipeClient = mkPipeClient({ pipe })
```

### Chat Messages

```typescript
import { mkPipeClient } from "@leancodepl/rx-pipe-client"
import { createPipe } from "@leancodepl/pipe"

interface ChatTopic {
  roomId: string
}

interface ChatNotifications {
  MessageReceived: {
    id: string
    content: string
    authorId: string
  }
}

const pipe = createPipe({
  url: "wss://api.example.com/pipe",
  getAccessToken: () => localStorage.getItem("token"),
})
const pipeClient = mkPipeClient({ pipe })
const chatTopic = pipeClient.createTopic<ChatTopic, ChatNotifications>("chat")

chatTopic({ roomId: "room1" }).subscribe(notification => {
  if (notification.type === "MessageReceived") {
    console.log(`New message: ${notification.data.content}`)
  }
})
```

### Live Metrics with RxJS Operators

```typescript
import { filter, map } from "rxjs/operators"
import { mkPipeClient } from "@leancodepl/rx-pipe-client"
import { createPipe } from "@leancodepl/pipe"

interface MetricsTopic {
  dashboardId: string
}

interface MetricsNotifications {
  CpuUpdate: { value: number }
  MemoryUpdate: { value: number }
}

const pipe = createPipe({
  url: "wss://api.example.com/pipe",
  getAccessToken: () => localStorage.getItem("token"),
})
const pipeClient = mkPipeClient({ pipe })
const metricsTopic = pipeClient.createTopic<MetricsTopic, MetricsNotifications>("metrics")

const cpuUpdates$ = metricsTopic({ dashboardId: "main" }).pipe(
  filter(notification => notification.type === "CpuUpdate"),
  map(notification => notification.data.value),
)

cpuUpdates$.subscribe(value => {
  console.log(`CPU: ${value}%`)
})
```
npm package: @leancodepl/styled-tools
Description: Utilities for styled-components
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/styled-tools

TypeScript utilities for styled-components with type-safe theme access.

## Installation

```bash
npm install @leancodepl/styled-tools
# or
yarn add @leancodepl/styled-tools
```

## API

### `mkTheme()`

Creates type-safe theme utilities for styled-components with full TypeScript support.

**Returns:** Object containing `theme` proxy and `useTheme` hook

## Usage Examples

### Basic Setup

```typescript
// theme.ts
import { mkTheme } from "@leancodepl/styled-tools"
import styled from "styled-components"

interface AppTheme {
  colors: { primary: string; secondary: string }
  spacing: { small: string; large: string }
}

export const { theme, useTheme } = mkTheme<AppTheme>()

const Button = styled.button`
  color: ${theme.colors.primary};
  padding: ${theme.spacing.small};
`
```

### React Hook Usage

```typescript
import React from 'react';
import { useTheme } from './theme';

function ThemedComponent() {
  const theme = useTheme();

  return (
    <div style={{ backgroundColor: theme.colors.primary }}>
      <h1>Themed Component</h1>
    </div>
  );
}
```
npm package: @leancodepl/stylelint-config
Description: Stylelint configuration for CSS and SCSS linting
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/stylelint-config

Stylelint configuration for CSS and SCSS with property ordering.

## Installation

```bash
npm install --save-dev @leancodepl/stylelint-config
# or
yarn add --dev @leancodepl/stylelint-config
```

## Usage Examples

### Basic Setup

```javascript
// stylelint.config.js
module.exports = {
  extends: "@leancodepl/stylelint-config",
}
```

### With Overrides

```javascript
// stylelint.config.js
module.exports = {
  extends: "@leancodepl/stylelint-config",
  rules: {
    "length-zero-no-unit": null,
    "color-hex-case": "upper",
  },
}
```
npm package: @leancodepl/vite-plugin-favicon
Description: Vite plugin for generating favicons
Author: LeanCode
Latest version: 10.2.0

# @leancodepl/vite-plugin-favicon

A Typescript library for generating favicon formats and sizes from a source logo and injecting the HTML tags into the
build output. Extracted from [vite favicon plugin](https://github.com/josh-hemphill/vite-plugin-favicon) and adjusted to
be dev mode compatible.

## Installation

```bash
npm install @leancodepl/vite-plugin-favicon
```

## API

### `ViteFaviconsPlugin(options)`

Creates a Vite plugin for generating favicons from a source logo.

**Parameters:**

- `options` - Configuration options for favicon generation

**Returns:** Vite plugin instance

### `ViteFaviconsPluginOptions`

Configuration options for the Vite favicon plugin.

**Properties:**

- `logo?: string` - Source logo path for favicon generation (default: "assets/logo.png")
- `inject?: boolean` - Whether to inject HTML links and metadata (default: true)
- `favicons?: Partial<FaviconOptions>`
- `outputPath?: string`

## Usage Examples

### Basic Configuration

```javascript
// vite.config.js
import { ViteFaviconsPlugin } from "@leancodepl/vite-plugin-favicon"

export default {
  plugins: [ViteFaviconsPlugin()],
}
```

### Custom Logo Path

```javascript
// vite.config.js
import { ViteFaviconsPlugin } from "@leancodepl/vite-plugin-favicon"

export default {
  plugins: [
    ViteFaviconsPlugin({
      logo: "src/assets/logo.png",
    }),
  ],
}
```

### Advanced Favicon Configuration

```javascript
// vite.config.js
import { ViteFaviconsPlugin } from "@leancodepl/vite-plugin-favicon"

export default {
  plugins: [
    ViteFaviconsPlugin({
      logo: "src/assets/logo.png",
      favicons: {
        appName: "My Application",
        appShortName: "MyApp",
        themeColor: "#ffffff",
        background: "#000000",
        display: "standalone",
      },
    }),
  ],
}
```