@harperfast/template-react-ts-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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harperfast/template-react-ts-studio",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "type": "module",
5
5
  "repository": "github:HarperFast/create-harper",
6
6
  "scripts": {},
@@ -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,20 +0,0 @@
1
- import { type RequestTargetOrId, tables } from 'harperdb';
2
-
3
- export interface ExamplePerson {
4
- id: string;
5
- name: string;
6
- tag: string;
7
- }
8
-
9
- export class ExamplePeople extends tables.ExamplePeople<ExamplePerson> {
10
- // we can define our own custom POST handler
11
- async post(target: RequestTargetOrId, newRecord: Omit<ExamplePerson, 'id'>) {
12
- // do something with the incoming content;
13
- return super.post(target, newRecord);
14
- }
15
- // or custom GET handler
16
- async get(target: RequestTargetOrId): Promise<ExamplePerson> {
17
- // we can modify this resource before returning
18
- return super.get(target);
19
- }
20
- }
@@ -1,41 +0,0 @@
1
- import { type IterableEventQueue, RequestTarget, Resource, tables } from 'harperdb';
2
-
3
- interface ExampleSocketRecord {
4
- id: string;
5
- type?: 'get' | 'put';
6
- name: string;
7
- tag: string;
8
- }
9
-
10
- export class ExampleSocket extends Resource<ExampleSocketRecord> {
11
- static loadAsInstance = false;
12
-
13
- // This customizes handling the socket connections; tables can have this method too!
14
- async *connect(
15
- target: RequestTarget,
16
- incomingMessages: IterableEventQueue<ExampleSocketRecord>,
17
- ): AsyncIterable<ExampleSocketRecord> {
18
- const subscription = await tables.ExamplePeople.subscribe(target);
19
- if (!incomingMessages) {
20
- // Server sent events, no incoming messages!
21
- // Subscribe to changes to the table.
22
- return subscription;
23
- }
24
- for await (let message of incomingMessages) {
25
- const { type, id, name, tag } = message;
26
- switch (type) {
27
- case 'get':
28
- const loaded = await tables.ExamplePeople.get(id);
29
- yield {
30
- type: 'get',
31
- id,
32
- ...(loaded ? loaded : {}),
33
- };
34
- break;
35
- case 'put':
36
- await tables.ExamplePeople.put(id, { name, tag });
37
- break;
38
- }
39
- }
40
- }
41
- }
@@ -1,29 +0,0 @@
1
- import { type RecordObject, type RequestTargetOrId, Resource } from 'harperdb';
2
-
3
- interface GreetingRecord {
4
- greeting: string;
5
- }
6
-
7
- export class Greeting extends Resource<GreetingRecord> {
8
- static loadAsInstance = false;
9
-
10
- async post(target: RequestTargetOrId, newRecord: Partial<GreetingRecord & RecordObject>): Promise<GreetingRecord> {
11
- return { greeting: 'Greetings, post!' };
12
- }
13
-
14
- async get(target?: RequestTargetOrId): Promise<GreetingRecord> {
15
- return { greeting: 'Greetings, get!' };
16
- }
17
-
18
- async put(target: RequestTargetOrId, record: GreetingRecord & RecordObject): Promise<GreetingRecord> {
19
- return { greeting: 'Greetings, put!' };
20
- }
21
-
22
- async patch(target: RequestTargetOrId, record: Partial<GreetingRecord & RecordObject>): Promise<GreetingRecord> {
23
- return { greeting: 'Greetings, patch!' };
24
- }
25
-
26
- async delete(target: RequestTargetOrId): Promise<boolean> {
27
- return true;
28
- }
29
- }
@@ -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
- }