@harperfast/template-react-ts-studio 0.12.3 → 0.12.4

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
@@ -1,11 +1,11 @@
1
- # HarperDB Agent Skills
1
+ # Harper Agent Skills
2
2
 
3
3
  This repository contains "skills" that guide AI agents in developing Harper applications.
4
4
 
5
5
  ## Available Skills
6
6
 
7
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
- - [Automatic REST APIs](skills/automatic-rest-apis.md): Details on the CRUD endpoints automatically generated for exported tables.
8
+ - [Automatic APIs](skills/automatic-apis.md): Details on the CRUD endpoints automatically generated for exported tables with REST and WebSockets.
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.
11
11
  - [Custom Resources](skills/custom-resources.md): How to define custom REST endpoints using JavaScript or TypeScript (Note: Paths are case-sensitive).
@@ -16,3 +16,4 @@ This repository contains "skills" that guide AI agents in developing Harper appl
16
16
  - [Handling Binary Data](skills/handling-binary-data.md): How to store and serve binary data like images or MP3s.
17
17
  - [Serving Web Content](skills/serving-web-content): Two ways to serve web content from a Harper application.
18
18
  - [Checking Authentication](skills/checking-authentication.md): How to use sessions to verify user identity and roles.
19
+ [adding-tables-with-schemas.md](skills/adding-tables-with-schemas.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harperfast/template-react-ts-studio",
3
- "version": "0.12.3",
3
+ "version": "0.12.4",
4
4
  "type": "module",
5
5
  "repository": "github:HarperFast/create-harper",
6
6
  "scripts": {},
@@ -1,6 +1,6 @@
1
1
  # Resources
2
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).
3
+ The [schemas you define in .GraphQL files](../skills/adding-tables-with-schemas.md) will [automatically stand-up REST APIs](../skills/automatic-apis.md).
4
4
 
5
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
6
 
@@ -1,4 +1,4 @@
1
- # Adding Tables to HarperDB
1
+ # Adding Tables to Harper
2
2
 
3
3
  To add tables to a Harper database, follow these guidelines:
4
4
 
@@ -8,7 +8,7 @@ To add tables to a Harper database, follow these guidelines:
8
8
 
9
9
  3. **Defining Relationships**: You can link tables together using the `@relationship` directive. For more details, see the [Defining Relationships](defining-relationships.md) skill.
10
10
 
11
- 4. **Automatic REST APIs**: If you add `@table @export` to a schema type, HarperDB automatically sets up REST APIs for basic CRUD operations against that table. For a detailed list of available endpoints and how to use them, see the [Automatic REST APIs](automatic-rest-apis.md) skill.
11
+ 4. **Automatic APIs**: If you add `@table @export` to a schema type, Harper automatically sets up REST and WebSocket APIs for basic CRUD operations against that table. For a detailed list of available endpoints and how to use them, see the [Automatic REST APIs](automatic-apis.md) skill.
12
12
 
13
13
  - `GET /{TableName}`: Describes the schema itself.
14
14
  - `GET /{TableName}/`: Lists all records (supports filtering, sorting, and pagination via query parameters). See the [Querying REST APIs](querying-rest-apis.md) skill for details.
