@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.
Files changed (146) hide show
  1. package/README.md +4 -3
  2. package/dist/app.d.ts +98 -3
  3. package/dist/app.js +63 -0
  4. package/dist/app.js.map +1 -1
  5. package/dist/appboundry/build.d.ts +39 -1
  6. package/dist/appboundry/build.js +57 -6
  7. package/dist/appboundry/build.js.map +1 -1
  8. package/dist/appboundry/guest.js +46 -5
  9. package/dist/appboundry/guest.js.map +1 -1
  10. package/dist/appboundry/host.d.ts +24 -5
  11. package/dist/appboundry/host.js +234 -141
  12. package/dist/appboundry/host.js.map +1 -1
  13. package/dist/appboundry/runtime.d.ts +44 -0
  14. package/dist/appboundry/runtime.js +99 -0
  15. package/dist/appboundry/runtime.js.map +1 -0
  16. package/dist/cli/entry.d.ts +1 -0
  17. package/dist/cli/entry.js +4 -0
  18. package/dist/cli/entry.js.map +1 -0
  19. package/dist/cli/main.d.ts +5 -0
  20. package/dist/cli/main.js +550 -13
  21. package/dist/cli/main.js.map +1 -1
  22. package/dist/cli/test-reporter.d.ts +9 -0
  23. package/dist/cli/test-reporter.js +26 -0
  24. package/dist/cli/test-reporter.js.map +1 -0
  25. package/dist/client/index.d.ts +3 -0
  26. package/dist/client/index.js +3 -0
  27. package/dist/client/index.js.map +1 -1
  28. package/dist/dashboard/assets/index-BSnW2DC-.js +15 -0
  29. package/dist/dashboard/assets/{index-91I1zDK-.css → index-BXTNQAg1.css} +1 -1
  30. package/dist/dashboard/index.html +3 -3
  31. package/dist/docs.d.ts +12 -0
  32. package/dist/docs.js +42 -0
  33. package/dist/docs.js.map +1 -0
  34. package/dist/errors.d.ts +15 -0
  35. package/dist/errors.js +9 -0
  36. package/dist/errors.js.map +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/platform/changes.d.ts +340 -0
  40. package/dist/platform/changes.js +355 -0
  41. package/dist/platform/changes.js.map +1 -0
  42. package/dist/platform/deployments.d.ts +653 -0
  43. package/dist/platform/deployments.js +532 -0
  44. package/dist/platform/deployments.js.map +1 -0
  45. package/dist/platform/operations.d.ts +74 -0
  46. package/dist/platform/operations.js +198 -0
  47. package/dist/platform/operations.js.map +1 -0
  48. package/dist/platform/platform.d.ts +78 -0
  49. package/dist/platform/platform.js +264 -0
  50. package/dist/platform/platform.js.map +1 -0
  51. package/dist/platform/server.d.ts +25 -0
  52. package/dist/platform/server.js +165 -0
  53. package/dist/platform/server.js.map +1 -0
  54. package/dist/platform/source.d.ts +27 -0
  55. package/dist/platform/source.js +142 -0
  56. package/dist/platform/source.js.map +1 -0
  57. package/dist/runtime/activity.d.ts +25 -0
  58. package/dist/runtime/activity.js +38 -12
  59. package/dist/runtime/activity.js.map +1 -1
  60. package/dist/runtime/agent.d.ts +16 -0
  61. package/dist/runtime/agent.js +92 -28
  62. package/dist/runtime/agent.js.map +1 -1
  63. package/dist/runtime/backup-environment.d.ts +32 -0
  64. package/dist/runtime/backup-environment.js +92 -0
  65. package/dist/runtime/backup-environment.js.map +1 -0
  66. package/dist/runtime/backup.d.ts +129 -0
  67. package/dist/runtime/backup.js +344 -0
  68. package/dist/runtime/backup.js.map +1 -0
  69. package/dist/runtime/capabilities.js +4 -2
  70. package/dist/runtime/capabilities.js.map +1 -1
  71. package/dist/runtime/changes.js +2 -2
  72. package/dist/runtime/changes.js.map +1 -1
  73. package/dist/runtime/contract.js +4 -3
  74. package/dist/runtime/contract.js.map +1 -1
  75. package/dist/runtime/data.d.ts +36 -5
  76. package/dist/runtime/data.js +165 -55
  77. package/dist/runtime/data.js.map +1 -1
  78. package/dist/runtime/decisions.js +2 -1
  79. package/dist/runtime/decisions.js.map +1 -1
  80. package/dist/runtime/instance.js +17 -0
  81. package/dist/runtime/instance.js.map +1 -1
  82. package/dist/runtime/integrations.js +14 -6
  83. package/dist/runtime/integrations.js.map +1 -1
  84. package/dist/runtime/loader.js +28 -4
  85. package/dist/runtime/loader.js.map +1 -1
  86. package/dist/runtime/migration-context.d.ts +25 -0
  87. package/dist/runtime/migration-context.js +69 -0
  88. package/dist/runtime/migration-context.js.map +1 -0
  89. package/dist/runtime/outbox.d.ts +6 -82
  90. package/dist/runtime/outbox.js +14 -59
  91. package/dist/runtime/outbox.js.map +1 -1
  92. package/dist/runtime/readiness.js +18 -1
  93. package/dist/runtime/readiness.js.map +1 -1
  94. package/dist/runtime/runtime.d.ts +84 -8
  95. package/dist/runtime/runtime.js +372 -131
  96. package/dist/runtime/runtime.js.map +1 -1
  97. package/dist/runtime/services.d.ts +41 -5
  98. package/dist/runtime/services.js +49 -4
  99. package/dist/runtime/services.js.map +1 -1
  100. package/dist/runtime/sessions.js +4 -3
  101. package/dist/runtime/sessions.js.map +1 -1
  102. package/dist/runtime/state-contract.d.ts +167 -0
  103. package/dist/runtime/state-contract.js +438 -0
  104. package/dist/runtime/state-contract.js.map +1 -0
  105. package/dist/runtime/transactions.d.ts +199 -0
  106. package/dist/runtime/transactions.js +246 -0
  107. package/dist/runtime/transactions.js.map +1 -0
  108. package/dist/schema.d.ts +13 -1
  109. package/dist/schema.js +21 -2
  110. package/dist/schema.js.map +1 -1
  111. package/dist/server/admin.d.ts +3 -2
  112. package/dist/server/admin.js +62 -10
  113. package/dist/server/admin.js.map +1 -1
  114. package/dist/server/index.d.ts +6 -1
  115. package/dist/server/index.js +90 -9
  116. package/dist/server/index.js.map +1 -1
  117. package/dist/server/mcp.js +1 -1
  118. package/dist/server/mcp.js.map +1 -1
  119. package/dist/server/project.d.ts +5 -0
  120. package/dist/server/project.js +13 -2
  121. package/dist/server/project.js.map +1 -1
  122. package/dist/testing/index.d.ts +10 -3
  123. package/dist/testing/index.js +33 -7
  124. package/dist/testing/index.js.map +1 -1
  125. package/docs/AGENT-OPERATIONS.md +515 -0
  126. package/docs/APPBOUNDRY.md +240 -0
  127. package/docs/ARCHITECTURE.md +126 -0
  128. package/docs/BACKUP.md +115 -0
  129. package/docs/GUARANTEES.md +457 -0
  130. package/docs/PATH-TO-PRODUCTION.md +117 -0
  131. package/docs/README.md +15 -0
  132. package/docs/SECURITY.md +182 -0
  133. package/docs/TRANSACTIONS.md +216 -0
  134. package/docs/UPSTREAM-GAPS.md +270 -0
  135. package/docs/WHY-FELTKIT.md +64 -0
  136. package/docs/assets/feltkit-logo-dark.png +0 -0
  137. package/docs/assets/feltkit-logo.png +0 -0
  138. package/package.json +10 -8
  139. package/skills/.claude-plugin/marketplace.json +1 -1
  140. package/skills/.claude-plugin/plugin.json +3 -3
  141. package/skills/feltkit-agent/SKILL.md +9 -5
  142. package/skills/feltkit-build/SKILL.md +16 -4
  143. package/skills/feltkit-data/SKILL.md +20 -3
  144. package/skills/feltkit-services/SKILL.md +13 -7
  145. package/dist/dashboard/assets/index-BhFOquA7.js +0 -15
  146. 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 blindly in a loop
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.18.0. Details: the project's `docs/GUARANTEES.md`. Verified in Claude Code only.
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
- await ctx.services.jobs.enqueue("invoice.send", { orderId }); // runs later, as this caller
43
- await ctx.services.webhooks.emit("order.paid", { orderId }); // to subscribed endpoints
44
- await ctx.services.notifications.send({ recipient: "ada", type: "order", title: "Paid" });
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 (at least once; notifications are
68
- deduplicated by their idempotency key, jobs and webhook events may repeat). An AppBoundry artifact refuses
69
- `ctx.afterCommit`.
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.0 (shared instance; `credential.store` / `credential.status`; `servicesContract` for Managed FeltDB).
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.