Skip to content

Commit 9dea9c0

Browse files
wip
1 parent 3f03852 commit 9dea9c0

File tree

7 files changed

+182
-121
lines changed

7 files changed

+182
-121
lines changed

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* [Web Applications](developers/applications/web-applications.md)
1919
* [Example Projects](developers/applications/example-projects.md)
2020
* [Components](developers/components/README.md)
21+
* [Configuration](developers/components/configuration.md)
2122
* [Managing](developers/components/managing.md)
2223
* [Reference](developers/components/reference.md)
2324
* [Built-In Components](developers/components/built-in.md)

docs/developers/components/README.md

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,76 @@
11
# Components
22

3-
Harper components are a core Harper concept defined as flexible JavaScript based _extensions_ of the highly extensible core Harper platform. They are executed by Harper directly and have complete access to the Harper [Global APIs](../../technical-details/reference/globals.md) (such as `Resource`, `databases`, and `tables`).
3+
**Components** are the high-level concept for modules that extend the Harper core platform adding additional functionality. The application you built in the previous section is an example of a component. In addition to applications, components also encompass extensions.
44

5-
A key aspect to components are their extensibility; components can be built on other components. For example, a [Harper Application](../applications/README.md) is a component that uses many other components. The [application template](https://github.com/HarperDB/application-template) demonstrates many of Harper's built-in components such as `rest` (for automatic REST endpoint generation), `graphqlSchema` (for table schema definitions), and many more.
5+
**Applications** are best defined as the implementation of a specific user-facing feature or functionality. Applications are built on top of extensions and can be thought of as the end product that users interact with. For example, a Next.js application that serves a web interface or an Apollo GraphQL server that provides a GraphQL API are both applications.
66

7-
From management to development, the following pages document everything a developer needs to know about Harper components.
7+
**Extensions** are the building blocks of the Harper component system. Applications depend on extensions to provide the functionality the application is implementing. For example, the built-in `graphqlSchema` extension enables applications to define their databases and tables using GraphQL schemas. Furthermore, the `@harperdb/nextjs` and `@harperdb/apollo` extensions are the building blocks that provide support for building Next.js and Apollo applications.
88

9-
- [Managing Components](./managing.md) - developing, installing, deploying, and executing Harper components locally and remotely
10-
- [Technical Reference](./reference.md) - detailed, technical reference for component development
11-
- [Built-In Components](./built-in.md) - documentation for all of Harper's built-in components (i.e. `rest`)
9+
All together, the support for implementing a feature is the extension, and the actual implementation of the feature is the application.
1210

13-
## Custom Components
11+
Extensions can also depend on other extensions. For example, the [`@harperdb/apollo`](https://github.com/HarperDB/apollo) extension depends on the built-in `graphqlSchema` extension to create a cache table for Apollo queries. Applications can then use the `@harperdb/apollo` extension to implement an Apollo GraphQL backend server.
1412

15-
The following list is all of Harper's officially maintained, custom components. They are all available on npm and GitHub.
13+
```mermaid
14+
flowchart TD
15+
subgraph Applications
16+
direction TB
17+
NextJSApp["Next.js App"]
18+
ApolloApp["Apollo App"]
19+
CustomResource["Custom Resource"]
20+
end
21+
22+
subgraph Extensions
23+
direction TB
24+
subgraph Custom
25+
NextjsExt["@harperdb/nextjs"]
26+
ApolloExt["@harperdb/apollo"]
27+
end
28+
subgraph Built-In
29+
GraphqlSchema["graphqlSchema"]
30+
JsResource["jsResource"]
31+
Rest["rest"]
32+
end
33+
end
34+
35+
subgraph Core
36+
direction TB
37+
Database["database"]
38+
FileSystem["file-system"]
39+
Networking["networking"]
40+
end
41+
42+
NextJSApp --> NextjsExt
43+
ApolloApp --> ApolloExt
44+
CustomResource --> JsResource & GraphqlSchema & Rest
45+
46+
NextjsExt --> Networking
47+
NextjsExt --> FileSystem
48+
ApolloExt --> GraphqlSchema
49+
ApolloExt --> Networking
50+
51+
GraphqlSchema --> Database
52+
JsResource --> Database
53+
Rest --> Networking
54+
55+
```
56+
57+
> As of Harper v4.6, a new, **experimental** component system has been introduced called **plugins**. Plugins are a **new iteration of the existing extension system**. They are simultaneously a simplification and an extensibility upgrade. Instead of defining multiple methods (`start` vs `startOnMainThread`, `handleFile` vs `setupFile`, `handleDirectory` vs `setupDirectory`), plugins only have to define a single `handleComponent` method. Plugins are **experimental**, and complete documentation is available on the [Plugin API](./plugins.md) page. In time we plan to deprecate the concept of extensions in favor of plugins, but for now, both are supported.
58+
59+
Beyond applications and extensions, components are further classified as built-in or custom. **Built-in** components are included with Harper by default and can be directly referenced by their name. The `graphqlSchema`, `rest`, and `jsResource` extensions used in the previous application example are all examples of built-in extensions. **Custom** components must use external references, generally npm or GitHub packages, and are often included as dependencies within the `package.json` of the component.
60+
61+
> Harper maintains a number of custom components that are available on `npm` and `GitHub`, such as the [`@harperdb/nextjs`](https://github.com/HarperDB/nextjs) extension or the [`@harperdb/status-check`](https://github.com/HarperDB/status-check) application.
62+
63+
64+
Harper does not currently include any built-in applications, making "custom applications" a bit redundant. Generally, we just say "application". However, there is a multitude of both built-in and custom extensions, and so the documentation refers to them as such. A complete list of built-in extensions is available in the [Built-In Extensions](./built-in.md) documentation page, and the list of custom extensions and applications is available below.
65+
66+
## Custom Applications
1667

17-
- [`@harperdb/nextjs`](https://github.com/HarperDB/nextjs)
18-
- [`@harperdb/apollo`](https://github.com/HarperDB/apollo)
1968
- [`@harperdb/status-check`](https://github.com/HarperDB/status-check)
2069
- [`@harperdb/prometheus-exporter`](https://github.com/HarperDB/prometheus-exporter)
2170
- [`@harperdb/acl-connect`](https://github.com/HarperDB/acl-connect)
71+
72+
## Custom Extensions
73+
74+
- [`@harperdb/nextjs`](https://github.com/HarperDB/nextjs)
75+
- [`@harperdb/apollo`](https://github.com/HarperDB/apollo)
2276
- [`@harperdb/astro`](https://github.com/HarperDB/astro)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Component Configuration
2+
3+
Harper components are configured with a `config.yaml` file located in the root of the component module directory. This file is how a component configures other components it depends on. Each entry in the file starts with a component name, and then configuration values are indented below it.
4+
5+
```yaml
6+
name:
7+
option-1: value
8+
option-2: value
9+
```
10+
11+
It is the entry's `name` that is used for component resolution. It can be one of the [built-in extensions](./built-in.md), or it must match a package dependency of the component as specified by `package.json`. The [Custom Component Configuration](#custom-component-configuration) section provides more details and examples.
12+
13+
For some built-in components they can be configured with as little as a top-level boolean; for example, the [rest](./built-in.md#rest) extension can be enabled with just:
14+
15+
```yaml
16+
rest: true
17+
```
18+
19+
Most components generally have more configuration options. Some options are ubiquitous to the Harper platform, such as the `files` and `urlPath` options for an [extension](./extensions.md) or [plugin](./plugins.md), or `package` for any [custom component](#custom-component-configuration).
20+
21+
## Custom Component Configuration
22+
23+
Any custom component **must** be configured with the `package` option in order for Harper to load that component. When enabled, the name of package must match a dependency of the component. For example, to use the `@harperdb/nextjs` extension, it must first be included in `package.json`:
24+
25+
```json
26+
{
27+
"dependencies": {
28+
"@harperdb/nextjs": "1.0.0"
29+
}
30+
}
31+
```
32+
33+
Then, within `config.yaml` it can be enabled and configured using:
34+
35+
```yaml
36+
'@harperdb/nextjs':
37+
package: '@harperdb/nextjs'
38+
# ...
39+
```
40+
41+
Since npm allows for a [variety of dependency configurations](https://docs.npmjs.com/cli/configuring-npm/package-json#dependencies), this can be used to create custom references. For example, to depend on a specific GitHub branch, first update the `package.json`:
42+
43+
```json
44+
{
45+
"dependencies": {
46+
"harper-nextjs-test-feature": "HarperDB/nextjs#test-feature"
47+
}
48+
}
49+
```
50+
51+
And now in `config.yaml`:
52+
53+
```yaml
54+
harper-nextjs-test-feature:
55+
package: '@harperdb/nextjs'
56+
files: './'
57+
# ...
58+
```
59+
60+
## Default Component Configuration
61+
62+
Harper components do not need to specify a `config.yaml`. Harper uses the following default configuration to load components.
63+
64+
```yaml
65+
rest: true
66+
graphqlSchema:
67+
files: '*.graphql'
68+
roles:
69+
files: 'roles.yaml'
70+
jsResource:
71+
files: 'resources.js'
72+
fastifyRoutes:
73+
files: 'routes/*.js'
74+
urlPath: '.'
75+
static:
76+
files: 'web/**'
77+
```
78+
79+
Refer to the [built-in components](./built-in.md) documentation for more information on these fields.
80+
81+
If a `config.yaml` is defined, it will **not** be merged with the default config.

docs/developers/components/extensions.md

Whitespace-only changes.

0 commit comments

Comments
 (0)