@feltdb/feltkit 0.3.11 → 0.3.13
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/README.md +4 -3
- package/dist/app.d.ts +98 -3
- package/dist/app.js +63 -0
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.d.ts +39 -1
- package/dist/appboundry/build.js +57 -6
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest.js +46 -5
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/appboundry/host.d.ts +24 -5
- package/dist/appboundry/host.js +234 -141
- package/dist/appboundry/host.js.map +1 -1
- package/dist/appboundry/runtime.d.ts +44 -0
- package/dist/appboundry/runtime.js +99 -0
- package/dist/appboundry/runtime.js.map +1 -0
- package/dist/cli/entry.d.ts +1 -0
- package/dist/cli/entry.js +4 -0
- package/dist/cli/entry.js.map +1 -0
- package/dist/cli/main.d.ts +5 -0
- package/dist/cli/main.js +550 -13
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/test-reporter.d.ts +9 -0
- package/dist/cli/test-reporter.js +26 -0
- package/dist/cli/test-reporter.js.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.js.map +1 -1
- package/dist/dashboard/assets/index-BSnW2DC-.js +15 -0
- package/dist/dashboard/assets/{index-91I1zDK-.css → index-BXTNQAg1.css} +1 -1
- package/dist/dashboard/index.html +3 -3
- package/dist/docs.d.ts +12 -0
- package/dist/docs.js +42 -0
- package/dist/docs.js.map +1 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/platform/changes.d.ts +340 -0
- package/dist/platform/changes.js +355 -0
- package/dist/platform/changes.js.map +1 -0
- package/dist/platform/deployments.d.ts +653 -0
- package/dist/platform/deployments.js +532 -0
- package/dist/platform/deployments.js.map +1 -0
- package/dist/platform/operations.d.ts +74 -0
- package/dist/platform/operations.js +198 -0
- package/dist/platform/operations.js.map +1 -0
- package/dist/platform/platform.d.ts +78 -0
- package/dist/platform/platform.js +264 -0
- package/dist/platform/platform.js.map +1 -0
- package/dist/platform/server.d.ts +25 -0
- package/dist/platform/server.js +165 -0
- package/dist/platform/server.js.map +1 -0
- package/dist/platform/source.d.ts +27 -0
- package/dist/platform/source.js +142 -0
- package/dist/platform/source.js.map +1 -0
- package/dist/runtime/activity.d.ts +25 -0
- package/dist/runtime/activity.js +38 -12
- package/dist/runtime/activity.js.map +1 -1
- package/dist/runtime/agent.d.ts +16 -0
- package/dist/runtime/agent.js +92 -28
- package/dist/runtime/agent.js.map +1 -1
- package/dist/runtime/backup-environment.d.ts +32 -0
- package/dist/runtime/backup-environment.js +92 -0
- package/dist/runtime/backup-environment.js.map +1 -0
- package/dist/runtime/backup.d.ts +129 -0
- package/dist/runtime/backup.js +344 -0
- package/dist/runtime/backup.js.map +1 -0
- package/dist/runtime/capabilities.js +4 -2
- package/dist/runtime/capabilities.js.map +1 -1
- package/dist/runtime/changes.js +2 -2
- package/dist/runtime/changes.js.map +1 -1
- package/dist/runtime/contract.js +4 -3
- package/dist/runtime/contract.js.map +1 -1
- package/dist/runtime/data.d.ts +36 -5
- package/dist/runtime/data.js +165 -55
- package/dist/runtime/data.js.map +1 -1
- package/dist/runtime/decisions.js +2 -1
- package/dist/runtime/decisions.js.map +1 -1
- package/dist/runtime/instance.js +17 -0
- package/dist/runtime/instance.js.map +1 -1
- package/dist/runtime/integrations.js +14 -6
- package/dist/runtime/integrations.js.map +1 -1
- package/dist/runtime/loader.js +28 -4
- package/dist/runtime/loader.js.map +1 -1
- package/dist/runtime/migration-context.d.ts +25 -0
- package/dist/runtime/migration-context.js +69 -0
- package/dist/runtime/migration-context.js.map +1 -0
- package/dist/runtime/outbox.d.ts +6 -82
- package/dist/runtime/outbox.js +14 -59
- package/dist/runtime/outbox.js.map +1 -1
- package/dist/runtime/readiness.js +18 -1
- package/dist/runtime/readiness.js.map +1 -1
- package/dist/runtime/runtime.d.ts +84 -8
- package/dist/runtime/runtime.js +372 -131
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/services.d.ts +41 -5
- package/dist/runtime/services.js +49 -4
- package/dist/runtime/services.js.map +1 -1
- package/dist/runtime/sessions.js +4 -3
- package/dist/runtime/sessions.js.map +1 -1
- package/dist/runtime/state-contract.d.ts +167 -0
- package/dist/runtime/state-contract.js +438 -0
- package/dist/runtime/state-contract.js.map +1 -0
- package/dist/runtime/transactions.d.ts +199 -0
- package/dist/runtime/transactions.js +246 -0
- package/dist/runtime/transactions.js.map +1 -0
- package/dist/schema.d.ts +13 -1
- package/dist/schema.js +21 -2
- package/dist/schema.js.map +1 -1
- package/dist/server/admin.d.ts +3 -2
- package/dist/server/admin.js +62 -10
- package/dist/server/admin.js.map +1 -1
- package/dist/server/index.d.ts +6 -1
- package/dist/server/index.js +90 -9
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp.js +1 -1
- package/dist/server/mcp.js.map +1 -1
- package/dist/server/project.d.ts +5 -0
- package/dist/server/project.js +13 -2
- package/dist/server/project.js.map +1 -1
- package/dist/testing/index.d.ts +10 -3
- package/dist/testing/index.js +33 -7
- package/dist/testing/index.js.map +1 -1
- package/docs/AGENT-OPERATIONS.md +515 -0
- package/docs/APPBOUNDRY.md +240 -0
- package/docs/ARCHITECTURE.md +126 -0
- package/docs/BACKUP.md +115 -0
- package/docs/GUARANTEES.md +457 -0
- package/docs/PATH-TO-PRODUCTION.md +117 -0
- package/docs/README.md +15 -0
- package/docs/SECURITY.md +182 -0
- package/docs/TRANSACTIONS.md +216 -0
- package/docs/UPSTREAM-GAPS.md +270 -0
- package/docs/WHY-FELTKIT.md +64 -0
- package/docs/assets/feltkit-logo-dark.png +0 -0
- package/docs/assets/feltkit-logo.png +0 -0
- package/package.json +10 -8
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +3 -3
- package/skills/feltkit-agent/SKILL.md +9 -5
- package/skills/feltkit-build/SKILL.md +16 -4
- package/skills/feltkit-data/SKILL.md +20 -3
- package/skills/feltkit-services/SKILL.md +13 -7
- package/dist/dashboard/assets/index-BhFOquA7.js +0 -15
- package/dist/dashboard/theme.js +0 -11
|
@@ -23,6 +23,17 @@ export const contacts = app.collection("contacts", {
|
|
|
23
23
|
|
|
24
24
|
Records carry `id` and `__version` (FeltDB's). Do not declare either. Writes are validated against the shape.
|
|
25
25
|
|
|
26
|
+
FeltDB enforces the schema the collections compile to (types, required fields, no undeclared fields).
|
|
27
|
+
|
|
28
|
+
- **References and constraints.** Declare a reference with `s.ref(otherCollection)`: it must
|
|
29
|
+
name an existing record, and a referenced record cannot be deleted. Declare uniqueness and
|
|
30
|
+
indexes in the third argument: `app.collection("contacts", {...}, { unique: [["email"]], indexes: [{ fields: ["stage"] }] })`.
|
|
31
|
+
- **Changing a collection.** Adding an optional field is installed by itself. A required
|
|
32
|
+
field, a type change, a removed field or a removed populated collection needs an
|
|
33
|
+
`app.migration("name", (m) => m.update(contacts, (c) => ({ ...c, newField: value })))`.
|
|
34
|
+
`npx feltkit migrate --dry-run` shows the plan and the records that would fail. Never edit
|
|
35
|
+
or rename a migration that ran.
|
|
36
|
+
|
|
26
37
|
## Read
|
|
27
38
|
|
|
28
39
|
```ts
|
|
@@ -33,6 +44,9 @@ const page = await ctx.db.query(contacts, { where: [{ field: "stage", eq: "lead"
|
|
|
33
44
|
// page.records, page.nextCursor, page.exhausted
|
|
34
45
|
```
|
|
35
46
|
|
|
47
|
+
`find` returns **every** match unless you pass `limit` (FeltKit reads FeltDB's pages for you), and `count`
|
|
48
|
+
counts every match. `query` returns **one page** of at most 1,000 records: follow `nextCursor` until it
|
|
49
|
+
is absent. For a large collection, page with `query` on a request path rather than `find` everything.
|
|
36
50
|
`where` clauses support `eq`, `neq`, `lt`, `lte`, `gt`, `gte`. Queries are read-only and live in the client
|
|
37
51
|
(`useQuery` re-runs when their data changes).
|
|
38
52
|
|
|
@@ -48,13 +62,16 @@ await ctx.db.delete(contacts, id);
|
|
|
48
62
|
A mutation's writes are buffered and commit as **one FeltDB transaction** when the handler returns; if it throws,
|
|
49
63
|
nothing is written.
|
|
50
64
|
|
|
65
|
+
Records `ctx.db` returns are your own copies: change them freely; nothing is stored until you `patch` or `replace`.
|
|
66
|
+
|
|
51
67
|
## Consistency: what is guaranteed
|
|
52
68
|
|
|
53
69
|
- **Atomic**: all of a mutation's writes, or none.
|
|
54
70
|
- **Checked reads**: everything a mutation read — by id, by equality filter (including records that would newly
|
|
55
71
|
match: phantoms), by range (conservatively), and whole collections — is checked at commit. If any of it changed,
|
|
56
|
-
the commit fails with `CONFLICT` and nothing is written. Retry the mutation; do not retry
|
|
57
|
-
without a bound.
|
|
72
|
+
the commit fails with `CONFLICT` and `retryable: true`, and nothing is written. Retry the mutation; do not retry
|
|
73
|
+
blindly in a loop without a bound. A `CONFLICT` without `retryable` (a duplicate unique value, "already applied")
|
|
74
|
+
fails the same way again: do not retry it.
|
|
58
75
|
- **Not guaranteed**: a consistent snapshot *while* a handler runs; checks for read-only mutations; fences against
|
|
59
76
|
writes made through `ctx.unsafe.feltdb`.
|
|
60
77
|
- Service effects (`ctx.services.*`) commit separately from the mutation.
|
|
@@ -76,4 +93,4 @@ Deleting records, bulk changes, schema changes that drop fields, or anything in
|
|
|
76
93
|
|
|
77
94
|
## Compatibility
|
|
78
95
|
|
|
79
|
-
`@feltdb/feltkit` 0.3.x on `@feltdb/core` 0.
|
|
96
|
+
`@feltdb/feltkit` 0.3.x on `@feltdb/core` 0.21.0. Details: `npx feltkit docs guarantees` (node_modules/@feltdb/feltkit/docs/GUARANTEES.md). Verified in Claude Code only.
|
|
@@ -39,15 +39,19 @@ export const checkout = app.mutation({
|
|
|
39
39
|
access: "orders.write",
|
|
40
40
|
args: { orderId: s.string() },
|
|
41
41
|
handler: async (ctx, { orderId }) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
ctx.afterCommit.jobs.enqueue("invoice.send", { orderId }); // runs later, as this caller, if this commits
|
|
43
|
+
ctx.afterCommit.webhooks.emit("order.paid", { orderId }); // to subscribed endpoints, if this commits
|
|
44
|
+
ctx.afterCommit.notifications.send({ recipient: "ada", type: "order", title: "Paid" });
|
|
45
45
|
const region = await ctx.services.configuration.get("REGION");
|
|
46
46
|
return { region };
|
|
47
47
|
},
|
|
48
48
|
});
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
**Jobs run as whoever queued them, re-authorized each attempt:** that principal needs `jobs.create` to queue and
|
|
52
|
+
`jobs.execute` for the run, plus the job mutation's own `access`. In tests, `t.as(...)` callers are signed in like
|
|
53
|
+
production callers; `runServices()` returns `failed: { jobs, deliveries }` beside the attempt counts.
|
|
54
|
+
|
|
51
55
|
**Service calls inside functions run as the caller.** Every role that can reach a function needs the service
|
|
52
56
|
permissions that function uses: if `checkout` reads `configuration.get`, every role that calls `checkout` needs
|
|
53
57
|
`configuration.read`. A refusal says so: `orders:checkout called configuration.get as grace (roles: clerk), which does
|
|
@@ -64,9 +68,11 @@ ctx.afterCommit.jobs.enqueue("invoice.send", { orderId });
|
|
|
64
68
|
```
|
|
65
69
|
|
|
66
70
|
Each is recorded in the mutation's transaction (`_feltkit_outbox`) and performed after the commit, as the caller.
|
|
67
|
-
If the process stops in between, the services worker performs it later
|
|
68
|
-
|
|
69
|
-
`
|
|
71
|
+
If the process stops in between, the services worker performs it later. A job or webhook delivery is created in
|
|
72
|
+
the transaction that marks the effect done, so it exists once per committed effect; notifications are deduplicated
|
|
73
|
+
by their idempotency key. Running the job and delivering the webhook are retried by the services (at least once). A failed effect stays `failed` with
|
|
74
|
+
its error until an operator retries it: `npx feltkit outbox list --state failed`, `npx feltkit outbox retry <id>`.
|
|
75
|
+
The same holds in an AppBoundry artifact (AppBoundry 1.5.0 or later).
|
|
70
76
|
|
|
71
77
|
## Configure a service
|
|
72
78
|
|
|
@@ -137,6 +143,6 @@ affect other systems. Confirm with the user before doing any of them.
|
|
|
137
143
|
|
|
138
144
|
## Compatibility
|
|
139
145
|
|
|
140
|
-
`@feltdb/feltkit` 0.3.x with `@appport/services` 0.13.
|
|
146
|
+
`@feltdb/feltkit` 0.3.x with `@appport/services` 0.13.1 (shared instance; transactional job and webhook creation; `credential.store` / `credential.status`; `servicesContract` for Managed FeltDB).
|
|
141
147
|
The console is development-only.
|
|
142
148
|
Verified in Claude Code only.
|