@harperfast/template-react-studio 0.11.0 → 0.12.0
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.
- package/AGENTS.md +1 -1
- package/package.json +1 -1
- package/resources/README.md +11 -0
- package/schemas/README.md +11 -0
- package/resources/examplePeople.js +0 -14
- package/resources/exampleSocket.js +0 -34
- package/resources/greeting.js +0 -10
- package/schemas/exampleCat.graphql +0 -6
- package/schemas/examplePeople.graphql +0 -7
- /package/skills/{adding-tables.md → adding-tables-with-schemas.md} +0 -0
package/AGENTS.md
CHANGED
|
@@ -4,7 +4,7 @@ This repository contains "skills" that guide AI agents in developing Harper appl
|
|
|
4
4
|
|
|
5
5
|
## Available Skills
|
|
6
6
|
|
|
7
|
-
- [Adding Tables](skills/adding-tables.md): Learn how to define schemas and enable automatic REST APIs for your database tables.
|
|
7
|
+
- [Adding Tables with Schemas](skills/adding-tables-with-schemas.md): Learn how to define schemas and enable automatic REST APIs for your database tables with schema .graphql files in Harper.
|
|
8
8
|
- [Automatic REST APIs](skills/automatic-rest-apis.md): Details on the CRUD endpoints automatically generated for exported tables.
|
|
9
9
|
- [Querying REST APIs](skills/querying-rest-apis.md): How to use filters, operators, sorting, and pagination in REST requests.
|
|
10
10
|
- [Programmatic Table Requests](skills/programmatic-table-requests.md): How to use filters, operators, sorting, and pagination in programmatic table requests.
|
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Resources
|
|
2
|
+
|
|
3
|
+
The [schemas you define in .GraphQL files](../skills/adding-tables-with-schemas.md) will [automatically stand-up REST APIs](../skills/automatic-rest-apis.md).
|
|
4
|
+
|
|
5
|
+
But you can [extend your tables with custom logic](../skills/extending-tables.md) and [create your own resources](../skills/custom-resources.md) in this directory.
|
|
6
|
+
|
|
7
|
+
## Want to read more?
|
|
8
|
+
|
|
9
|
+
Check out the rest of the "skills" documentation!
|
|
10
|
+
|
|
11
|
+
[AGENTS.md](../AGENTS.md)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Schemas
|
|
2
|
+
|
|
3
|
+
Your schemas are defined in `.graphql` files within this `schemas` directory. These files contain the structure and types for your database tables, allowing Harper to automatically generate REST APIs for CRUD operations.
|
|
4
|
+
|
|
5
|
+
Take a look at the [Adding Tables with Schemas](../skills/adding-tables-with-schemas.md) to learn more!
|
|
6
|
+
|
|
7
|
+
## Want to read more?
|
|
8
|
+
|
|
9
|
+
Check out the rest of the "skills" documentation!
|
|
10
|
+
|
|
11
|
+
[AGENTS.md](../AGENTS.md)
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { tables } from 'harperdb';
|
|
2
|
-
|
|
3
|
-
export class ExamplePeople extends tables.ExamplePeople {
|
|
4
|
-
// we can define our own custom POST handler
|
|
5
|
-
post(content) {
|
|
6
|
-
// do something with the incoming content;
|
|
7
|
-
return super.post(content);
|
|
8
|
-
}
|
|
9
|
-
// or custom GET handler
|
|
10
|
-
get() {
|
|
11
|
-
// we can modify this resource before returning
|
|
12
|
-
return super.get();
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Resource, tables } from 'harperdb';
|
|
2
|
-
|
|
3
|
-
export class ExampleSocket extends Resource {
|
|
4
|
-
static loadAsInstance = false;
|
|
5
|
-
|
|
6
|
-
// This customizes handling the socket connections; tables can have this method too!
|
|
7
|
-
async *connect(
|
|
8
|
-
target,
|
|
9
|
-
incomingMessages,
|
|
10
|
-
) {
|
|
11
|
-
const subscription = await tables.ExamplePeople.subscribe(target);
|
|
12
|
-
if (!incomingMessages) {
|
|
13
|
-
// Server sent events, no incoming messages!
|
|
14
|
-
// Subscribe to changes to the table.
|
|
15
|
-
return subscription;
|
|
16
|
-
}
|
|
17
|
-
for await (let message of incomingMessages) {
|
|
18
|
-
const { type, id, name, tag } = message;
|
|
19
|
-
switch (type) {
|
|
20
|
-
case 'get':
|
|
21
|
-
const loaded = await tables.ExamplePeople.get(id);
|
|
22
|
-
yield {
|
|
23
|
-
type: 'get',
|
|
24
|
-
id,
|
|
25
|
-
...(loaded ? loaded : {}),
|
|
26
|
-
};
|
|
27
|
-
break;
|
|
28
|
-
case 'put':
|
|
29
|
-
await tables.ExamplePeople.put(id, { name, tag });
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
package/resources/greeting.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
## This table is @export'ed, which means API endpoints are stood up for it automatically.
|
|
2
|
-
type ExampleCat @table @export {
|
|
3
|
-
id: ID @primaryKey # Here we define primary key (must be one)
|
|
4
|
-
name: String # we can define any other attributes here
|
|
5
|
-
tag: String @indexed # we can specify any attributes that should be indexed
|
|
6
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
## Here we can define any tables in our database. This example shows how we define a type as a table using
|
|
2
|
-
## the type name as the table name and specifying it is an "export" available in the REST and other external protocols.
|
|
3
|
-
type ExamplePeople @table @export {
|
|
4
|
-
id: ID @primaryKey # Here we define primary key (must be one)
|
|
5
|
-
name: String # we can define any other attributes here
|
|
6
|
-
tag: String @indexed # we can specify any attributes that should be indexed
|
|
7
|
-
}
|
|
File without changes
|