README.md 1.05 KB
Newer Older
1 2 3
# TypeScript Definitions for UnityBase

This is a very limited version of TS definitions for UnityBase.
4 5 6 7 8 9 10 11 12 13 14 15 16 17

In order to make sure IDE "just work" with the type definitions,
the structure, naming and other followed "DefinitelyTyped" project.

Package name scope is "@types", and not "@unitybase".

# Repository note

Packages are published to [http://registry.unitybase.info].  Make sure use that
registry, when install packages.

# Example

```
18
npm install -D @types/unitybase__ub-pub --registry http://registry.unitybase.info
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
```

```
import {UBConnection} from '@unitybase/ub-pub';


// ... somewhere later in code
async function () {
    // ...
	const cn: UBConnection = await UB.connect({
		host: `${protocol}//${host}:${port}`, path,
		async onCredentialRequired() {
			return {authMethod: 'UBIP', login: 'service-user'};
		}
	});

	const userId = await cn.Repository('uba_user')
		.attrs('ID')
		.where('name', '=', userName)
		.selectScalar();
}
```

And that shall be a valid typescript with full intellisense support, of course
with limitation of which types are defined.