Type constraints for the OpenHub ecosystem
npm install @openhub2/dharmaType constraints for the OpenHub ecosystem.
Dharma defines the law that all OpenHub layers must conform to:
- Layers: Provider, Runtime, Metaframework
- Boundaries: What crosses between layers
- Bindings: Database, KV, Blob
If you're using an OpenHub metaframework or runtime, dharma is included as a transitive dependency. You only need to install it directly if you're building a Provider, Runtime, or Metaframework.
``bash`
pnpm add -D @openhub2/dharma
`typescript`
import type { Provider, Runtime, Metaframework } from '@openhub2/dharma'
`typescript`
import type {
DatabaseBinding,
KVBinding,
BlobBinding,
Bindings
} from '@openhub2/dharma/subtypes'
`typescript`
import type { ProxyRequest, ProxyResponse } from '@openhub2/dharma/boundaries'
| Export | Path | Contents |
|--------|------|----------|
| Main | @openhub2/dharma | Provider, Runtime, Metaframework |@openhub2/dharma/layers
| Layers | | Layer type definitions |@openhub2/dharma/boundaries
| Boundaries | | ProxyRequest, ProxyResponse, cross-layer contracts |@openhub2/dharma/subtypes
| Subtypes | | Bindings, DatabaseBinding, KVBinding, BlobBinding |
If you are building a Provider, Runtime, or Metaframework, your implementation must satisfy the types defined here.
`typescript
import type { Provider } from '@openhub2/dharma'
export const myProvider: Provider = {
name: 'my-provider',
supportedBindings: ['database', 'kv', 'blob'],
createLocalBindings(transport) { / ... / },
createProxyHandler() { / ... / },
extractBindings(platformContext) { / ... / },
}
`
`typescript
import type { Runtime } from '@openhub2/dharma'
export const myRuntime: Runtime = {
name: 'my-runtime',
registerProvider(provider) { / ... / },
registerProxyEndpoint(handler) { / ... / },
injectBindings(context, bindings) { / ... / },
isRemoteMode() { / ... / },
}
`
`typescript
import type { Metaframework } from '@openhub2/dharma'
export const myMetaframework: Metaframework = {
name: 'my-metaframework',
configureRuntime(runtime, config) { / ... / },
defineConfig(schema) { / ... / },
registerCLI(cli) { / ... / },
registerDevtools(devtools) { / ... / },
}
``
See constitution.md for the full constitution.
Apache-2.0