@@ -0,0 +1,49 @@
1
+ # Automatic APIs in Harper
2
+
3
+ When you define a GraphQL type with the `@table` and `@export` directives, Harper automatically generates a fully-functional REST API and WebSocket interface for that table. This allows for immediate CRUD (Create, Read, Update, Delete) operations and real-time updates without writing any additional code.
4
+
5
+ ## Enabling Automatic APIs
6
+
7
+ To enable the automatic REST and WebSocket APIs for a table, ensure your GraphQL schema includes the `@export` directive:
8
+
9
+ ```graphql
10
+ type MyTable @table @export {
11
+ id: ID @primaryKey
12
+ # ... other fields
13
+ }
14
+ ```
15
+
16
+ ## Available REST Endpoints
17
+
18
+ The following endpoints are automatically created for a table named `TableName` (Note: Paths are **case-sensitive**, so `GET /TableName/` is valid while `GET /tablename/` is not):
19
+
20
+ - **Describe Schema**: `GET /{TableName}`
21
+ Returns the schema definition and metadata for the table.
22
+ - **List Records**: `GET /{TableName}/`
23
+ Lists all records in the table. This endpoint supports advanced filtering, sorting, and pagination. For more details, see the [Querying REST APIs](querying-rest-apis.md) skill.
24
+ - **Get Single Record**: `GET /{TableName}/{id}`
25
+ Retrieves a single record by its primary key (`id`).
26
+ - **Create Record**: `POST /{TableName}/`
27
+ Creates a new record. The request body should be a JSON object containing the record data.
28
+ - **Update Record (Full)**: `PUT /{TableName}/{id}`
29
+ Replaces the entire record at the specified `id` with the provided JSON data.
30
+ - **Update Record (Partial)**: `PATCH /{TableName}/{id}`
31
+ Updates only the specified fields of the record at the given `id`.
32
+ - **Delete All/Filtered Records**: `DELETE /{TableName}/`
33
+ Deletes all records in the table, or a subset of records if filtering parameters are provided.
34
+ - **Delete Single Record**: `DELETE /{TableName}/{id}`
35
+ Deletes the record with the specified `id`.
36
+
37
+ ## Automatic WebSockets
38
+
39
+ In addition to REST endpoints, Harper also stands up WebSocket interfaces for exported tables. When you connect to the table's endpoint via WebSocket, you will automatically receive events whenever updates are made to that table.
40
+
41
+ - **WebSocket Endpoint**: `ws://your-harper-instance/{TableName}`
42
+
43
+ This is the easiest way to add real-time capabilities to your application. For more complex real-time needs, see the [Real-time Applications](real-time-apps.md) skill.
44
+
45
+ ## Filtering and Querying
46
+
47
+ The `GET /{TableName}/` and `DELETE /{TableName}/` endpoints can be filtered using query parameters. While basic equality filters are straightforward, Harper supports a rich set of operators, sorting, and pagination.
48
+
49
+ For a comprehensive guide on advanced querying, see the [Querying REST APIs](querying-rest-apis.md) skill.
@@ -1,8 +1,8 @@
1
- # Checking Authentication and Sessions in this app (HarperDB Resources)
1
+ # Checking Authentication and Sessions in this app (Harper Resources)
2
2
 
3
- This project uses HarperDB Resource classes with cookie-backed sessions to enforce authentication and authorization. Below are the concrete patterns used across resources like `resources/me.ts`, `resources/signIn.ts`, `resources/signOut.ts`, and protected endpoints such as `resources/downloadAlbumArtwork.ts`.
3
+ This project uses Harper Resource classes with cookie-backed sessions to enforce authentication and authorization. Below are the concrete patterns used across resources like `resources/me.ts`, `resources/signIn.ts`, `resources/signOut.ts`, and protected endpoints such as `resources/downloadAlbumArtwork.ts`.
4
4
 
5
- Important: To actually enforce sessions (even on localhost), HarperDB must not auto-authorize the local loopback as the superuser. Ensure the following in your HarperDB config (see `~/hdb/harperdb-config.yaml`):
5
+ Important: To actually enforce sessions (even on localhost), Harper must not auto-authorize the local loopback as the superuser. Ensure the following in your Harper config (see `~/hdb/harperdb-config.yaml`):
6
6
 
