open-index/open-npm huggingface dataset:
npm package: @ovotech/avro-decimal
Description: A logical type representing Decimal as binary bytes
Author: Ivan Kerin
Latest version: 0.1.5

# Avro Decimal

A Logical type for representing a decimal object value as raw bytes

### Using

```bash
yarn add @ovotech/avro-decimal
```

And then you can use `AvroDecimal` for a logicalType of a field.

> [examples/simple.ts](examples/simple.ts)

```typescript
import { Type, Schema } from 'avsc';
import { AvroDecimal } from '@ovotech/avro-decimal';
import { Decimal } from 'decimal.js';

const decimalSchema: Schema = {
  type: 'bytes',
  logicalType: 'decimal',
  precision: 16,
  scale: 8,
};

export const DecimalType = Type.forSchema(decimalSchema, {
  logicalTypes: { decimal: AvroDecimal },
});

const encoded = DecimalType.toBuffer(new Decimal('100.01'));
const decoded = DecimalType.fromBuffer(encoded);

console.log(decoded);
```

## Running the tests

Then you can run the tests with:

```bash
yarn test
```

### Coding style (linting, etc) tests

Style is maintained with prettier and tslint

```
yarn lint
```

## Deployment

Deployment is preferment by lerna automatically on merge / push to main, but you'll need to bump the package version numbers yourself. Only updated packages with newer versions will be pushed to the npm registry.

## Contributing

Have a bug? File an issue with a simple example that reproduces this so we can take a look & confirm.

Want to make a change? Submit a PR, explain why it's useful, and make sure you've updated the docs (this file) and the tests (see [test folder](test)).

## License

This project is licensed under Apache 2 - see the [LICENSE](LICENSE) file for details
npm package: @ovotech/avro-epoch-days
Description: A logical type representing Date as epoch days
Author: Ivan Kerin
Latest version: 0.1.5

# Avro Epoch Days

A Logical type for representing a date stored as the number of days since epoch

### Using

```bash
yarn add @ovotech/avro-epoch-days
```

And then you can use `AvroEpochDays` for a logicalType of a field.

> [examples/simple.ts](examples/simple.ts)

```typescript
import { Type, Schema } from 'avsc';
import { AvroEpochDays } from '@ovotech/avro-epoch-days';

const eventSchema: Schema = {
  type: 'record',
  name: 'Event',
  fields: [
    {
      name: 'field1',
      type: { type: 'int', logicalType: 'date' },
    },
  ],
};

const EventType = Type.forSchema(eventSchema, { logicalTypes: { date: AvroEpochDays } });

const encoded = EventType.toBuffer({ field1: new Date('2020-01-01') });
const decoded = EventType.fromBuffer(encoded);

console.log(decoded);
```

It also supports schema evolution from int, logical:date and string types

> [examples/evolution.ts](examples/evolution.ts)

```typescript
import { Type, Schema } from 'avsc';
import { AvroEpochDays } from '@ovotech/avro-epoch-days';

const previousSchema: Schema = {
  type: 'record',
  name: 'Event',
  fields: [
    {
      name: 'field1',
      type: { type: 'string' },
    },
  ],
};

const eventSchema: Schema = {
  type: 'record',
  name: 'Event',
  fields: [
    {
      name: 'field1',
      type: { type: 'int', logicalType: 'date' },
    },
  ],
};

const PreviousType = Type.forSchema(previousSchema);
const EventType = Type.forSchema(eventSchema, {
  logicalTypes: { date: AvroEpochDays },
});
const previousTypeResolver = EventType.createResolver(PreviousType);

const encoded = PreviousType.toBuffer({ field1: '2020-01-01' });
const decoded = EventType.fromBuffer(encoded, previousTypeResolver);

console.log(decoded);
```

## Running the tests

Then you can run the tests with:

```bash
yarn test
```

### Coding style (linting, etc) tests

Style is maintained with prettier and tslint

```
yarn lint
```

## Deployment

Deployment is preferment by lerna automatically on merge / push to main, but you'll need to bump the package version numbers yourself. Only updated packages with newer versions will be pushed to the npm registry.

## Contributing

Have a bug? File an issue with a simple example that reproduces this so we can take a look & confirm.

Want to make a change? Submit a PR, explain why it's useful, and make sure you've updated the docs (this file) and the tests (see [test folder](test)).

## License

This project is licensed under Apache 2 - see the [LICENSE](LICENSE) file for details
npm package: @ovotech/avro-logical-types
Description: Some logical types for avsc
Author: Ivan Kerin
Latest version: 1.1.2

# Avro Logical Types

