@harperfast/template-vue-studio 1.5.20 → 1.5.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,10 +8,11 @@ Guidelines for building scalable, secure, and performant applications on Harper.
|
|
|
8
8
|
|
|
9
9
|
1. [Schema & Data Design](#1-schema--data-design) — **HIGH**
|
|
10
10
|
- 1.1 [Adding Tables with Schemas](#11-adding-tables-with-schemas)
|
|
11
|
-
- 1.2 [
|
|
12
|
-
- 1.3 [
|
|
13
|
-
- 1.4 [
|
|
14
|
-
- 1.5 [
|
|
11
|
+
- 1.2 [Schema Design & Tooling](#12-schema-design--tooling)
|
|
12
|
+
- 1.3 [Defining Relationships](#13-defining-relationships)
|
|
13
|
+
- 1.4 [Vector Indexing](#14-vector-indexing)
|
|
14
|
+
- 1.5 [Using Blobs](#15-using-blobs)
|
|
15
|
+
- 1.6 [Handling Binary Data](#16-handling-binary-data)
|
|
15
16
|
2. [API & Communication](#2-api--communication) — **HIGH**
|
|
16
17
|
- 2.1 [Automatic REST APIs](#21-automatic-rest-apis)
|
|
17
18
|
- 2.2 [Querying REST APIs](#22-querying-rest-apis)
|
|
@@ -61,7 +62,66 @@ type ExamplePerson @table @export {
|
|
|
61
62
|
}
|
|
62
63
|
```
|
|
63
64
|
|
|
64
|
-
### 1.2
|
|
65
|
+
### 1.2 Schema Design & Tooling
|
|
66
|
+
|
|
67
|
+
Harper uses GraphQL schemas to define database tables, relationships, and APIs. To ensure the best development experience for both humans and AI agents, it's important to understand the core directives and configure your project tooling correctly.
|
|
68
|
+
|
|
69
|
+
#### Core Harper Directives
|
|
70
|
+
|
|
71
|
+
Harper extends GraphQL with custom directives that define database behavior. These are typically defined in `node_modules/harperdb/schema.graphql`. If you don't have access to that file, here is a reference of the most important ones:
|
|
72
|
+
|
|
73
|
+
##### Table Definition
|
|
74
|
+
- `@table`: Marks a GraphQL type as a Harper database table.
|
|
75
|
+
- `@export`: Automatically generates REST and WebSocket APIs for the table.
|
|
76
|
+
- `@table(expiration: Int)`: Configures a time-to-expire for records in the table (useful for caching).
|
|
77
|
+
|
|
78
|
+
##### Attribute Constraints & Indexing
|
|
79
|
+
- `@primaryKey`: Specifies the unique identifier for the table.
|
|
80
|
+
- `@indexed`: Creates a standard index on the field for faster lookups.
|
|
81
|
+
- `@indexed(type: "HNSW", distance: "cosine" | "euclidean" | "dot")`: Creates a vector index for similarity search.
|
|
82
|
+
|
|
83
|
+
##### Relationships
|
|
84
|
+
- `@relationship(from: String)`: Defines a relationship to another table. `from` specifies the local field holding the foreign key.
|
|
85
|
+
|
|
86
|
+
##### Authentication & Authorization
|
|
87
|
+
- `@auth(role: String)`: Restricts access to a table or field based on user roles.
|
|
88
|
+
|
|
89
|
+
#### Configuring GraphQL Tooling
|
|
90
|
+
|
|
91
|
+
To get the best IDE support (autocompletion, validation) and to help AI agents understand your schema context, you should create a `graphql.config.yml` file in your project root.
|
|
92
|
+
|
|
93
|
+
This file tells GraphQL tools where to find Harper's built-in types and directives alongside your own schema files.
|
|
94
|
+
|
|
95
|
+
##### Creating `graphql.config.yml`
|
|
96
|
+
|
|
97
|
+
Create a file named `graphql.config.yml` in your project root with the following content:
|
|
98
|
+
|
|
99
|
+
```yaml
|
|
100
|
+
schema:
|
|
101
|
+
- "node_modules/harperdb/schema.graphql"
|
|
102
|
+
- "schema.graphql"
|
|
103
|
+
- "schemas/*.graphql"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
##### Why this is important:
|
|
107
|
+
1. **Shared Directives**: It includes `@table`, `@primaryKey`, etc., so they aren't marked as "unknown directives".
|
|
108
|
+
2. **Context for Agents**: When an agent reads your project, seeing this config helps it locate the core Harper definitions, leading to more accurate code generation.
|
|
109
|
+
3. **Consistency**: The `npm create harper@latest` command includes this by default. Manually adding it to existing projects ensures they follow the same standards.
|
|
110
|
+
|
|
111
|
+
#### Example Project Structure
|
|
112
|
+
|
|
113
|
+
A typical Harper project with proper schema tooling:
|
|
114
|
+
|
|
115
|
+
```text
|
|
116
|
+
my-harper-app/
|
|
117
|
+
├── config.yaml
|
|
118
|
+
├── graphql.config.yml
|
|
119
|
+
├── package.json
|
|
120
|
+
├── schema.graphql
|
|
121
|
+
└── resources.js
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 1.3 Defining Relationships
|
|
65
125
|
|
|
66
126
|
Using the `@relationship` directive to link tables.
|
|
67
127
|
|
|
@@ -105,7 +165,7 @@ type Category @table @export {
|
|
|
105
165
|
}
|
|
106
166
|
```
|
|
107
167
|
|
|
108
|
-
### 1.
|
|
168
|
+
### 1.4 Vector Indexing
|
|
109
169
|
|
|
110
170
|
How to define and use vector indexes for efficient similarity search.
|
|
111
171
|
|
|
@@ -130,7 +190,7 @@ type Document @table @export {
|
|
|
130
190
|
}
|
|
131
191
|
```
|
|
132
192
|
|
|
133
|
-
### 1.
|
|
193
|
+
### 1.5 Using Blobs
|
|
134
194
|
|
|
135
195
|
How to store and retrieve large data in Harper.
|
|
136
196
|
|
|
@@ -144,7 +204,7 @@ Use this when you need to store large, unstructured data such as files, images,
|
|
|
144
204
|
2. **Storing Data**: Send the data as a buffer or a stream when creating or updating a record.
|
|
145
205
|
3. **Retrieving Data**: Access the blob field, which will return the data as a stream or buffer.
|
|
146
206
|
|
|
147
|
-
### 1.
|
|
207
|
+
### 1.6 Handling Binary Data
|
|
148
208
|
|
|
149
209
|
How to store and serve binary data like images or MP3s.
|
|
150
210
|
|
|
@@ -52,6 +52,7 @@ See the concrete examples embedded in each rule subsection below (GraphQL schema
|
|
|
52
52
|
### 1. Schema & Data Design (HIGH)
|
|
53
53
|
|
|
54
54
|
- `adding-tables-with-schemas` - Define tables using GraphQL schemas and directives
|
|
55
|
+
- `schema-design-tooling` - Core directives and GraphQL IDE/agent configuration
|
|
55
56
|
- `defining-relationships` - Link tables using the `@relationship` directive
|
|
56
57
|
- `vector-indexing` - Efficient similarity search with vector indexes
|
|
57
58
|
- `using-blob-datatype` - Store and retrieve large data (Blobs)
|
|
@@ -85,6 +86,7 @@ Read individual rule files for detailed explanations and code examples:
|
|
|
85
86
|
|
|
86
87
|
```
|
|
87
88
|
rules/adding-tables-with-schemas.md
|
|
89
|
+
rules/schema-design-tooling.md
|
|
88
90
|
rules/automatic-apis.md
|
|
89
91
|
rules/creating-harper-apps.md
|
|
90
92
|
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: schema-design-tooling
|
|
3
|
+
description: Best practices for Harper schema design, including core directives and GraphQL tooling configuration.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Schema Design & Tooling
|
|
7
|
+
|
|
8
|
+
Harper uses GraphQL schemas to define database tables, relationships, and APIs. To ensure the best development experience for both humans and AI agents, it's important to understand the core directives and configure your project tooling correctly.
|
|
9
|
+
|
|
10
|
+
## Core Harper Directives
|
|
11
|
+
|
|
12
|
+
Harper extends GraphQL with custom directives that define database behavior. These are typically defined in `node_modules/harperdb/schema.graphql`. If you don't have access to that file, here is a reference of the most important ones:
|
|
13
|
+
|
|
14
|
+
### Table Definition
|
|
15
|
+
- `@table`: Marks a GraphQL type as a Harper database table.
|
|
16
|
+
- `@export`: Automatically generates REST and WebSocket APIs for the table.
|
|
17
|
+
- `@table(expiration: Int)`: Configures a time-to-expire for records in the table (useful for caching).
|
|
18
|
+
|
|
19
|
+
### Attribute Constraints & Indexing
|
|
20
|
+
- `@primaryKey`: Specifies the unique identifier for the table.
|
|
21
|
+
- `@indexed`: Creates a standard index on the field for faster lookups.
|
|
22
|
+
- `@indexed(type: "HNSW", distance: "cosine" | "euclidean" | "dot")`: Creates a vector index for similarity search.
|
|
23
|
+
|
|
24
|
+
### Relationships
|
|
25
|
+
- `@relationship(from: String)`: Defines a relationship to another table. `from` specifies the local field holding the foreign key.
|
|
26
|
+
|
|
27
|
+
### Authentication & Authorization
|
|
28
|
+
- `@auth(role: String)`: Restricts access to a table or field based on user roles.
|
|
29
|
+
|
|
30
|
+
## Configuring GraphQL Tooling
|
|
31
|
+
|
|
32
|
+
To get the best IDE support (autocompletion, validation) and to help AI agents understand your schema context, you should create a `graphql.config.yml` file in your project root.
|
|
33
|
+
|
|
34
|
+
This file tells GraphQL tools where to find Harper's built-in types and directives alongside your own schema files.
|
|
35
|
+
|
|
36
|
+
### Creating `graphql.config.yml`
|
|
37
|
+
|
|
38
|
+
Create a file named `graphql.config.yml` in your project root with the following content:
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
schema:
|
|
42
|
+
- "node_modules/harperdb/schema.graphql"
|
|
43
|
+
- "schema.graphql"
|
|
44
|
+
- "schemas/*.graphql"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Why this is important:
|
|
48
|
+
1. **Shared Directives**: It includes `@table`, `@primaryKey`, etc., so they aren't marked as "unknown directives".
|
|
49
|
+
2. **Context for Agents**: When an agent reads your project, seeing this config helps it locate the core Harper definitions, leading to more accurate code generation.
|
|
50
|
+
3. **Consistency**: The `npm create harper@latest` command includes this by default. Manually adding it to existing projects ensures they follow the same standards.
|
|
51
|
+
|
|
52
|
+
## Example Project Structure
|
|
53
|
+
|
|
54
|
+
A typical Harper project with proper schema tooling:
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
my-harper-app/
|
|
58
|
+
├── config.yaml
|
|
59
|
+
├── graphql.config.yml
|
|
60
|
+
├── package.json
|
|
61
|
+
├── schema.graphql
|
|
62
|
+
└── resources.js
|
|
63
|
+
```
|
package/config.yaml
CHANGED
|
@@ -19,9 +19,7 @@ graphqlSchema:
|
|
|
19
19
|
jsResource:
|
|
20
20
|
files: 'resources/*.js'
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
jsdoc: 'schemas/jsdocTypes.js'
|
|
25
|
-
|
|
22
|
+
# Generates jsdoc types for the schema so your code is schema-aware
|
|
23
|
+
# Bootstraps Vite to build your frontend to HTML/JS/CSS
|
|
26
24
|
'@harperfast/vite-plugin':
|
|
27
25
|
package: '@harperfast/vite-plugin'
|
package/package.json
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harperfast/template-vue-studio",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": "github:HarperFast/create-harper",
|
|
6
6
|
"scripts": {},
|
|
7
|
-
"devDependencies": {
|
|
8
|
-
"@eslint/js": "^10.0.1",
|
|
9
|
-
"@harperfast/schema-codegen": "^1.0.10",
|
|
10
|
-
"@harperfast/vite-plugin": "^0.2.1",
|
|
11
|
-
"@vitejs/plugin-vue": "^6.0.5",
|
|
12
|
-
"dotenv-cli": "^11.0.0",
|
|
13
|
-
"eslint": "^10.0.2",
|
|
14
|
-
"globals": "^17.4.0",
|
|
15
|
-
"prettier": "^3.8.1",
|
|
16
|
-
"vite": "^8.0.0",
|
|
17
|
-
"vue": "^3.5.29"
|
|
18
|
-
}
|
|
7
|
+
"devDependencies": {}
|
|
19
8
|
}
|
package/skills-lock.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"harper-best-practices": {
|
|
5
5
|
"source": "harperfast/skills",
|
|
6
6
|
"sourceType": "github",
|
|
7
|
-
"computedHash": "
|
|
7
|
+
"computedHash": "20b7623e2a79067e2362cd6ffee756f7d039259ff33dd52f2b69ff8f8e3c06bb"
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
}
|