@harperfast/template-react-studio 1.6.2 → 1.6.3

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.
@@ -48,9 +48,9 @@ Use this skill when you need to define new data structures or modify existing on
48
48
  #### How It Works
49
49
 
50
50
  1. **Create 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.
51
- 2. **Use 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`.
51
+ 2. **Use Directives**: All available directives for defining your schema are defined in `node_modules/harper/schema.graphql`. Common directives include `@table`, `@export`, `@primaryKey`, `@indexed`, and `@relationship`.
52
52
  3. **Define Relationships**: Link tables together using the `@relationship` directive.
53
- 4. **Enable 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.
53
+ 4. **Enable 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. **Important**: REST endpoints also require `rest: true` in `config.yaml` — without it, `@export`ed tables will not respond to HTTP requests.
54
54
  5. **Consider Table Extensions**: If you are going to extend the table in your resources, then do not `@export` the table from the schema.
55
55
 
56
56
  #### Example
@@ -69,7 +69,7 @@ Harper uses GraphQL schemas to define database tables, relationships, and APIs.
69
69
 
70
70
  #### Core Harper Directives
71
71
 
72
- 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
+ Harper extends GraphQL with custom directives that define database behavior. These are typically defined in `node_modules/harper/schema.graphql`. If you don't have access to that file, here is a reference of the most important ones:
73
73
 
74
74
  ##### Table Definition
75
75
 
@@ -103,7 +103,7 @@ Create a file named `graphql.config.yml` in your project root with the following
103
103
 
104
104
  ```yaml
105
105
  schema:
106
- - 'node_modules/harperdb/schema.graphql'
106
+ - 'node_modules/harper/schema.graphql'
107
107
  - 'schema.graphql'
108
108
  - 'schemas/*.graphql'
109
109
  ```
@@ -299,7 +299,7 @@ How to define custom REST endpoints using JavaScript or TypeScript.
299
299
  #### How It Works
300
300
 
301
301
  1. **Create Resource File**: Define your logic in a JS or TS file.
302
- 2. **Define Resource Class**: Export a class extending `Resource` from `harperdb`.
302
+ 2. **Define Resource Class**: Export a class extending `Resource` from `harper`.
303
303
  3. **Implement HTTP Methods**: Add methods like `get`, `post`, `put`, `patch`, or `delete` to handle corresponding requests.
304
304
  4. **Route Nesting and Naming**: You can control the URL structure by how you export your resources:
305
305
  - **Direct Class Export**: `export class Foo extends Resource` creates endpoints at `/Foo/`. Class names are case-sensitive in the URL.
@@ -430,11 +430,11 @@ Add the following scripts and dependencies to your `package.json`:
430
430
  {
431
431
  "scripts": {
432
432
  "deploy": "dotenv -- npm run deploy:component",
433
- "deploy:component": "harperdb deploy_component . restart=rolling replicated=true"
433
+ "deploy:component": "harper deploy_component . restart=rolling replicated=true"
434
434
  },
435
435
  "devDependencies": {
436
436
  "dotenv-cli": "^11.0.0",
437
- "harperdb": "^4.7.20"
437
+ "harper": "^5.0.0"
438
438
  }
439
439
  }
440
440
  ```
@@ -446,7 +446,7 @@ The `deploy` script is separated from `deploy:component` to ensure environment v
446
446
  - `deploy`: Uses `dotenv-cli` to load environment variables (like `CLI_TARGET`, `CLI_TARGET_USERNAME`, and `CLI_TARGET_PASSWORD`) before executing the next command.
447
447
  - `deploy:component`: The actual command that performs the deployment.
448
448
 
449
- By using `dotenv -- npm run deploy:component`, the environment variables are correctly set in the shell session before `harperdb deploy_component` is called, allowing it to authenticate with your cluster.
449
+ By using `dotenv -- npm run deploy:component`, the environment variables are correctly set in the shell session before `harper deploy_component` is called, allowing it to authenticate with your cluster.
450
450
 
451
451
  #### 2. Configure GitHub Actions
452
452
 
@@ -499,7 +499,7 @@ Two ways to serve web content from a Harper application.
499
499
 
500
500
  #### Methods
501
501
 
