create-harper 1.2.1 → 1.3.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.
Files changed (90) hide show
  1. package/lib/install.js +5 -0
  2. package/package.json +1 -1
  3. package/template-react/README.md +1 -1
  4. package/template-react/package.json +2 -0
  5. package/template-react/resources/README.md +3 -3
  6. package/template-react/schemas/README.md +2 -2
  7. package/template-react-ts/README.md +1 -1
  8. package/template-react-ts/package.json +2 -0
  9. package/template-react-ts/resources/README.md +3 -3
  10. package/template-react-ts/schemas/README.md +2 -2
  11. package/template-vanilla/README.md +1 -1
  12. package/template-vanilla/package.json +2 -0
  13. package/template-vanilla/resources/README.md +3 -3
  14. package/template-vanilla/schemas/README.md +2 -2
  15. package/template-vanilla-ts/README.md +1 -1
  16. package/template-vanilla-ts/package.json +2 -0
  17. package/template-vanilla-ts/resources/README.md +3 -3
  18. package/template-vanilla-ts/schemas/README.md +2 -2
  19. package/template-react/AGENTS.md +0 -22
  20. package/template-react/skills/adding-tables-with-schemas.md +0 -34
  21. package/template-react/skills/automatic-apis.md +0 -53
  22. package/template-react/skills/automatic-rest-apis.md +0 -41
  23. package/template-react/skills/caching.md +0 -113
  24. package/template-react/skills/checking-authentication.md +0 -281
  25. package/template-react/skills/custom-resources.md +0 -86
  26. package/template-react/skills/defining-relationships.md +0 -71
  27. package/template-react/skills/deploying-to-harper-fabric.md +0 -20
  28. package/template-react/skills/extending-tables.md +0 -70
  29. package/template-react/skills/handling-binary-data.md +0 -67
  30. package/template-react/skills/programmatic-table-requests.md +0 -185
  31. package/template-react/skills/querying-rest-apis.md +0 -69
  32. package/template-react/skills/real-time-apps.md +0 -75
  33. package/template-react/skills/serving-web-content.md +0 -82
  34. package/template-react/skills/typescript-type-stripping.md +0 -47
  35. package/template-react/skills/using-blob-datatype.md +0 -131
  36. package/template-react/skills/vector-indexing.md +0 -215
  37. package/template-react-ts/AGENTS.md +0 -22
  38. package/template-react-ts/skills/adding-tables-with-schemas.md +0 -34
  39. package/template-react-ts/skills/automatic-apis.md +0 -53
  40. package/template-react-ts/skills/automatic-rest-apis.md +0 -41
  41. package/template-react-ts/skills/caching.md +0 -113
  42. package/template-react-ts/skills/checking-authentication.md +0 -281
  43. package/template-react-ts/skills/custom-resources.md +0 -86
  44. package/template-react-ts/skills/defining-relationships.md +0 -71
  45. package/template-react-ts/skills/deploying-to-harper-fabric.md +0 -20
  46. package/template-react-ts/skills/extending-tables.md +0 -70
  47. package/template-react-ts/skills/handling-binary-data.md +0 -67
  48. package/template-react-ts/skills/programmatic-table-requests.md +0 -185
  49. package/template-react-ts/skills/querying-rest-apis.md +0 -69
  50. package/template-react-ts/skills/real-time-apps.md +0 -75
  51. package/template-react-ts/skills/serving-web-content.md +0 -82
  52. package/template-react-ts/skills/typescript-type-stripping.md +0 -47
  53. package/template-react-ts/skills/using-blob-datatype.md +0 -131
  54. package/template-react-ts/skills/vector-indexing.md +0 -215
  55. package/template-vanilla/AGENTS.md +0 -22
  56. package/template-vanilla/skills/adding-tables-with-schemas.md +0 -34
  57. package/template-vanilla/skills/automatic-apis.md +0 -53
  58. package/template-vanilla/skills/automatic-rest-apis.md +0 -41
  59. package/template-vanilla/skills/caching.md +0 -113
  60. package/template-vanilla/skills/checking-authentication.md +0 -281
  61. package/template-vanilla/skills/custom-resources.md +0 -86
  62. package/template-vanilla/skills/defining-relationships.md +0 -71
  63. package/template-vanilla/skills/deploying-to-harper-fabric.md +0 -20
  64. package/template-vanilla/skills/extending-tables.md +0 -70
  65. package/template-vanilla/skills/handling-binary-data.md +0 -67
  66. package/template-vanilla/skills/programmatic-table-requests.md +0 -185
  67. package/template-vanilla/skills/querying-rest-apis.md +0 -69
  68. package/template-vanilla/skills/real-time-apps.md +0 -75
  69. package/template-vanilla/skills/serving-web-content.md +0 -82
  70. package/template-vanilla/skills/typescript-type-stripping.md +0 -47
  71. package/template-vanilla/skills/using-blob-datatype.md +0 -131
  72. package/template-vanilla/skills/vector-indexing.md +0 -215
  73. package/template-vanilla-ts/AGENTS.md +0 -22
  74. package/template-vanilla-ts/skills/adding-tables-with-schemas.md +0 -34
  75. package/template-vanilla-ts/skills/automatic-apis.md +0 -53
  76. package/template-vanilla-ts/skills/automatic-rest-apis.md +0 -41
  77. package/template-vanilla-ts/skills/caching.md +0 -113
  78. package/template-vanilla-ts/skills/checking-authentication.md +0 -281
  79. package/template-vanilla-ts/skills/custom-resources.md +0 -86
  80. package/template-vanilla-ts/skills/defining-relationships.md +0 -71
  81. package/template-vanilla-ts/skills/deploying-to-harper-fabric.md +0 -20
  82. package/template-vanilla-ts/skills/extending-tables.md +0 -70
  83. package/template-vanilla-ts/skills/handling-binary-data.md +0 -67
  84. package/template-vanilla-ts/skills/programmatic-table-requests.md +0 -185
  85. package/template-vanilla-ts/skills/querying-rest-apis.md +0 -69
  86. package/template-vanilla-ts/skills/real-time-apps.md +0 -75
  87. package/template-vanilla-ts/skills/serving-web-content.md +0 -82
  88. package/template-vanilla-ts/skills/typescript-type-stripping.md +0 -47
  89. package/template-vanilla-ts/skills/using-blob-datatype.md +0 -131
  90. package/template-vanilla-ts/skills/vector-indexing.md +0 -215
