open-index/open-npm huggingface dataset:
npm package: @smartlyio/oats-nock-adapter
Description: nock server adapter for smartlyio/oats s
Author: Smartly.io
Latest version: 7.7.8

# Nock server adapter for smartlyio/oats

Nock adapter for creating mock servers from openapi definitions using oats.

To mock the request `POST /item` define the route as for any oats server adapter 
and then bind the route defining object to the nock adapter. The bound mock 
servers are namespaced using the OpenApi server strings as nock basepaths  so that 
multiple nock mocks can be used simultanenously so long as the basepaths differ. 
All of the mocked routes are persisted so any number of requests are served.

```ts
>>examples/example.ts
```

The `bind` call is just a constructor for a `Server` class that provides a `mock` method for 
adding new mocked routes or overlaying new handlers on top of already mocked routes. 
If the overlaying mock throws `Next` the previous mock for the route is called instead.

```ts
>>examples/server.ts
```
npm package: @smartlyio/oats-runtime
Description: Runtime for Oats a Openapi3 based generator for typescript aware servers and clients
Author: Smartly.io
Latest version: 7.7.8

# Runtime for smartlyio/oats

This package provides the runtime code required for using [@smartlyio/oats](https://www.npmjs.com/package/@smartlyio/oats) generated Openapi3 clients and servers. For usage examples see [oats github page](https://github.com/smartlyio/oats).
npm package: @smartlyio/safe-navigation
Description: typescript and null safe json object navigation
Author: Smartly.io
Latest version: 5.1.1

# safe-navigation

type(script) and null safe navigation in json objects 

## get `.$`

Returns the value or undefined if any value on the path to it is undefined

```js
// yarn ts-node examples/getter.ts
import safe from '../index';
import * as assert from 'assert';

interface A {
  a?: { b?: string };
}
const o: A = { a: { b: 'x' } };
assert(safe(o).a.b.$ === 'x');

```

The optional chaining also takes into account union types.

```js
// yarn ts-node examples/unions.ts
import safe from '../index';
import * as assert from 'assert';

type A = { a: number } | { b: string };
const o: A = { a: 1 };
assert(safe(o).a.$ === 1);

```

## set value `.$set`

Returns a new object with the target set to value if the path to value exists

```js
// yarn ts-node examples/set.ts
import safe from '../index';
import * as assert from 'assert';

interface A {
  a?: { b?: string };
}
const o: A = { a: { b: 'old' } };
const newValue: A = safe(o).a.b.$set('new');
assert(safe(newValue).a.b.$ === 'new');

```

## map value `.$map`

Maps the value at end of the path

```js
// yarn ts-node examples/map.ts
import safe from '../index';
import * as assert from 'assert';

interface A {
  a?: { b?: string };
}
const o: A = { a: { b: 'old' } };
const newValue: A = safe(o).a.b.$map((n: any) => n + ' to new');
assert(safe(newValue).a.b.$ === 'old to new');

```

## map with promises `.$pmap`

Returns a new object with the target mapped using a promise returning map function

```js
// yarn ts-node examples/pmap.ts
import safe from '../index';
import * as assert from 'assert';

interface A {
  a?: { b?: string };
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async function () {
  const o: A = { a: { b: 'x' } };
  const result = await safe(o).a.b.$pmap(async value => 'got ' + value);
  assert(safe(o).a.b.$ === 'x');
  assert(safe(result).a.b.$ === 'got x');
})();

```