502
- 1. **Static Serving**: Serve HTML, CSS, and JS files directly. If using the Vite plugin for development, ensure Harper is running (e.g., `harperdb run .`) to allow for Hot Module Replacement (HMR).
502
+ 1. **Static Serving**: Serve HTML, CSS, and JS files directly. If using the Vite plugin for development, ensure Harper is running (e.g., `harper run .`) to allow for Hot Module Replacement (HMR).
503
503
  2. **Dynamic Rendering**: Use custom resources to render content on the fly.
504
504
 
505
505
  ### 4.5 Logging Best Practices
@@ -14,9 +14,9 @@ Use this skill when you need to define new data structures or modify existing on
14
14
  ## How It Works
15
15
 
16
16
  1. **Create 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.
17
- 2. **Use 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`.
17
+ 2. **Use Directives**: All available directives for defining your schema are defined in `node_modules/harper/schema.graphql`. Common directives include `@table`, `@export`, `@primaryKey`, `@indexed`, and `@relationship`.
18
18
  3. **Define Relationships**: Link tables together using the `@relationship` directive. For more details, see the [Defining Relationships](defining-relationships.md) skill.
19
- 4. **Enable 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.
19
+ 4. **Enable 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. **Important**: REST endpoints also require `rest: true` in `config.yaml` — without it, `@export`ed tables will not respond to HTTP requests. For a detailed list of available endpoints and how to use them, see the [Automatic REST APIs](automatic-apis.md) skill.
20
20
  - `GET /{TableName}`: Describes the schema itself.
21
21
  - `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.
22
22
  - `GET /{TableName}/{id}`: Retrieves a single record by its ID.
@@ -13,11 +13,16 @@ Use this skill when you want to interact with Harper tables via REST or WebSocke
13
13
 
14
14
  ## How It Works
15
15
 
16
- 1. **Enable Automatic APIs**: Ensure your GraphQL schema includes the `@export` directive for the table.
17
- 2. **Access REST Endpoints**: Use the standard endpoints for your table (Note: Paths are case-sensitive).
18
- 3. **Use Automatic WebSockets**: Connect to `wss://your-harper-instance/{TableName}` to receive events whenever updates are made to that table. This is the easiest way to add real-time capabilities. (Use `ws://` for local development without SSL). For more complex needs, see [Real-time Apps](real-time-apps.md).
19
- 4. **Apply Filtering and Querying**: Use query parameters with `GET /{TableName}/` and `DELETE /{TableName}/`. See the [Querying REST APIs](querying-rest-apis.md) skill for advanced details.
20
- 5. **Customize if Needed**: If the automatic APIs don't meet your requirements, [customize the resources](./custom-resources.md).
16
+ 1. **Enable REST in `config.yaml`**: REST endpoints are **not active by default**. You must explicitly enable them:
17
+ ```yaml
18
+ rest: true
19
+ ```
20
+ Without this, `@export`ed tables will not respond to HTTP requests.
21
+ 2. **Enable Automatic APIs**: Ensure your GraphQL schema includes the `@export` directive for the table.
22
+ 3. **Access REST Endpoints**: Use the standard endpoints for your table (Note: Paths are case-sensitive).
23
+ 4. **Use Automatic WebSockets**: Connect to `wss://your-harper-instance/{TableName}` to receive events whenever updates are made to that table. This is the easiest way to add real-time capabilities. (Use `ws://` for local development without SSL). For more complex needs, see [Real-time Apps](real-time-apps.md).
24
+ 5. **Apply Filtering and Querying**: Use query parameters with `GET /{TableName}/` and `DELETE /{TableName}/`. See the [Querying REST APIs](querying-rest-apis.md) skill for advanced details.
25
+ 6. **Customize if Needed**: If the automatic APIs don't meet your requirements, [customize the resources](./custom-resources.md).
21
26
 
22
27
  ## Examples
23
28
 