package/lib/install.js CHANGED
@@ -20,4 +20,9 @@ export function install(root, agent) {
20
20
  stdio: 'inherit',
21
21
  cwd: root,
22
22
  });
23
+ prompts.log.step('Installing Harper skills...');
24
+ run('npx -y skills add harperfast/skills --all --yes', {
25
+ stdio: 'inherit',
26
+ cwd: root,
27
+ });
23
28
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-harper",
3
3
  "description": "Scaffold a new Harper project in JavaScript or TypeScript.",
4
- "version": "1.2.1",
4
+ "version": "1.3.0",
5
5
  "type": "module",
6
6
  "author": {
7
7
  "name": "HarperDB",
@@ -26,7 +26,7 @@ npm run dev
26
26
  2. Craft your schema by hand.
27
27
  3. Save your changes.
28
28
 
29
- These schemas are the heart of a great Harper app, specifying which tables you want and what attributes/fields they should have. Any table you `@export` stands up [REST endpoints automatically](./skills/automatic-rest-apis.md).
29
+ These schemas are the heart of a great Harper app, specifying which tables you want and what attributes/fields they should have. Any table you `@export` stands up [endpoints automatically](./.agents/skills/harper-best-practices/rules/automatic-apis.md).
30
30
 
31
31
  ### Add Custom Endpoints
32
32
 
@@ -4,6 +4,8 @@
4
4
  "type": "module",
5
5
  "repository": "github:HarperFast/create-harper",
6
6
  "scripts": {
7
+ "agent:run": "npx -y @harperfast/agent@latest",
8
+ "agent:skills:update": "npx -y skills@latest add harperfast/skills --all --yes",
7
9
  "dev": "harper run .",
8
10
  "test": "echo 'No tests implemented yet'",
9
11
  "lint": "echo 'No lint implemented yet'",
@@ -1,11 +1,11 @@
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-apis.md).
3
+ The [schemas you define in .GraphQL files](../.agents/skills/harper-best-practices/rules/adding-tables-with-schemas.md) will [automatically stand-up REST APIs](../.agents/skills/harper-best-practices/rules/automatic-apis.md).
4
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.
5
+ But you can [extend your tables with custom logic](../.agents/skills/harper-best-practices/rules/extending-tables.md) and [create your own resources](../.agents/skills/harper-best-practices/rules/custom-resources.md) in this directory.
6
6
 
7
7
  ## Want to read more?
8
8
 
9
9
  Check out the rest of the "skills" documentation!
10
10
 
11
- [AGENTS.md](../AGENTS.md)
11
+ [Harper Best Practices Skill](../.agents/skills/harper-best-practices/SKILL.md)
@@ -2,10 +2,10 @@
2
2
 
3
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
4
 
5
- Take a look at the [Adding Tables with Schemas](../skills/adding-tables-with-schemas.md) to learn more!
5
+ Take a look at the [Adding Tables with Schemas](../.agents/skills/harper-best-practices/rules/adding-tables-with-schemas.md) to learn more!
6
6
 
7
7
  ## Want to read more?
8
8
 
9
9
  Check out the rest of the "skills" documentation!
10
10
 
11
- [AGENTS.md](../AGENTS.md)
11
+ [Harper Best Practices Skill](../.agents/skills/harper-best-practices/SKILL.md)
@@ -28,7 +28,7 @@ TypeScript is supported at runtime in Node.js through [type stripping](https://n
28
28
  2. Craft your schema by hand.
29
29
  3. Save your changes.
30
30
 
31
- These schemas are the heart of a great Harper app, specifying which tables you want and what attributes/fields they should have. Any table you `@export` stands up [REST endpoints automatically](./skills/automatic-rest-apis.md).
31
+ These schemas are the heart of a great Harper app, specifying which tables you want and what attributes/fields they should have. Any table you `@export` stands up [endpoints automatically](./.agents/skills/harper-best-practices/rules/automatic-apis.md).
32
32
 
33
33
  ### Add Custom Endpoints
34
34
 
@@ -4,6 +4,8 @@
4
4
  "type": "module",
5
5
  "repository": "github:HarperFast/create-harper",
6
6
  "scripts": {
7
+ "agent:run": "npx -y @harperfast/agent@latest",
8
+ "agent:skills:update": "npx -y skills@latest add harperfast/skills --all --yes",
7
9
  "dev": "harper run .",
8
10
  "test": "echo 'No tests implemented yet'",
9
11
  "lint": "echo 'No lint implemented yet'",
@@ -1,11 +1,11 @@
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-apis.md).
3
+ The [schemas you define in .GraphQL files](../.agents/skills/harper-best-practices/rules/adding-tables-with-schemas.md) will [automatically stand-up REST APIs](../.agents/skills/harper-best-practices/rules/automatic-apis.md).
4
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.
5
+ But you can [extend your tables with custom logic](../.agents/skills/harper-best-practices/rules/extending-tables.md) and [create your own resources](../.agents/skills/harper-best-practices/rules/custom-resources.md) in this directory.
6
6
 
7
7
  ## Want to read more?
8
8
 
9
9
  Check out the rest of the "skills" documentation!
10
10
 
11
- [AGENTS.md](../AGENTS.md)
11
+ [Harper Best Practices Skill](../.agents/skills/harper-best-practices/SKILL.md)
@@ -2,10 +2,10 @@
2
2
 
3
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
4
 
5
- Take a look at the [Adding Tables with Schemas](../skills/adding-tables-with-schemas.md) to learn more!
5
+ Take a look at the [Adding Tables with Schemas](../.agents/skills/harper-best-practices/rules/adding-tables-with-schemas.md) to learn more!
6
6
 
7
7
  ## Want to read more?
8
8
 
9
9
  Check out the rest of the "skills" documentation!
10
10
 
11
- [AGENTS.md](../AGENTS.md)
11
+ [Harper Best Practices Skill](../.agents/skills/harper-best-practices/SKILL.md)
@@ -26,7 +26,7 @@ npm run dev
26
26
  2. Craft your schema by hand.
27
27
  3. Save your changes.
28
28
 
29
- These schemas are the heart of a great Harper app, specifying which tables you want and what attributes/fields they should have. Any table you `@export` stands up [REST endpoints automatically](./skills/automatic-rest-apis.md).
29
+ These schemas are the heart of a great Harper app, specifying which tables you want and what attributes/fields they should have. Any table you `@export` stands up [endpoints automatically](./.agents/skills/harper-best-practices/rules/automatic-apis.md).
30
30
 
31
31
  ### Add Custom Endpoints
32
32
 
@@ -4,6 +4,8 @@
4
4
  "type": "module",
5
5
  "repository": "github:HarperFast/create-harper",
6
6
  "scripts": {
7
+ "agent:run": "npx -y @harperfast/agent@latest",
8
+ "agent:skills:update": "npx -y skills@latest add harperfast/skills --all --yes",
7
9
  "start": "harperdb run .",
8
10
  "dev": "harperdb dev .",
9
11
  "deploy": "dotenv -- npm run deploy:component",
@@ -1,11 +1,11 @@
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-apis.md).
3
+ The [schemas you define in .GraphQL files](../.agents/skills/harper-best-practices/rules/adding-tables-with-schemas.md) will [automatically stand-up REST APIs](../.agents/skills/harper-best-practices/rules/automatic-apis.md).
4
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.
5
+ But you can [extend your tables with custom logic](../.agents/skills/harper-best-practices/rules/extending-tables.md) and [create your own resources](../.agents/skills/harper-best-practices/rules/custom-resources.md) in this directory.
6
6
 
7
7
  ## Want to read more?
8
8
 
9
9
  Check out the rest of the "skills" documentation!
10
10
 
11
- [AGENTS.md](../AGENTS.md)
11
+ [Harper Best Practices Skill](../.agents/skills/harper-best-practices/SKILL.md)
@@ -2,10 +2,10 @@
2
2
 
3
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
4
 
5
- Take a look at the [Adding Tables with Schemas](../skills/adding-tables-with-schemas.md) to learn more!
5
+ Take a look at the [Adding Tables with Schemas](../.agents/skills/harper-best-practices/rules/adding-tables-with-schemas.md) to learn more!
6
6
 
7
7
  ## Want to read more?
8
8
 
9
9
  Check out the rest of the "skills" documentation!
10
10
 
11
- [AGENTS.md](../AGENTS.md)
11
+ [Harper Best Practices Skill](../.agents/skills/harper-best-practices/SKILL.md)
@@ -28,7 +28,7 @@ TypeScript is supported at runtime in Node.js through [type stripping](https://n
28
28
  2. Craft your schema by hand.
29
29
  3. Save your changes.
30
30
 
31
- These schemas are the heart of a great Harper app, specifying which tables you want and what attributes/fields they should have. Any table you `@export` stands up [REST endpoints automatically](./skills/automatic-rest-apis.md).
31
+ These schemas are the heart of a great Harper app, specifying which tables you want and what attributes/fields they should have. Any table you `@export` stands up [endpoints automatically](./.agents/skills/harper-best-practices/rules/automatic-apis.md).
32
32
 
33
33
  ### Add Custom Endpoints
34
34
 
@@ -4,6 +4,8 @@
4
4
  "type": "module",
5
5
  "repository": "github:HarperFast/create-harper",
6
6
  "scripts": {
7
+ "agent:run": "npx -y @harperfast/agent@latest",
8
+ "agent:skills:update": "npx -y skills@latest add harperfast/skills --all --yes",
7
9
  "start": "harperdb run .",
8
10
  "dev": "harperdb dev .",
9
11
  "deploy": "dotenv -- npm run deploy:component",
@@ -1,11 +1,11 @@
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-apis.md).
3
+ The [schemas you define in .GraphQL files](../.agents/skills/harper-best-practices/rules/adding-tables-with-schemas.md) will [automatically stand-up REST APIs](../.agents/skills/harper-best-practices/rules/automatic-apis.md).
4
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.
5
+ But you can [extend your tables with custom logic](../.agents/skills/harper-best-practices/rules/extending-tables.md) and [create your own resources](../.agents/skills/harper-best-practices/rules/custom-resources.md) in this directory.
6
6
 
7
7
  ## Want to read more?
8
8
 
9
9
  Check out the rest of the "skills" documentation!
10
10
 
11
- [AGENTS.md](../AGENTS.md)
11
+ [Harper Best Practices Skill](../.agents/skills/harper-best-practices/SKILL.md)
@@ -2,10 +2,10 @@
2
2
 
3
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
4
 
5
- Take a look at the [Adding Tables with Schemas](../skills/adding-tables-with-schemas.md) to learn more!
5
+ Take a look at the [Adding Tables with Schemas](../.agents/skills/harper-best-practices/rules/adding-tables-with-schemas.md) to learn more!
6
6
 
7
7
  ## Want to read more?
8
8
 
9
9
  Check out the rest of the "skills" documentation!
10
10
 
11
- [AGENTS.md](../AGENTS.md)
11
+ [Harper Best Practices Skill](../.agents/skills/harper-best-practices/SKILL.md)
@@ -1,22 +0,0 @@
1
- # Harper Agent Skills
2
-
3
- This repository contains "skills" that guide AI agents in developing Harper applications.
4
-
5
- ## Available Skills
6
-
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 APIs](skills/automatic-apis.md): Details on the CRUD endpoints automatically generated for exported tables with REST and WebSockets.
9
- - [Caching](skills/caching.md): How caching is defined and implemented in Harper applications.
10
- - [Checking Authentication](skills/checking-authentication.md): How to use sessions to verify user identity and roles.
11
- - [Custom Resources](skills/custom-resources.md): How to define custom REST endpoints using JavaScript or TypeScript (Note: Paths are case-sensitive).
12
- - [Defining Relationships](skills/defining-relationships.md): Using the `@relationship` directive to link tables.
13
- - [Deploying to Harper Fabric](skills/deploying-to-harper-fabric.md): Globally scaling your Harper application with our generous Free tier and beyond.
14
- - [Extending Table Resources](skills/extending-tables.md): Adding custom logic to automatically generated table resources.
15
- - [Handling Binary Data](skills/handling-binary-data.md): How to store and serve binary data like images or MP3s.
16
- - [Programmatic Table Requests](skills/programmatic-table-requests.md): How to use filters, operators, sorting, and pagination in programmatic table requests.
17
- - [Querying REST APIs](skills/querying-rest-apis.md): How to use filters, operators, sorting, and pagination in REST requests.
18
- - [Real-time Applications](skills/real-time-apps.md): Implementing WebSockets and Pub/Sub for live data updates.
19
- - [Serving Web Content](skills/serving-web-content): Two ways to serve web content from a Harper application.
20
- - [TypeScript Type Stripping](skills/typescript-type-stripping.md): Using TypeScript directly without build tools via Node.js Type Stripping.
21
- - [Using Blobs](skills/using-blob-datatype.md): How to store and retrieve large data in HarperDB.
22
- - [Vector Indexing](skills/vector-indexing.md): How to define and use vector indexes for efficient similarity search.
@@ -1,34 +0,0 @@
1
- # Adding Tables to Harper
2
-
3
- To add tables to a Harper database, follow these guidelines:
4
-
5
- 1. **Dedicated Schema Files**: Prefer having a dedicated schema `.graphql` file for each table. Check the `config.yaml` file under `graphqlSchema.files` to see how it's configured. It typically accepts wildcards (e.g., `schemas/*.graphql`), but may be configured to point at a single file.
6
-
7
- 2. **Directives**: All available directives for defining your schema are defined in `node_modules/harperdb/schema.graphql`. Common directives include `@table`, `@export`, `@primaryKey`, `@indexed`, and `@relationship`.
8
-
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
-
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
-
13
- - `GET /{TableName}`: Describes the schema itself.
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.
15
- - `GET /{TableName}/{id}`: Retrieves a single record by its ID.
16
- - `POST /{TableName}/`: Creates a new record.
17
- - `PUT /{TableName}/{id}`: Updates an existing record.
18
- - `PATCH /{TableName}/{id}`: Performs a partial update on a record.
19
- - `DELETE /{TableName}/`: Deletes all records or filtered records.
20
- - `DELETE /{TableName}/{id}`: Deletes a single record by its ID.
21
-
22
- ### Example
23
-
24
- In `schemas/ExamplePerson.graphql`:
25
-
26
- ```graphql
27
- type ExamplePerson @table @export {
28
- id: ID @primaryKey
29
- name: String
30
- tag: String @indexed
31
- }
32
- ```
33
-
34
- Tip: if you are going to [extend the table](./extending-tables.md) in your resources, then do not `@export` the table from the schema.
@@ -1,53 +0,0 @@
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.
50
-
51
- ## Customizing Resources
52
-
53
- If the automatic APIs don't behave how you need, then you can look to [customize the resources](./custom-resources.md).
@@ -1,41 +0,0 @@
1
- # Automatic REST APIs in HarperDB
2
-
3
- When you define a GraphQL type with the `@table` and `@export` directives, HarperDB automatically generates a fully-functional REST API for that table. This allows for immediate CRUD (Create, Read, Update, Delete) operations without writing any additional code.
4
-
5
- ## Enabling REST APIs
6
-
7
- To enable the automatic REST API 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 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
- ## Filtering and Querying
38
-
39
- The `GET /{TableName}/` and `DELETE /{TableName}/` endpoints can be filtered using query parameters. While basic equality filters are straightforward, HarperDB supports a rich set of operators, sorting, and pagination.
40
-
41
- For a comprehensive guide on advanced querying, see the [Querying REST APIs](querying-rest-apis.md) skill.
@@ -1,113 +0,0 @@
1
- # Harper Caching
2
-
3
- Harper includes integrated support for **caching data from external sources**, enabling high-performance, low-latency cache storage that is fully queryable and interoperable with your applications. With built-in caching capabilities and distributed responsiveness, Harper makes an ideal **data caching server** for both edge and centralized use cases.
4
-
5
- ---
6
-
7
- ## What is Harper Caching?
8
-
9
- Harper caching lets you store **cached content** in standard tables, enabling you to:
10
-
11
- - Expose cached entries as **queryable structured data** (e.g., JSON or CSV)
12
- - Serve data to clients with **flexible formats and custom querying**
13
- - Manage cache control with **timestamps and ETags** for downstream caching layers
14
- - Implement **active or passive caching** patterns depending on your source and invalidation strategy
15
-
16
- ---
17
-
18
- ## Configuring a Cache Table
19
-
20
- Define a cache table in your `schema.graphql`:
21
-
22
- ```graphql
23
- type MyCache @table(expiration: 3600) @export {
24
- id: ID @primaryKey
25
- }
26
- ```
27
-
28
- - `expiration` is defined in seconds
29
- - Expired records are refreshed on access
30
- - Evicted records are removed after expiration
31
-
32
- ---
33
-
34
- ## Connecting an External Source
35
-
36
- Create a resource:
37
-
38
- ```js
39
- import { Resource } from 'harperdb';
40
-
41
- export class ThirdPartyAPI extends Resource {
42
- async get() {
43
- const id = this.getId();
44
- const response = await fetch(`https://api.example.com/items/${id}`);
45
- if (!response.ok) {
46
- throw new Error('Source fetch failed');
47
- }
48
- return await response.json();
49
- }
50
- }
51
- ```
52
-
53
- Attach it to your table:
54
-
55
- ```js
56
- import { tables } from 'harperdb';
57
- import { ThirdPartyAPI } from './ThirdPartyAPI.js';
58
-
59
- const { MyCache } = tables;
60
- MyCache.sourcedFrom(ThirdPartyAPI);
61
- ```
62
-
63
- ---
64
-
65
- ## Cache Behavior
66
-
67
- 1. Fresh data is returned immediately
68
- 2. Missing or stale data triggers a fetch
69
- 3. Concurrent misses are deduplicated
70
-
71
- ---
72
-
73
- ## Active Caching
74
-
75
- Use `subscribe()` to proactively update or invalidate cache entries:
76
-
77
- ```js
78
- class MyAPI extends Resource {
79
- async *subscribe() {
80
- // stream updates
81
- }
82
- }
83
- ```
84
-
85
- See [Real Time Apps](real-time-apps.md) for more details.
86
-
87
- ---
88
-
89
- ## Write-Through Caching
90
-
91
- Propagate updates upstream:
92
-
93
- ```js
94
- class ThirdPartyAPI extends Resource {
95
- async put(data) {
96
- await fetch(`https://some-api.com/${this.getId()}`, {
97
- method: 'PUT',
98
- body: JSON.stringify(data),
99
- });
100
- }
101
- }
102
- ```
103
-
104
- ---
105
-
106
- ## Summary
107
-
108
- Harper Caching allows you to:
109
-
110
- - Cache external APIs efficiently
111
- - Query cached data like native tables
112
- - Prevent cache stampedes
113
- - Build real-time or write-through caches