7
7
  ```yaml
8
8
  authentication:
@@ -174,7 +174,7 @@ export function ensureSuperUser(user: User | undefined) {
174
174
 
175
175
  ## Client considerations
176
176
 
177
- - Sessions are cookie-based; the server handles setting and reading the cookie via HarperDB. If you make cross-origin requests, ensure the appropriate `credentials` mode and CORS settings.
177
+ - Sessions are cookie-based; the server handles setting and reading the cookie via Harper. If you make cross-origin requests, ensure the appropriate `credentials` mode and CORS settings.
178
178
  - If developing locally, double-check the server config still has `authentication.authorizeLocal: false` to avoid accidental superuser bypass.
179
179
 
180
180
  ## Quick checklist
@@ -183,4 +183,4 @@ export function ensureSuperUser(user: User | undefined) {
183
183
  - [ ] Sign-in uses `context.login` and handles 400/403 correctly.
184
184
  - [ ] Protected routes call `ensureSuperUser(this.getCurrentUser())` (or another role check) before doing work.
185
185
  - [ ] Sign-out verifies a session and deletes it.
186
- - [ ] `authentication.authorizeLocal` is `false` and `enableSessions` is `true` in HarperDB config.
186
+ - [ ] `authentication.authorizeLocal` is `false` and `enableSessions` is `true` in Harper config.
@@ -1,8 +1,8 @@
1
- # Custom Resources in HarperDB
1
+ # Custom Resources in Harper
2
2
 
3
3
  Custom Resources allow you to define your own REST endpoints with custom logic by writing JavaScript or TypeScript code. This is useful when the automatic CRUD operations provided by `@table @export` are not enough.
4
4
 
5
- HarperDB supports [TypeScript Type Stripping](typescript-type-stripping.md), allowing you to use TypeScript directly without additional build tools on supported Node.js versions.
5
+ Harper supports [TypeScript Type Stripping](typescript-type-stripping.md), allowing you to use TypeScript directly without additional build tools on supported Node.js versions.
6
6
 
7
7
  ## Defining a Custom Resource
8
8
 
@@ -21,7 +21,7 @@ interface GreetingRecord {
21
21
  }
22
22
 
23
23
  export class Greeting extends Resource<GreetingRecord> {
24
- // Set to false if you want HarperDB to manage the instance lifecycle
24
+ // Set to false if you want Harper to manage the instance lifecycle
25
25
  static loadAsInstance = false;
26
26
 
27
27
  async get(target?: RequestTargetOrId): Promise<GreetingRecord> {
@@ -79,4 +79,4 @@ Once defined and configured, your resource will be available at a REST endpoint
79
79
 
80
80
  ### Case Sensitivity
81
81
 
82
- Paths in HarperDB are **case-sensitive**. A resource class named `MyResource` will be accessible only at `/MyResource/`, not `/myresource/`.
82
+ Paths in Harper are **case-sensitive**. A resource class named `MyResource` will be accessible only at `/MyResource/`, not `/myresource/`.
@@ -1,6 +1,6 @@
1
- # Defining Relationships in HarperDB
1
+ # Defining Relationships in Harper
2
2
 
3
- HarperDB allows you to define relationships between tables using the `@relationship` directive in your GraphQL schema. This enables powerful features like automatic joins when querying through REST APIs.
3
+ Harper allows you to define relationships between tables using the `@relationship` directive in your GraphQL schema. This enables powerful features like automatic joins when querying through REST APIs.
4
4
 
5
5
  ## The `@relationship` Directive
6
6
 
@@ -67,5 +67,5 @@ This returns authors with their names and a list of their books (only the titles
67
67
  ## Benefits of `@relationship`
68
68
 
69
69
  - **Simplified Queries**: No need for complex manual joins in your code.
70
- - **Efficient Data Fetching**: HarperDB optimizes relationship lookups.
70
+ - **Efficient Data Fetching**: Harper optimizes relationship lookups.
71
71
  - **Improved API Discoverability**: Related data structures are clearly defined in your schema.
@@ -1,6 +1,6 @@
1
- # Extending Table Resources in HarperDB
1
+ # Extending Table Resources in Harper
2
2
 
3
- In HarperDB, when you define a table in GraphQL and export it, you can extend the automatically generated resource class to add custom logic, validation, or hooks to standard CRUD operations.
3
+ In Harper, when you define a table in GraphQL and export it, you can extend the automatically generated resource class to add custom logic, validation, or hooks to standard CRUD operations.
4
4
 
5
5
  ## How to Extend a Table Resource
6
6
 
@@ -53,7 +53,7 @@ export class ExamplePeople extends tables.ExamplePeople<ExamplePerson> {
53
53
 
54
54
  ## Important Note
55
55
 
56
- When you extend a table resource, HarperDB uses your custom class for all REST API interactions with that table. Make sure to call `super[method]` if you still want the default behavior to occur after your custom logic.
56
+ When you extend a table resource, Harper uses your custom class for all REST API interactions with that table. Make sure to call `super[method]` if you still want the default behavior to occur after your custom logic.
57
57
 
58
58
  Extended tables do not need to be `@export`ed in their schema .graphql.
59
59
 
@@ -1,6 +1,6 @@
1
- # Handling Binary Data in HarperDB
1
+ # Handling Binary Data in Harper
2
2
 
3
- When working with binary data (such as images or audio files) in HarperDB, you often receive this data as base64-encoded strings through JSON REST APIs. To store this data efficiently in a `Blob` field, you should convert it to a `Buffer`.
3
+ When working with binary data (such as images or audio files) in Harper, you often receive this data as base64-encoded strings through JSON REST APIs. To store this data efficiently in a `Blob` field, you should convert it to a `Buffer`.
4
4
 
5
5
  ## Storing Base64 Strings as Buffers
6
6
 
@@ -63,5 +63,5 @@ export class TrackResource extends Resource {
63
63
  ## Why Use Blobs?
64
64
 
65
65
  - **Efficiency**: `Blob` fields are optimized for storing binary data. Buffers are the standard way to handle binary data in Node.js.
66
- - **Compatibility**: Many HarperDB features and external libraries expect binary data to be in `Buffer` or `Uint8Array` format.
66
+ - **Compatibility**: Many Harper features and external libraries expect binary data to be in `Buffer` or `Uint8Array` format.
67
67
  - **Storage**: Storing data as binary is more compact than storing it as a base64-encoded string.
@@ -1,10 +1,10 @@
1
- # Programmatic Requests with HarperDB Tables
1
+ # Programmatic Requests with Harper Tables
2
2
 
3
- In HarperDB, you can interact with your database tables programmatically using the global `tables` object. Each table defined in your schema is available as a property on this object.
3
+ In Harper, you can interact with your database tables programmatically using the global `tables` object. Each table defined in your schema is available as a property on this object.
4
4
 
5
5
  ## Basic Usage
6
6
 
7
- The `tables` object provides a direct way to perform CRUD operations from within your HarperDB resources or scripts.
7
+ The `tables` object provides a direct way to perform CRUD operations from within your Harper resources or scripts.
8
8
 
9
9
  ```typescript
