@harperfast/template-vue-ts-studio 1.9.0 → 1.9.1
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/skills/harper-best-practices/AGENTS.md +16 -12
- package/.agents/skills/harper-best-practices/rules/custom-resources.md +5 -4
- package/.agents/skills/harper-best-practices/rules/extending-tables.md +11 -8
- package/agent/skills/harper-best-practices/AGENTS.md +1950 -0
- package/agent/skills/harper-best-practices/SKILL.md +96 -0
- package/agent/skills/harper-best-practices/rules/adding-tables-with-schemas.md +42 -0
- package/agent/skills/harper-best-practices/rules/automatic-apis.md +165 -0
- package/agent/skills/harper-best-practices/rules/caching.md +163 -0
- package/agent/skills/harper-best-practices/rules/checking-authentication.md +190 -0
- package/agent/skills/harper-best-practices/rules/creating-a-fabric-account-and-cluster.md +30 -0
- package/agent/skills/harper-best-practices/rules/creating-harper-apps.md +54 -0
- package/agent/skills/harper-best-practices/rules/custom-resources.md +44 -0
- package/agent/skills/harper-best-practices/rules/defining-relationships.md +35 -0
- package/agent/skills/harper-best-practices/rules/deploying-to-harper-fabric.md +122 -0
- package/agent/skills/harper-best-practices/rules/extending-tables.md +46 -0
- package/agent/skills/harper-best-practices/rules/handling-binary-data.md +45 -0
- package/agent/skills/harper-best-practices/rules/load-env.md +111 -0
- package/agent/skills/harper-best-practices/rules/logging.md +169 -0
- package/agent/skills/harper-best-practices/rules/programmatic-table-requests.md +134 -0
- package/agent/skills/harper-best-practices/rules/querying-rest-apis.md +202 -0
- package/agent/skills/harper-best-practices/rules/real-time-apps.md +102 -0
- package/agent/skills/harper-best-practices/rules/schema-design-tooling.md +161 -0
- package/agent/skills/harper-best-practices/rules/serving-web-content.md +85 -0
- package/agent/skills/harper-best-practices/rules/typescript-type-stripping.md +64 -0
- package/agent/skills/harper-best-practices/rules/using-blob-datatype.md +38 -0
- package/agent/skills/harper-best-practices/rules/vector-indexing.md +124 -0
- package/agent/skills/harper-best-practices/rules.manifest.yaml +302 -0
- package/package.json +1 -1
- package/skills-lock.json +1 -1
|
@@ -1031,19 +1031,20 @@ Use this skill when the automatic CRUD operations provided by `@table @export` a
|
|
|
1031
1031
|
|
|
1032
1032
|
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.
|
|
1033
1033
|
2. **Create the Resource File**: Create a `.ts` or `.js` file in the directory specified by `jsResource` in `config.yaml` (typically `resources/`).
|
|
1034
|
-
3. **Define the Resource Class**: Export a class extending `Resource` from `harper
|
|
1034
|
+
3. **Define the Resource Class**: Export a class extending `Resource` from `harper` and define **static** methods for the HTTP verbs you handle. In Harper 5 the static methods are the HTTP handlers (mapped 1:1 to verbs); they receive a pre-parsed `RequestTarget`, and write handlers also receive the request body as an awaitable `data` argument:
|
|
1035
1035
|
|
|
1036
1036
|
```typescript
|
|
1037
|
-
import {
|
|
1037
|
+
import { Resource } from 'harper';
|
|
1038
1038
|
|
|
1039
1039
|
export class MyResource extends Resource {
|
|
1040
|
-
|
|
1040
|
+
// v5 handlers are static and map 1:1 to HTTP verbs.
|
|
1041
|
+
static async get(target: any) {
|
|
1041
1042
|
return { message: 'Hello from custom GET!' };
|
|
1042
1043
|
}
|
|
1043
1044
|
}
|
|
1044
1045
|
```
|
|
1045
1046
|
|
|
1046
|
-
4. **Implement HTTP Methods**: Add methods
|
|
1047
|
+
4. **Implement HTTP Methods**: Add static methods (`get`, `post`, `put`, `patch`, or `delete`) to handle the corresponding requests. Read/delete handlers receive `(target)`; write handlers receive `(target, data)` where `data` is awaitable.
|
|
1047
1048
|
5. **Route Nesting and Naming**: You can control the URL structure by how you export your resources:
|
|
1048
1049
|
- **Direct Class Export**: `export class Foo extends Resource` creates endpoints at `/Foo/`. Class names are case-sensitive in the URL.
|
|
1049
1050
|
- **Nested Objects**: `export const Bar = { Foo };` creates endpoints at `/Bar/Foo/`.
|
|
@@ -1074,23 +1075,26 @@ Use this skill when you need to add custom validation, side effects (like webhoo
|
|
|
1074
1075
|
}
|
|
1075
1076
|
```
|
|
1076
1077
|
2. **Create the Extension File**: Create a `.ts` file in your `resources/` directory.
|
|
1077
|
-
3. **Extend the Table Resource**: Export a class that extends `tables.YourTableName
|
|
1078
|
+
3. **Extend the Table Resource**: Export a class that extends `tables.YourTableName` and override the relevant **static** methods. In Harper 5 resource handlers are static and map 1:1 to HTTP verbs: `get(target)`, `post(target, data)`, `put(target, data)`, `patch(target, data)`, `delete(target)`. `target` is a pre-parsed `RequestTarget`; for writes, `data` is the request body and is **awaitable** (`await data`). Delegate to `super` to keep Harper's default behavior — a collection create passes just the record (`super.post(record)`), updates pass the target (`super.put(target, data)` / `super.patch(target, data)`), and reads/deletes pass the target (`super.get(target)`). To return a specific HTTP status from a thrown error, set **`.statusCode`** (e.g. `400`) on the error — a plain `.status` property is ignored.
|
|
1078
1079
|
|
|
1079
1080
|
```typescript
|
|
1080
|
-
import {
|
|
1081
|
+
import { tables } from 'harper';
|
|
1081
1082
|
|
|
1082
1083
|
export class MyTable extends tables.MyTable {
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1084
|
+
// Static handler; receives (target, data) — data is awaitable.
|
|
1085
|
+
static async post(target: any, data: any) {
|
|
1086
|
+
const record = await data;
|
|
1087
|
+
if (!record?.name) {
|
|
1088
|
+
const error: any = new Error('Name is required');
|
|
1089
|
+
error.statusCode = 400; // HTTP status (use statusCode, NOT status)
|
|
1090
|
+
throw error;
|
|
1087
1091
|
}
|
|
1088
|
-
return super.post(
|
|
1092
|
+
return super.post(record); // create delegates with the record (no id)
|
|
1089
1093
|
}
|
|
1090
1094
|
}
|
|
1091
1095
|
```
|
|
1092
1096
|
|
|
1093
|
-
4. **Override Methods**: Override `get`, `post`, `put`, `patch`, or `delete` as needed
|
|
1097
|
+
4. **Override Methods**: Override the static `get`, `post`, `put`, `patch`, or `delete` as needed, delegating to `super.<method>` (see the argument forms above) to preserve Harper's default behavior unless you intend to replace it entirely.
|
|
1094
1098
|
5. **Implement Logic**: Use overrides for validation, side effects, or transforming data before/after database operations.
|
|
1095
1099
|
|
|
1096
1100
|
### 3.3 Programmatic Table Requests
|
|
@@ -17,19 +17,20 @@ Use this skill when the automatic CRUD operations provided by `@table @export` a
|
|
|
17
17
|
|
|
18
18
|
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.
|
|
19
19
|
2. **Create the Resource File**: Create a `.ts` or `.js` file in the directory specified by `jsResource` in `config.yaml` (typically `resources/`).
|
|
20
|
-
3. **Define the Resource Class**: Export a class extending `Resource` from `harper
|
|
20
|
+
3. **Define the Resource Class**: Export a class extending `Resource` from `harper` and define **static** methods for the HTTP verbs you handle. In Harper 5 the static methods are the HTTP handlers (mapped 1:1 to verbs); they receive a pre-parsed `RequestTarget`, and write handlers also receive the request body as an awaitable `data` argument:
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
-
import {
|
|
23
|
+
import { Resource } from 'harper';
|
|
24
24
|
|
|
25
25
|
export class MyResource extends Resource {
|
|
26
|
-
|
|
26
|
+
// v5 handlers are static and map 1:1 to HTTP verbs.
|
|
27
|
+
static async get(target: any) {
|
|
27
28
|
return { message: 'Hello from custom GET!' };
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
```
|
|
31
32
|
|
|
32
|
-
4. **Implement HTTP Methods**: Add methods
|
|
33
|
+
4. **Implement HTTP Methods**: Add static methods (`get`, `post`, `put`, `patch`, or `delete`) to handle the corresponding requests. Read/delete handlers receive `(target)`; write handlers receive `(target, data)` where `data` is awaitable.
|
|
33
34
|
5. **Route Nesting and Naming**: You can control the URL structure by how you export your resources:
|
|
34
35
|
- **Direct Class Export**: `export class Foo extends Resource` creates endpoints at `/Foo/`. Class names are case-sensitive in the URL.
|
|
35
36
|
- **Nested Objects**: `export const Bar = { Foo };` creates endpoints at `/Bar/Foo/`.
|
|
@@ -23,21 +23,24 @@ Use this skill when you need to add custom validation, side effects (like webhoo
|
|
|
23
23
|
}
|
|
24
24
|
```
|
|
25
25
|
2. **Create the Extension File**: Create a `.ts` file in your `resources/` directory.
|
|
26
|
-
3. **Extend the Table Resource**: Export a class that extends `tables.YourTableName
|
|
26
|
+
3. **Extend the Table Resource**: Export a class that extends `tables.YourTableName` and override the relevant **static** methods. In Harper 5 resource handlers are static and map 1:1 to HTTP verbs: `get(target)`, `post(target, data)`, `put(target, data)`, `patch(target, data)`, `delete(target)`. `target` is a pre-parsed `RequestTarget`; for writes, `data` is the request body and is **awaitable** (`await data`). Delegate to `super` to keep Harper's default behavior — a collection create passes just the record (`super.post(record)`), updates pass the target (`super.put(target, data)` / `super.patch(target, data)`), and reads/deletes pass the target (`super.get(target)`). To return a specific HTTP status from a thrown error, set **`.statusCode`** (e.g. `400`) on the error — a plain `.status` property is ignored.
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
|
-
import {
|
|
29
|
+
import { tables } from 'harper';
|
|
30
30
|
|
|
31
31
|
export class MyTable extends tables.MyTable {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
// Static handler; receives (target, data) — data is awaitable.
|
|
33
|
+
static async post(target: any, data: any) {
|
|
34
|
+
const record = await data;
|
|
35
|
+
if (!record?.name) {
|
|
36
|
+
const error: any = new Error('Name is required');
|
|
37
|
+
error.statusCode = 400; // HTTP status (use statusCode, NOT status)
|
|
38
|
+
throw error;
|
|
36
39
|
}
|
|
37
|
-
return super.post(
|
|
40
|
+
return super.post(record); // create delegates with the record (no id)
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
43
|
```
|
|
41
44
|
|
|
42
|
-
4. **Override Methods**: Override `get`, `post`, `put`, `patch`, or `delete` as needed
|
|
45
|
+
4. **Override Methods**: Override the static `get`, `post`, `put`, `patch`, or `delete` as needed, delegating to `super.<method>` (see the argument forms above) to preserve Harper's default behavior unless you intend to replace it entirely.
|
|
43
46
|
5. **Implement Logic**: Use overrides for validation, side effects, or transforming data before/after database operations.
|