Some logical types for [avsc](https://github.com/mtth/avsc).

### Using

```bash
yarn add @ovotech/avro-logical-types
```

```typescript
import { DateType } from '@ovotech/avro-logical-types';
import { Type } from 'avsc';

const type = Type.forSchema(
  {
    type: 'record',
    fields: [{ name: 'kind', type: { type: 'enum', symbols: ['CAT', 'DOG'] } }, { name: 'name', type: 'string' }],
  },
  { logicalTypes: { date: DateType } },
);
```

Or with [@ovotech/avro-stream](https://github.com/ovotech/bit-node-tools/tree/master/packages/avro-stream)

```typescript
import { AvroDeserializer } from '@ovotech/avro-stream';
import { DateType, TimestampType } from '@ovotech/avro-logical-types';

const deserializer = new AvroDeserializer('http://localhost:8081', {
  logicalTypes: { date: DateType, 'timestamp-millis': TimestampType },
});
```

### Available Types

**DateType**: Dates serialised as epoch days (number of days since epoch), deserialised as ISO String

**DateAsDateType**: Dates serialised as epoch days (number of days since epoch), deserialised as an instance of `Date`

**TimestampType**: Dates serialised as timestamp, deserialised as ISO String

**TimestampAsDateType**: Dates serialised as timestamp, deserialised as an instance of `Date`

**DecimalType**: Decimal, up to 64bit (or 63 bit signed), serialised as bytes, deserialised as an instance of [decimal.js](https://npmjs.com/decimal.js)

## Running the tests

You can run the tests with:

```bash
yarn test
```

### Coding style (linting, etc) tests

Style is maintained with prettier and tslint

```
yarn lint
```

## Deployment

Deployment is preferment by lerna automatically on merge / push to master, but you'll need to bump the package version numbers yourself. Only updated packages with newer versions will be pushed to the npm registry.

## Contributing

Have a bug? File an issue with a simple example that reproduces this so we can take a look & confirm.

Want to make a change? Submit a PR, explain why it's useful, and make sure you've updated the docs (this file) and the tests (see [test folder](test)).

## License

This project is licensed under Apache 2 - see the [LICENSE](LICENSE) file for details
npm package: @ovotech/avro-mock-generator
Description: Generate mock messages from an avro schema
Latest version: 3.0.0

# Avro Mock Generator

Create mock messages from Avro schemas.

## Usage

Call the generator with the schema:

```
import generateMsg from '@ovotech/avro-mock-generator'

const schema = {
  type: 'record',
  fields: [{ name: 'nbChickens', type: 'int' }],
}
console.log(generateData(schema));

// { nbChickens: 25672672 }
```

All fields will contain randomly generated data that respects their type.

### Options

An `options` object can optionnaly be provide as the second argument.

Supported Options:

- `generators`: An `key`/`value` object of generator functions.
  - `key`: the `type` (or `logicalType`)
  - `value`: should be a generator function `(type, context) => value` where - `type`: the content of the `type` field in the schema, either a `string` for simple type, or the type configuration for complex types - `context`: an object with contextual data, including the `generators`
    It is possible to override the default generators, and add support for extra types/logicalTypes by providing
- `pickUnion`: Array of strings to drive which member of union type to choose. Can be the short name of fully namespaced names. When this option is not provided, the first element in the union will be chosen

## Reproducible generation

Use the `Seeded` factory to create a version of the generator that will use deterministic randomness.

The factory will return a function with the same signature as the default generator.

## Supported Avro features

Based on the Avro 1.9.0 [specification](https://avro.apache.org/docs/current/spec.html).

- All primitive types
- All logical types
  - including custom logicalTypes using the `options` parameter. If a `logicalType` is missing a generator, data will be generated matching the underlying `type`.
- All complex types
  - Note that for `enum` types, the first element of the array will always be chosen.
- Type Alias

**Partial support for namespaces**. Only union types are namespaced, unconditionally.

## Contributing

All contributions are welcome, just fork the repository then create a PR. Once merged we will release a new version.

## Releasing

Simply create a [new release](https://github.com/ovotech/avro-mock-generator/releases/new) on master, with the tag being the new version (eg: 1.0.0).
npm package: @ovotech/avro-timestamp-millis
Description: A logical type representing Date as long number
Author: Ivan Kerin
Latest version: 0.1.5

# Avro Timestamp Millis

A Logical type for representing a date stored as the number of milliseconds since epoch

### Using

```bash
yarn add @ovotech/avro-timestamp-millis
```

And then you can use `AvroEpochDays` for a logicalType of a field.

> [examples/simple.ts](examples/simple.ts)

```typescript
import { Type, Schema } from 'avsc';
import { AvroTimestampMillis } from '@ovotech/avro-timestamp-millis';

const eventSchema: Schema = {
  type: 'record',
  name: 'Event',
  fields: [
    {
      name: 'field1',
      type: { type: 'long', logicalType: 'timestamp-millis' },
    },
  ],
};

const EventType = Type.forSchema(eventSchema, {
  logicalTypes: { 'timestamp-millis': AvroTimestampMillis },
});

const encoded = EventType.toBuffer({ field1: new Date('2020-01-01') });
const decoded = EventType.fromBuffer(encoded);

console.log(decoded);
```

It also supports schema evolution from int, logical:date and string types

> [examples/evolution.ts](examples/evolution.ts)

```typescript
import { Type, Schema } from 'avsc';
import { AvroTimestampMillis } from '@ovotech/avro-timestamp-millis';

const previousSchema: Schema = {
  type: 'record',
  name: 'Event',
  fields: [
    {
      name: 'field1',
      type: { type: 'string' },
    },
  ],
};

const eventSchema: Schema = {
  type: 'record',
  name: 'Event',
  fields: [
    {
      name: 'field1',
      type: { type: 'long', logicalType: 'timestamp-millis' },
    },
  ],
};

const PreviousType = Type.forSchema(previousSchema);
const EventType = Type.forSchema(eventSchema, {
  logicalTypes: { 'timestamp-millis': AvroTimestampMillis },
});
const previousTypeResolver = EventType.createResolver(PreviousType);

const encoded = PreviousType.toBuffer({ field1: '2020-01-01' });
const decoded = EventType.fromBuffer(encoded, previousTypeResolver);

console.log(decoded);
```

## Running the tests

Then you can run the tests with:

```bash
yarn test
```

### Coding style (linting, etc) tests

Style is maintained with prettier and tslint

```
yarn lint
```

## Deployment

Deployment is preferment by lerna automatically on merge / push to main, but you'll need to bump the package version numbers yourself. Only updated packages with newer versions will be pushed to the npm registry.

## Contributing

Have a bug? File an issue with a simple example that reproduces this so we can take a look & confirm.

Want to make a change? Submit a PR, explain why it's useful, and make sure you've updated the docs (this file) and the tests (see [test folder](test)).

## License

This project is licensed under Apache 2 - see the [LICENSE](LICENSE) file for details