@@ -32,7 +32,7 @@ type MyCache @table(expiration: 3600) @export {
32
32
  ### Resource Implementation
33
33
 
34
34
  ```js
35
- import { Resource, tables } from 'harperdb';
35
+ import { Resource, tables } from 'harper';
36
36
 
37
37
  export class ThirdPartyAPI extends Resource {
38
38
  async get() {
@@ -13,7 +13,7 @@ Use this skill when you need to implement sign-in/sign-out functionality, protec
13
13
 
14
14
  ## How It Works
15
15
 
16
- 1. **Configure Harper for Sessions**: Ensure `harperdb-config.yaml` has sessions enabled and local auto-authorization disabled for testing:
16
+ 1. **Configure Harper for Sessions**: Ensure `harper-config.yaml` has sessions enabled and local auto-authorization disabled for testing:
17
17
  ```yaml
18
18
  authentication:
19
19
  authorizeLocal: false
@@ -15,10 +15,10 @@ Use this skill when the automatic CRUD operations provided by `@table @export` a
15
15
 
16
16
  1. **Check if a Custom Resource is Necessary**: Verify if [Automatic APIs](./automatic-apis.md) or [Extending Tables](./extending-tables.md) can satisfy the requirement first.
17
17
  2. **Create the Resource File**: Create a `.ts` or `.js` file in the directory specified by `jsResource` in `config.yaml` (typically `resources/`).
18
- 3. **Define the Resource Class**: Export a class extending `Resource` from `harperdb`:
18
+ 3. **Define the Resource Class**: Export a class extending `Resource` from `harper`:
19
19
 
20
20
  ```typescript
21
- import { type RequestTargetOrId, Resource } from 'harperdb';
21
+ import { type RequestTargetOrId, Resource } from 'harper';
22
22
 
23
23
  export class MyResource extends Resource {
24
24
  async get(target?: RequestTargetOrId) {
@@ -34,7 +34,7 @@ Use this skill when the automatic CRUD operations provided by `@table @export` a
34
34
  - **Lowercase and Hyphens**: Use object keys to define custom paths: `export const bar = { 'foo-baz': Foo };` exposes endpoints at `/bar/foo-baz/`.
35
35
  6. **Access Tables (Optional)**: Import and use the `tables` object to interact with your data:
36
36
  ```typescript
37
- import { tables } from 'harperdb';
37
+ import { tables } from 'harper';
38
38
  // ... inside a method
39
39
  const results = await tables.MyTable.list();
40
40
  ```
@@ -35,11 +35,11 @@ Add the following scripts and dependencies to your `package.json`:
35
35
  {
36
36
  "scripts": {
37
37
  "deploy": "dotenv -- npm run deploy:component",
38
- "deploy:component": "harperdb deploy_component . restart=rolling replicated=true"
38
+ "deploy:component": "harper deploy_component . restart=rolling replicated=true"
39
39
  },
40
40
  "devDependencies": {
41
41
  "dotenv-cli": "^11.0.0",
42
- "harperdb": "^4.7.20"
42
+ "harper": "^5.0.0"
43
43
  }
44
44
  }
45
45
  ```
@@ -51,7 +51,7 @@ The `deploy` script is separated from `deploy:component` to ensure environment v
51
51
  - `deploy`: Uses `dotenv-cli` to load environment variables (like `CLI_TARGET`, `CLI_TARGET_USERNAME`, and `CLI_TARGET_PASSWORD`) before executing the next command.
52
52
  - `deploy:component`: The actual command that performs the deployment.
53
53
 
54
- By using `dotenv -- npm run deploy:component`, the environment variables are correctly set in the shell session before `harperdb deploy_component` is called, allowing it to authenticate with your cluster.
54
+ By using `dotenv -- npm run deploy:component`, the environment variables are correctly set in the shell session before `harper deploy_component` is called, allowing it to authenticate with your cluster.
55
55
 
56
56
  ### 2. Configure GitHub Actions
57
57
 
@@ -24,7 +24,7 @@ Use this skill when you need to add custom validation, side effects (like webhoo
24
24
  3. **Extend the Table Resource**: Export a class that extends `tables.YourTableName`:
25
25
 
26
26
  ```typescript
27
- import { type RequestTargetOrId, tables } from 'harperdb';
27
+ import { type RequestTargetOrId, tables } from 'harper';
28
28
 
29
29
  export class MyTable extends tables.MyTable {
30
30
  async post(target: RequestTargetOrId, record: any) {
@@ -30,6 +30,7 @@ Use this skill when you need to perform database operations (CRUD, search, subsc
30
30
  // process record
31
31
  }
32
32
  ```
33
+ See the [Query Conditions](#query-conditions) section below for the full query object reference.
33
34
  5. **Real-time Subscriptions**: Use `subscribe(query)` to listen for changes:
34
35
  ```typescript
35
36
  for await (const event of tables.MyTable.subscribe(query)) {
@@ -38,6 +39,90 @@ Use this skill when you need to perform database operations (CRUD, search, subsc
38
39
  ```
39
40
  6. **Publish Events**: Use `publish(id, message)` to trigger subscriptions without necessarily persisting data.
40
41
 
42
+ ## Query Conditions
43
+
44
+ When passing a query to `search()`, `get()`, or `subscribe()`, use a query object with a `conditions` array.
45
+
46
+ ### Condition Object Shape
47
+
48
+ | Property | Description |
49
+ |---|---|
50
+ | `attribute` | Field name, or array of field names to traverse a relationship (e.g., `['brand', 'name']`) |
51
+ | `value` | The value to compare against |
52
+ | `comparator` | One of the comparator strings below (default: `equals`) |
53
+ | `operator` | `and` (default) or `or` — applies to a nested `conditions` block |
54
+ | `conditions` | Nested array of condition objects for complex AND/OR logic |
55
+
56
+ ### Comparator Values
57
+
58
+ Use these exact strings — incorrect comparator names will silently fail or error:
59
+
60
+ | Comparator | Meaning |
61
+ |---|---|
62
+ | `equals` | Exact match (default) |
63
+ | `not_equal` | Not equal |
64
+ | `greater_than` | `>` |
65
+ | `greater_than_equal` | `>=` |
66
+ | `less_than` | `<` |
67
+ | `less_than_equal` | `<=` |
68
+ | `starts_with` | String starts with value |
69
+ | `contains` | String contains value |
70
+ | `ends_with` | String ends with value |
71
+ | `between` | Value is between two bounds (pass `value` as `[min, max]`) |
72
+
73
+ ### Query Object Parameters
74
+
75
+ | Property | Description |
76
+ |---|---|
77
+ | `conditions` | Array of condition objects |
78
+ | `limit` | Maximum number of records to return |
79
+ | `offset` | Number of records to skip (for pagination) |
80
+ | `select` | Array of attribute names to return; supports `$id` and `$updatedtime` |
81
+ | `sort` | Object with `attribute`, `descending` (bool), and optional `next` for secondary sort |
82
+
83
+ ### Examples
84
+
85
+ **Simple filter:**
86
+ ```javascript
87
+ for await (const record of tables.Product.search({
88
+ conditions: [{ attribute: 'price', comparator: 'less_than', value: 100 }],
89
+ limit: 20,
90
+ })) { ... }
91
+ ```
92
+
93
+ **AND + nested OR:**
94
+ ```javascript
95
+ for await (const record of tables.Product.search({
96
+ conditions: [
97
+ { attribute: 'price', comparator: 'less_than', value: 100 },
98
+ {
99
+ operator: 'or',
100
+ conditions: [
101
+ { attribute: 'rating', comparator: 'greater_than', value: 4 },
102
+ { attribute: 'featured', value: true },
103
+ ],
104
+ },
105
+ ],
106
+ })) { ... }
107
+ ```
108
+
109
+ **Relationship traversal:**
110
+ ```javascript
111
+ for await (const record of tables.Book.search({
112
+ conditions: [{ attribute: ['brand', 'name'], comparator: 'equals', value: 'Harper' }],
113
+ })) { ... }
114
+ ```
115
+
116
+ **Sort and paginate:**
117
+ ```javascript
118
+ for await (const record of tables.Product.search({
119
+ conditions: [{ attribute: 'inStock', value: true }],
120
+ sort: { attribute: 'price', descending: false },
121
+ limit: 10,
122
+ offset: 20,
123
+ })) { ... }
124
+ ```
125
+
41
126
  ## Cautions
42
127
 
43
128
  Be very careful when performing updates and deletions! You may be dealing with live production data. The wrong request to delete, without approval from a human, could be devastating to a business. Always use the proper approval process.
@@ -24,7 +24,7 @@ Use this skill when you need to stream live updates to clients, implement chat f
24
24
  ### Bi-directional WebSocket Resource
25
25
 
26
26
  ```typescript
27
- import { Resource, tables } from 'harperdb';
27
+ import { Resource, tables } from 'harper';
28
28
 
29
29
  export class MySocket extends Resource {
30
30
  async *connect(target, incomingMessages) {
@@ -9,7 +9,7 @@ Harper uses GraphQL schemas to define database tables, relationships, and APIs.
9
9
 
10
10
  ## Core Harper Directives
11
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:
12
+ Harper extends GraphQL with custom directives that define database behavior. These are typically defined in `node_modules/harper/schema.graphql`. If you don't have access to that file, here is a reference of the most important ones:
13
13
 
14
14
  ### Table Definition
15
15
 
@@ -43,7 +43,7 @@ Create a file named `graphql.config.yml` in your project root with the following
43
43
 
44
44
  ```yaml
45
45
  schema:
46
- - 'node_modules/harperdb/schema.graphql'
46
+ - 'node_modules/harper/schema.graphql'
47
47
  - 'schema.graphql'
48
48
  - 'schemas/*.graphql'
49
49
  ```
@@ -59,7 +59,6 @@ Use this skill when you need to serve a frontend (HTML, CSS, JS, or a React app)
59
59
  4. **Deploy for Production**: For Vite apps, use a build script to generate static files into a `web/` folder and deploy them using the static handler pattern. For example, these scripts in a package.json can perform the necessary steps:
60
60
  ```json
61
61
  "build": "vite build",
62
- "deploy": "rm -Rf deploy && npm run build && mkdir deploy && mv web deploy/ && cp -R deploy-template/* deploy/ && cp -R schemas resources deploy/ && dotenv -- npm run deploy:component && rm -Rf deploy",
63
- "deploy:component": "(cd deploy && harper deploy_component . project=web restart=rolling replicated=true)"
62
+ "deploy": "rm -Rf deploy && npm run build && mkdir deploy && mv web deploy/ && cp -R deploy-template/* deploy/ && cp -R schemas resources deploy/ && (cd deploy && harper deploy_component . project=web restart=rolling replicated=true) && rm -Rf deploy",
64
63
  ```
65
64
  Then in production, the "Static Plugin" option will performantly and securely serve your assets. `npm create harper@latest` scaffolds all of this for you.
@@ -17,7 +17,7 @@ Use this skill when you want to write Harper Resources in TypeScript and have th
17
17
  2. **Name Files with `.ts`**: Create your resource files in the `resources/` directory with a `.ts` extension.
18
18
  3. **Use TypeScript Syntax**: Write your resource classes using standard TypeScript (interfaces, types, etc.).
19
19
  ```typescript
20
- import { Resource } from 'harperdb';
20
+ import { Resource } from 'harper';
21
21
  export class MyResource extends Resource {
22
22
  async get(): Promise<{ message: string }> {
23
23
  return { message: 'Running TS directly!' };
@@ -22,7 +22,7 @@ Use this skill when you need to store unstructured or large binary data (media,
22
22
  ```
23
23
  2. **Create and Store Blobs**: Use `createBlob()` from Harper's globals to wrap Buffers or Streams:
24
24
  ```javascript
25
- import { tables } from 'harperdb';
25
+ import { tables } from 'harper';
26
26
  const blob = createBlob(largeBuffer);
27
27
  await tables.MyTable.put('my-id', { data: blob });
28
28
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harperfast/template-react-studio",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "type": "module",
5
5
  "repository": "github:HarperFast/create-harper",
6
6
  "scripts": {},
package/skills-lock.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "source": "harperfast/skills",
6
6
  "sourceType": "github",
7
7
  "skillPath": "harper-best-practices/SKILL.md",
8
- "computedHash": "5ba34805d61ba1a997deffcbba9dd92ca775f286c4e8de8df0966518ff7b9eaf"
8
+ "computedHash": "838b776573e9ebd05ac70c9ad38233a5bf40d1882be0cc54744168092e96e251"
9
9
  }
10
10
  }
11
11
  }