@harperfast/template-react-ts-studio 1.12.1 → 1.12.2
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 +226 -112
- package/.agents/skills/harper-best-practices/rules/deploying-to-harper-fabric.md +96 -44
- package/.agents/skills/harper-best-practices/rules/v5-upgrade.md +135 -73
- package/agent/skills/harper-best-practices/AGENTS.md +226 -112
- package/agent/skills/harper-best-practices/rules/deploying-to-harper-fabric.md +96 -44
- package/agent/skills/harper-best-practices/rules/v5-upgrade.md +135 -73
- package/package.json +1 -1
- package/skills-lock.json +1 -1
|
@@ -8,32 +8,28 @@ metadata:
|
|
|
8
8
|
- >-
|
|
9
9
|
fabric/cluster-creation-management.md#Connecting the Harper CLI to a
|
|
10
10
|
Cluster
|
|
11
|
-
sourceCommit:
|
|
12
|
-
inputHash:
|
|
11
|
+
sourceCommit: 6bf676d4bde158fcd08a81565556a0ee91768274
|
|
12
|
+
inputHash: 8c8b2fabac08a561
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
# Deploying to Harper Fabric
|
|
16
16
|
|
|
17
|
-
Instructions for the agent to follow when deploying a Harper application to a remote Harper Fabric
|
|
17
|
+
Instructions for the agent to follow when deploying a Harper application to a remote Harper Fabric cluster.
|
|
18
18
|
|
|
19
19
|
## When to Use
|
|
20
20
|
|
|
21
|
-
Apply this rule when deploying a Harper application to a remote Harper Fabric cluster or any remote Harper instance.
|
|
21
|
+
Apply this rule when deploying a Harper application to a remote Harper Fabric cluster or any remote Harper instance. This includes first-time deploys, redeployments, rollbacks, and CI/CD pipeline deployments. See [creating-a-fabric-account-and-cluster.md](creating-a-fabric-account-and-cluster.md) to set up a cluster before deploying.
|
|
22
22
|
|
|
23
23
|
## How It Works
|
|
24
24
|
|
|
25
|
-
1. **
|
|
26
|
-
|
|
27
|
-
2. **Authenticate with `harper login`**: Run `harper login` once to store an authentication token locally. The CLI also writes `HARPER_CLI_TARGET` to a local `.env` for subsequent commands.
|
|
25
|
+
1. **Authenticate against the remote cluster**: Run `harper login` once, pointing at the cluster's Application URL (found on the cluster's **Config → Overview** page). The CLI stores the token and writes `HARPER_CLI_TARGET` to a local `.env`.
|
|
28
26
|
|
|
29
27
|
```bash
|
|
30
28
|
harper login <Application URL>
|
|
31
29
|
# Provide cluster username and password when prompted
|
|
32
30
|
```
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
3. **Deploy with `harper deploy`**: After logging in, deploy without repeating credentials.
|
|
32
|
+
2. **Deploy the application**: Run `harper deploy` with the required parameters. After logging in, no credentials need to be repeated.
|
|
37
33
|
|
|
38
34
|
```bash
|
|
39
35
|
harper deploy \
|
|
@@ -44,7 +40,50 @@ Apply this rule when deploying a Harper application to a remote Harper Fabric cl
|
|
|
44
40
|
replicated=true
|
|
45
41
|
```
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
3. **Choose a package source**: Set the `package` parameter to any valid npm dependency value, or omit it to package and upload the current local directory.
|
|
44
|
+
|
|
45
|
+
| Value | Effect |
|
|
46
|
+
| ---------------------------------------------------- | ------------------------------------------------ |
|
|
47
|
+
| _(omitted)_ | Packages and deploys the current local directory |
|
|
48
|
+
| `"@harperdb/status-check"` | npm package |
|
|
49
|
+
| `"HarperDB/status-check"` | GitHub shorthand |
|
|
50
|
+
| `"https://github.com/HarperDB/status-check"` | GitHub URL |
|
|
51
|
+
| `"git+ssh://git@github.com:HarperDB/secret-app.git"` | Private repo via SSH |
|
|
52
|
+
| `"https://example.com/application.tar.gz"` | Tarball URL |
|
|
53
|
+
|
|
54
|
+
For git tags, use the `semver` directive:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
HarperDB/application-template#semver:v1.0.0
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
4. **Deploy by reference (optional)**: Instead of uploading a snapshot, send a pinned git reference so the cluster fetches and builds that exact commit. Use `by_ref=true` to resolve the current commit from the local repository automatically.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
harper deploy by_ref=true restart=true replicated=true
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Use `ref` to deploy a specific commit, tag, or branch (resolved to a full SHA before sending):
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Deploy a specific tag
|
|
70
|
+
harper deploy ref=v1.2.0 restart=true replicated=true
|
|
71
|
+
|
|
72
|
+
# Roll back by deploying an older commit
|
|
73
|
+
harper deploy ref=9f8c2a1 restart=true replicated=true
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Key `by_ref` parameters:**
|
|
77
|
+
|
|
78
|
+
| Parameter | Required | Description |
|
|
79
|
+
| ------------ | -------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
80
|
+
| `by_ref` | — | Build the package reference from the local repository |
|
|
81
|
+
| `ref` | optional | Deploy a specific commit, tag, or branch instead of `HEAD`. Implies `by_ref`. |
|
|
82
|
+
| `credential` | optional | Set to `true` to authenticate the clone with the stored credential for the repository's host. Omit for public repositories. |
|
|
83
|
+
|
|
84
|
+
> Commit and push before deploying by reference. The cluster clones from the remote and only sees pushed commits. Run `git fetch` if the unpushed-commit check fires for a commit you know you pushed.
|
|
85
|
+
|
|
86
|
+
5. **Authenticate for CI/CD**: Use environment variables instead of `harper login` for automated pipelines.
|
|
48
87
|
|
|
49
88
|
```bash
|
|
50
89
|
export HARPER_CLI_USERNAME=<username>
|
|
@@ -57,7 +96,19 @@ Apply this rule when deploying a Harper application to a remote Harper Fabric cl
|
|
|
57
96
|
replicated=true
|
|
58
97
|
```
|
|
59
98
|
|
|
60
|
-
|
|
99
|
+
6. **Provision credentials for private repositories**: Run `harper deploy setup=true` once per component and source to provision a deploy credential. Run this with an administrative credential, not the CI identity.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
harper deploy setup=true
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Then pass `credential=true` on subsequent deploys:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
harper deploy by_ref=true credential=true restart=true replicated=true
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
7. **Use inline auth for one-off commands (not recommended for production)**: Pass `auth_username` and `auth_password` directly. These take precedence over environment variables and saved login tokens.
|
|
61
112
|
|
|
62
113
|
```bash
|
|
63
114
|
harper deploy \
|
|
@@ -70,59 +121,56 @@ Apply this rule when deploying a Harper application to a remote Harper Fabric cl
|
|
|
70
121
|
replicated=true
|
|
71
122
|
```
|
|
72
123
|
|
|
73
|
-
6. **Choose a package source**: Set the `package` parameter to any valid npm dependency value, or omit it to package and deploy the current local directory.
|
|
74
|
-
|
|
75
|
-
| Value | Meaning |
|
|
76
|
-
| ---------------------------------------------------- | ---------------------------------------------- |
|
|
77
|
-
| _(omitted)_ | Package and deploy the current local directory |
|
|
78
|
-
| `"@harperdb/status-check"` | npm package |
|
|
79
|
-
| `"HarperDB/status-check"` | GitHub shorthand |
|
|
80
|
-
| `"https://github.com/HarperDB/status-check"` | GitHub full URL |
|
|
81
|
-
| `"git+ssh://git@github.com:HarperDB/secret-app.git"` | Private repo via SSH |
|
|
82
|
-
| `"https://example.com/application.tar.gz"` | Remote tarball |
|
|
83
|
-
|
|
84
|
-
For pinned git tags, use the `semver` directive:
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
HarperDB/application-template#semver:v1.0.0
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
For SSH-based private repos, register keys with the `Add SSH Key` operation before deploying.
|
|
91
|
-
|
|
92
124
|
## Examples
|
|
93
125
|
|
|
94
|
-
**
|
|
126
|
+
**Standard deploy after login:**
|
|
95
127
|
|
|
96
128
|
```bash
|
|
97
129
|
harper login https://my-cluster.harperdbcloud.com
|
|
98
|
-
# Enter username and password when prompted
|
|
99
|
-
|
|
100
130
|
harper deploy \
|
|
101
131
|
project=my-app \
|
|
102
|
-
package="
|
|
132
|
+
package="@myorg/my-app" \
|
|
103
133
|
target=https://my-cluster.harperdbcloud.com \
|
|
104
134
|
restart=true \
|
|
105
135
|
replicated=true
|
|
106
136
|
```
|
|
107
137
|
|
|
108
|
-
**
|
|
138
|
+
**Deploy current directory as a snapshot:**
|
|
109
139
|
|
|
110
140
|
```bash
|
|
111
|
-
export HARPER_CLI_USERNAME=admin
|
|
112
|
-
export HARPER_CLI_PASSWORD=secret
|
|
113
141
|
harper deploy \
|
|
114
142
|
project=my-app \
|
|
115
|
-
package="@harperdb/status-check" \
|
|
116
143
|
target=https://my-cluster.harperdbcloud.com \
|
|
117
144
|
restart=true \
|
|
118
145
|
replicated=true
|
|
119
146
|
```
|
|
120
147
|
|
|
121
|
-
**Deploy
|
|
148
|
+
**Deploy a pinned tag by reference:**
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
harper deploy ref=v1.2.0 restart=true replicated=true
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Deploy a private repository by reference with a stored credential:**
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
harper deploy by_ref=true credential=true restart=true replicated=true
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**GitHub Actions — deploy the pull request head commit explicitly:**
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
harper deploy ref=${{ github.event.pull_request.head.sha }} restart=true replicated=true
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**CI/CD deploy using environment variables:**
|
|
122
167
|
|
|
123
168
|
```bash
|
|
169
|
+
export HARPER_CLI_USERNAME=<username>
|
|
170
|
+
export HARPER_CLI_PASSWORD=<password>
|
|
124
171
|
harper deploy \
|
|
125
172
|
project=my-app \
|
|
173
|
+
package="HarperDB/my-app#semver:v1.0.0" \
|
|
126
174
|
target=https://my-cluster.harperdbcloud.com \
|
|
127
175
|
restart=true \
|
|
128
176
|
replicated=true
|
|
@@ -130,7 +178,11 @@ harper deploy \
|
|
|
130
178
|
|
|
131
179
|
## Notes
|
|
132
180
|
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
136
|
-
-
|
|
181
|
+
- `harper login` stores an authentication token so subsequent `harper deploy` commands do not require credentials to be repeated.
|
|
182
|
+
- Inline `auth_username`/`auth_password` parameters take precedence over environment variables, which take precedence over saved login tokens.
|
|
183
|
+
- For SSH-based private repos, register keys with the `add_ssh_key` operation before deploying.
|
|
184
|
+
- `by_ref` deploys build from source on each cluster node. If your application requires a build step that cannot run on the node, deploy a built payload (omit `by_ref`) instead.
|
|
185
|
+
- `harper deploy setup=true` requires **super_user** privileges. Provision credentials with an administrative account, not the CI identity.
|
|
186
|
+
- Tags and branches passed to `ref` are resolved to a full commit SHA locally before the deploy is sent. If resolution fails, run `git fetch` and retry, or pass a full commit SHA directly.
|
|
187
|
+
- The `refs/pull/<n>/head` style refs are rejected; use `ref=${{ github.event.pull_request.head.sha }}` in GitHub Actions pull request workflows instead.
|
|
188
|
+
- Deploy credentials provisioned via `harper deploy setup=true` are stored scoped to the component and reused on every subsequent deploy, including rollbacks.
|
|
@@ -7,21 +7,21 @@ metadata:
|
|
|
7
7
|
mode: generate
|
|
8
8
|
sources:
|
|
9
9
|
- release-notes/v5-lincoln/v5-migration.md
|
|
10
|
-
sourceCommit:
|
|
11
|
-
inputHash:
|
|
10
|
+
sourceCommit: aa74b1cca7f4a511877730268f2fb6e628b50cf9
|
|
11
|
+
inputHash: 01c0fafb9afa68a0
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
# v5 Upgrade: Breaking Changes and Migration Guide
|
|
15
15
|
|
|
16
|
-
Instructions for the agent to apply when migrating a Harper application to v5
|
|
16
|
+
Instructions for the agent to apply all required breaking-change fixes and recommended updates when migrating a Harper application to v5.
|
|
17
17
|
|
|
18
18
|
## When to Use
|
|
19
19
|
|
|
20
|
-
Apply this rule
|
|
20
|
+
Apply this rule whenever upgrading an existing Harper application to v5, encountering v5 runtime errors related to module imports, `Table.get` return values, transaction context, process spawning, or VM module loading. Also apply when configuring `harperdb-config.yaml` for a v5 deployment.
|
|
21
21
|
|
|
22
22
|
## How It Works
|
|
23
23
|
|
|
24
|
-
1. **Update the package import from `harperdb` to `harper`**: All application code must import from `harper
|
|
24
|
+
1. **Update the package import from `harperdb` to `harper`**: All application code must import from `harper`, not `harperdb`.
|
|
25
25
|
|
|
26
26
|
```javascript
|
|
27
27
|
import { tables } from 'harper';
|
|
@@ -29,74 +29,160 @@ Apply this rule when upgrading an existing Harper application to v5, when encoun
|
|
|
29
29
|
|
|
30
30
|
2. **Enable `allowInstallScripts` if packages require install scripts**: Harper v5 uses `--ignore-scripts` by default when installing packages. If your application requires installation scripts (e.g., to install additional binaries), set the `allowInstallScripts` option when deploying.
|
|
31
31
|
|
|
32
|
-
3. **Update `Table.get` usage — return value is now a frozen record object**: `Table.get`
|
|
32
|
+
3. **Update `Table.get` usage — return value is now a plain frozen record object**: `Table.get` no longer returns an instance of the table class. The returned object is frozen and does not have table instance methods.
|
|
33
33
|
- Replace `wasLoadedFromSource()` with `target.loadedFromSource`:
|
|
34
34
|
|
|
35
35
|
```javascript
|
|
36
|
-
//
|
|
36
|
+
// OLD — no longer works
|
|
37
37
|
const record = await Table.get(id);
|
|
38
|
-
if (record.wasLoadedFromSource()) {
|
|
38
|
+
if (record.wasLoadedFromSource()) {
|
|
39
|
+
// record was loaded from origin (not cache)
|
|
40
|
+
}
|
|
41
|
+
```
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
```javascript
|
|
44
|
+
// NEW
|
|
45
|
+
const target = new RequestTarget(); // note that this is passed in if you are overriding the `get` method
|
|
42
46
|
target.id = id;
|
|
43
47
|
const record = await Table.get(target);
|
|
44
48
|
if (target.loadedFromSource) {
|
|
45
|
-
|
|
49
|
+
// record was loaded from origin (not cache)
|
|
46
50
|
}
|
|
47
51
|
```
|
|
48
52
|
|
|
49
|
-
-
|
|
53
|
+
- The record object still has `getUpdatedTime` and `getExpiresAt` methods available.
|
|
54
|
+
|
|
55
|
+
- **Handle frozen records**: The record object is frozen — you cannot add or remove properties directly. Copy and spread instead:
|
|
50
56
|
|
|
51
57
|
```javascript
|
|
52
|
-
//
|
|
58
|
+
// OLD — throws in v5
|
|
53
59
|
const record = await Table.get(id);
|
|
54
60
|
record.property = 'changed';
|
|
61
|
+
```
|
|
55
62
|
|
|
56
|
-
|
|
63
|
+
```javascript
|
|
64
|
+
// NEW
|
|
57
65
|
let record = await Table.get(id);
|
|
58
66
|
record = { ...record, property: 'changed' };
|
|
59
67
|
```
|
|
60
68
|
|
|
61
|
-
|
|
69
|
+
4. **Update transaction and context handling**: Harper v5 uses asynchronous context tracking. Context and the current transaction are automatically carried to all calls, including `Table.get`. Code that previously omitted context to escape a transaction must now explicitly commit or start a new transaction.
|
|
70
|
+
- Import `getContext` and `transaction` from `harper`:
|
|
62
71
|
|
|
63
|
-
|
|
72
|
+
```javascript
|
|
73
|
+
import { getContext, transaction } from 'harper';
|
|
74
|
+
```
|
|
64
75
|
|
|
65
|
-
|
|
66
|
-
import { setTimeout as delay } from 'node:timers/promises';
|
|
67
|
-
import { getContext, transaction } from 'harper';
|
|
68
|
-
|
|
69
|
-
class MyResource {
|
|
70
|
-
static async get(target) {
|
|
71
|
-
// Commit the current transaction to read latest data:
|
|
72
|
-
await getContext().transaction.commit();
|
|
73
|
-
// Optionally wrap each poll in a new transaction:
|
|
74
|
-
while ((await transaction(() => Table.get(target))).status !== 'ready') {
|
|
75
|
-
await delay(100);
|
|
76
|
-
}
|
|
77
|
-
return Table.get(target);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
```
|
|
76
|
+
- Explicitly commit the current transaction before reading updated data:
|
|
81
77
|
|
|
82
|
-
|
|
78
|
+
```javascript
|
|
79
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
80
|
+
import { getContext, transaction } from 'harper';
|
|
81
|
+
class MyResource {
|
|
82
|
+
static async get(target) {
|
|
83
|
+
await getContext().transaction.commit();
|
|
84
|
+
while ((await transaction(() => Table.get(target))).status !== 'ready') {
|
|
85
|
+
await delay(100);
|
|
86
|
+
}
|
|
87
|
+
return Table.get(target);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
5. **Register allowed spawn commands via `allowedSpawnCommands`**: Any `spawn` or `execFile` call may only launch executables listed in `applications.allowedSpawnCommands` in `harperdb-config.yaml`. The `exec` function is not usable through the substituted module, and `execSync` always throws. The `spawn`, `execFile`, and `fork` functions also require a `name` property in the `options` argument to prevent process multiplication across threads.
|
|
83
93
|
|
|
84
94
|
6. **Replace `blob.save()` with `saveBeforeCommit`**: The `blob.save()` method has been removed. Use the `saveBeforeCommit` flag in the options passed to the `Blob` constructor instead.
|
|
85
95
|
|
|
86
|
-
7. **Configure the `moduleLoader` and `lockdown` settings**: Harper v5 loads application modules through Node.js's VM module API. Control
|
|
96
|
+
7. **Configure the `moduleLoader` and `lockdown` settings**: Harper v5 loads application modules through Node.js's VM module API. Control all behavior in the `applications` section of `harperdb-config.yaml`:
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
applications:
|
|
100
|
+
lockdown: freeze-after-load # default; see below
|
|
101
|
+
moduleLoader: vm-current-context # vm-current-context (default) | vm | native | compartment
|
|
102
|
+
dependencyLoader: auto # auto (default) | app | native
|
|
103
|
+
allowedDirectory: app # app (default) | any
|
|
104
|
+
allowedSpawnCommands: # see "Spawning new processes" above
|
|
105
|
+
- npm
|
|
106
|
+
- node
|
|
107
|
+
# allowedBuiltinModules: [] # if omitted, all Node.js built-ins are allowed
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**`moduleLoader` options:**
|
|
111
|
+
|
|
112
|
+
| Value | Behavior |
|
|
113
|
+
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
114
|
+
| `vm-current-context` | Default. VM loader in Harper's own context; shares intrinsics with Harper for best compatibility. |
|
|
115
|
+
| `vm` | VM loader in a separate per-application context with its own intrinsics; stronger isolation but can cause `instanceof` failures. |
|
|
116
|
+
| `native` | Standard Node.js `import()` with no VM loader; application-specific context (tagged logging, per-app `config`) not available. |
|
|
117
|
+
| `compartment` | SES Compartment-based loading; for specialized sandboxing only. |
|
|
118
|
+
|
|
119
|
+
**`lockdown` options:**
|
|
120
|
+
|
|
121
|
+
| Value | Behavior |
|
|
122
|
+
| ------------------- | ------------------------------------------------------------- |
|
|
123
|
+
| `freeze-after-load` | Default. Freezes intrinsics after all components have loaded. |
|
|
124
|
+
| `freeze` | Freezes intrinsics before loading any application code. |
|
|
125
|
+
| `ses` | Full SES lockdown via the `ses` package; strictest. |
|
|
126
|
+
| `none` | No lockdown. Use as a temporary workaround only. |
|
|
127
|
+
- To disable the VM loader entirely and restore pre-v5 behavior:
|
|
87
128
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
129
|
+
```yaml
|
|
130
|
+
applications:
|
|
131
|
+
moduleLoader: native
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- To restrict which Node.js built-ins are accessible:
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
applications:
|
|
138
|
+
allowedBuiltinModules:
|
|
139
|
+
- fs
|
|
140
|
+
- path
|
|
141
|
+
- http
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- To allow loading modules from outside the application directory:
|
|
145
|
+
|
|
146
|
+
```yaml
|
|
147
|
+
applications:
|
|
148
|
+
allowedDirectory: any
|
|
149
|
+
```
|
|
96
150
|
|
|
97
151
|
## Examples
|
|
98
152
|
|
|
99
|
-
|
|
153
|
+
**Full transaction context migration:**
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
157
|
+
import { getContext, transaction } from 'harper';
|
|
158
|
+
|
|
159
|
+
class MyResource {
|
|
160
|
+
static async get(target) {
|
|
161
|
+
// Explicitly commit the transaction to see updated data
|
|
162
|
+
await getContext().transaction.commit();
|
|
163
|
+
// Start a new transaction for each get to see the latest data
|
|
164
|
+
while ((await transaction(() => Table.get(target))).status !== 'ready') {
|
|
165
|
+
await delay(100);
|
|
166
|
+
}
|
|
167
|
+
return Table.get(target);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**`Table.get` with `loadedFromSource` check:**
|
|
173
|
+
|
|
174
|
+
```javascript
|
|
175
|
+
import { tables } from 'harper';
|
|
176
|
+
|
|
177
|
+
const target = new RequestTarget();
|
|
178
|
+
target.id = id;
|
|
179
|
+
const record = await Table.get(target);
|
|
180
|
+
if (target.loadedFromSource) {
|
|
181
|
+
// record was loaded from origin (not cache)
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Full `harperdb-config.yaml` `applications` block:**
|
|
100
186
|
|
|
101
187
|
```yaml
|
|
102
188
|
applications:
|
|
@@ -109,35 +195,11 @@ applications:
|
|
|
109
195
|
- node
|
|
110
196
|
```
|
|
111
197
|
|
|
112
|
-
### Restricting allowed built-in modules
|
|
113
|
-
|
|
114
|
-
```yaml
|
|
115
|
-
applications:
|
|
116
|
-
allowedBuiltinModules:
|
|
117
|
-
- fs
|
|
118
|
-
- path
|
|
119
|
-
- http
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Disabling the VM loader for package compatibility
|
|
123
|
-
|
|
124
|
-
```yaml
|
|
125
|
-
applications:
|
|
126
|
-
moduleLoader: native
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Accessing context and committing a transaction
|
|
130
|
-
|
|
131
|
-
```javascript
|
|
132
|
-
import { getContext } from 'harper';
|
|
133
|
-
|
|
134
|
-
await getContext().transaction.commit();
|
|
135
|
-
```
|
|
136
|
-
|
|
137
198
|
## Notes
|
|
138
199
|
|
|
139
|
-
-
|
|
140
|
-
-
|
|
141
|
-
-
|
|
142
|
-
- `
|
|
143
|
-
-
|
|
200
|
+
- Use `getContext` (imported from `harper`) to access the current transaction anywhere in application code without passing context explicitly through every call.
|
|
201
|
+
- Harper functions and APIs should be accessed through the `harper` package rather than through global variables.
|
|
202
|
+
- Use `static` methods on Resources/Tables to implement endpoints, and access request information from the request `target` argument or via `getContext`.
|
|
203
|
+
- `lockdown: none` is only a temporary workaround for dependencies that mutate intrinsic prototypes at runtime; do not leave it set in production.
|
|
204
|
+
- Under `lockdown: ses`, the constrained (https-only) `fetch` is applied only in `vm` mode. In `vm-current-context` and `native` modes, application code uses the standard global `fetch`.
|
|
205
|
+
- In production, `allowedDirectory: app` is the default; dev mode installs default to `allowedDirectory: any`.
|