10
10
  const track = await tables.ExamplePeople.get(id) as ExamplePerson;
@@ -1,6 +1,6 @@
1
- # Querying through REST APIs in HarperDB
1
+ # Querying through REST APIs in Harper
2
2
 
3
- HarperDB's automatic REST APIs support powerful querying capabilities directly through URL query parameters. This allows you to filter, sort, paginate, and join data without writing complex queries.
3
+ Harper's automatic REST APIs support powerful querying capabilities directly through URL query parameters. This allows you to filter, sort, paginate, and join data without writing complex queries.
4
4
 
5
5
  ## Basic Filtering
6
6
 
@@ -1,10 +1,14 @@
1
- # Real-time Applications in HarperDB
1
+ # Real-time Applications in Harper
2
2
 
3
- HarperDB provides built-in support for real-time data synchronization using WebSockets and a Pub/Sub mechanism. This allows clients to receive immediate updates when data changes in the database.
3
+ Harper provides built-in support for real-time data synchronization using WebSockets and a Pub/Sub mechanism. This allows clients to receive immediate updates when data changes in the database.
4
+
5
+ ## Automatic WebSockets
6
+
7
+ For many use cases, the [Automatic APIs](automatic-apis.md) provided by Harper are more than enough. When you `@export` a table, Harper automatically provides a WebSocket endpoint that publishes events whenever data in that table is updated.
4
8
 
5
9
  ## Implementing a WebSocket Resource
6
10
 
7
- To handle WebSocket connections, implement the `connect` method in your custom resource class.
11
+ Customizing resources by implementing a `connect` method is only necessary when you want to come up with a more specific back-and-forth or custom message handling. To handle WebSocket connections, implement the `connect` method in your custom resource class.
8
12
 
9
13
  ### Example: `resources/exampleSocket.ts`
10
14
 
@@ -68,4 +72,4 @@ socket.send(JSON.stringify({ type: 'ping' }));
68
72
 
69
73
  - **Automatic Table Subscriptions**: Easily stream changes from any database table.
70
74
  - **Bi-directional Communication**: Send and receive messages in real-time.
71
- - **Scalable Pub/Sub**: HarperDB handles the efficient distribution of messages to subscribers.
75
+ - **Scalable Pub/Sub**: Harper handles the efficient distribution of messages to subscribers.
@@ -1,16 +1,16 @@
1
1
  # TypeScript Type Stripping
2
2
 
3
- HarperDB supports using TypeScript directly without any additional build tools (like `tsc` or `esbuild`) by leveraging Node.js's native Type Stripping capability. This allows you to write `.ts` files for your Custom Resources and have them run directly in HarperDB.
3
+ Harper supports using TypeScript directly without any additional build tools (like `tsc` or `esbuild`) by leveraging Node.js's native Type Stripping capability. This allows you to write `.ts` files for your Custom Resources and have them run directly in Harper.
4
4
 
5
5
  ## Requirements
6
6
 
7
7
  - **Node.js Version**: You must be running a version of Node.js that supports type stripping (Node.js v22.6.0 or higher).
8
- - **No Experimental Flags**: When running on supported Node.js versions, HarperDB can automatically handle type stripping for your resource files.
8
+ - **No Experimental Flags**: When running on supported Node.js versions, Harper can automatically handle type stripping for your resource files.
9
9
 
10
10
  ## Benefits
11
11
 
12
12
  - **Faster Development**: No need to wait for a build step or manage complex build pipelines.
13
- - **Simplified Tooling**: You don't need to install or configure `ts-node`, `tsx`, or other TypeScript execution engines for your HarperDB resources.
13
+ - **Simplified Tooling**: You don't need to install or configure `ts-node`, `tsx`, or other TypeScript execution engines for your Harper resources.
14
14
  - **Native Performance**: Leverages Node.js's built-in support for stripping types, which is highly efficient.
15
15
 
16
16
  ## Usage
@@ -44,4 +44,4 @@ jsResource:
44
44
  files: 'resources/*.ts'
45
45
  ```
46
46
 
47
- When HarperDB starts, it will detect the `.ts` files and, if running on a compatible Node.js version, will execute them using type stripping.
47
+ When Harper starts, it will detect the `.ts` files and, if running on a compatible Node.js version, will execute them using type stripping.