@plumbus/core 0.6.7 → 0.6.9
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/CHANGELOG.md +28 -0
- package/README.md +1 -11
- package/dist/.tsbuildinfo +1 -1
- package/dist/ai/types/enums.d.ts +1 -0
- package/dist/api/authentication-http.d.ts +17 -0
- package/dist/api/authentication-http.d.ts.map +1 -0
- package/dist/api/authentication-http.js +51 -0
- package/dist/api/authentication-http.js.map +1 -0
- package/dist/api/cookies.d.ts +2 -0
- package/dist/api/cookies.d.ts.map +1 -0
- package/dist/api/cookies.js +29 -0
- package/dist/api/cookies.js.map +1 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/route-generator.d.ts +3 -0
- package/dist/api/route-generator.d.ts.map +1 -1
- package/dist/api/route-generator.js +107 -19
- package/dist/api/route-generator.js.map +1 -1
- package/dist/audit/index.d.ts +1 -0
- package/dist/audit/index.d.ts.map +1 -1
- package/dist/audit/index.js +1 -0
- package/dist/audit/index.js.map +1 -1
- package/dist/audit/service.d.ts +2 -1
- package/dist/audit/service.d.ts.map +1 -1
- package/dist/audit/service.js +7 -6
- package/dist/audit/service.js.map +1 -1
- package/dist/audit/writer.d.ts +4 -0
- package/dist/audit/writer.d.ts.map +1 -0
- package/dist/audit/writer.js +17 -0
- package/dist/audit/writer.js.map +1 -0
- package/dist/auth/http-authentication.d.ts +33 -0
- package/dist/auth/http-authentication.d.ts.map +1 -0
- package/dist/auth/http-authentication.js +37 -0
- package/dist/auth/http-authentication.js.map +1 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +1 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/cli/commands/init.d.ts +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +64 -2
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/migrate.js +3 -3
- package/dist/cli/commands/migrate.js.map +1 -1
- package/dist/cli/commands/ui.d.ts +5 -0
- package/dist/cli/commands/ui.d.ts.map +1 -1
- package/dist/cli/commands/ui.js +26 -3
- package/dist/cli/commands/ui.js.map +1 -1
- package/dist/cli/discover.d.ts +1 -0
- package/dist/cli/discover.d.ts.map +1 -1
- package/dist/cli/discover.js +34 -1
- package/dist/cli/discover.js.map +1 -1
- package/dist/config/duration.d.ts +4 -0
- package/dist/config/duration.d.ts.map +1 -0
- package/dist/config/duration.js +22 -0
- package/dist/config/duration.js.map +1 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +6 -1
- package/dist/config/loader.js.map +1 -1
- package/dist/data/migration.d.ts +1 -1
- package/dist/data/migration.d.ts.map +1 -1
- package/dist/data/migration.js +31 -2
- package/dist/data/migration.js.map +1 -1
- package/dist/data/repository.d.ts.map +1 -1
- package/dist/data/repository.js +103 -1
- package/dist/data/repository.js.map +1 -1
- package/dist/errors/http.d.ts.map +1 -1
- package/dist/errors/http.js +1 -0
- package/dist/errors/http.js.map +1 -1
- package/dist/errors/index.d.ts +3 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +6 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/flows/engine.d.ts.map +1 -1
- package/dist/flows/engine.js +2 -22
- package/dist/flows/engine.js.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/jobs/routes.d.ts +2 -0
- package/dist/jobs/routes.d.ts.map +1 -1
- package/dist/jobs/routes.js +36 -5
- package/dist/jobs/routes.js.map +1 -1
- package/dist/server/authentication-runtime.d.ts +14 -0
- package/dist/server/authentication-runtime.d.ts.map +1 -0
- package/dist/server/authentication-runtime.js +2 -0
- package/dist/server/authentication-runtime.js.map +1 -0
- package/dist/server/bootstrap.d.ts +3 -0
- package/dist/server/bootstrap.d.ts.map +1 -1
- package/dist/server/bootstrap.js +45 -14
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/testing/context.d.ts.map +1 -1
- package/dist/testing/context.js +113 -0
- package/dist/testing/context.js.map +1 -1
- package/dist/testing/e2e.d.ts +3 -0
- package/dist/testing/e2e.d.ts.map +1 -1
- package/dist/testing/e2e.js +1 -0
- package/dist/testing/e2e.js.map +1 -1
- package/dist/types/audit.d.ts +13 -0
- package/dist/types/audit.d.ts.map +1 -1
- package/dist/types/context.d.ts +61 -0
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/enums.d.ts +1 -0
- package/dist/types/enums.d.ts.map +1 -1
- package/dist/types/enums.js +1 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/security.d.ts +2 -0
- package/dist/types/security.d.ts.map +1 -1
- package/instructions/capabilities.md +8 -1
- package/instructions/entities.md +25 -0
- package/instructions/peer-dependencies.md +4 -1
- package/instructions/security.md +2 -0
- package/instructions/testing.md +29 -0
- package/package.json +2 -2
package/instructions/entities.md
CHANGED
|
@@ -107,6 +107,31 @@ const total = await ctx.data.User.count({ active: true }, filters);
|
|
|
107
107
|
|
|
108
108
|
`findMany` applies `limit`/`offset`/`orderBy`; `count` returns the matching row count over the same filters (so page totals stay correct). `search` uses case-insensitive `ILIKE` (OR across columns), `in` is SQL `IN`, `notEq` is `<>`. Multi-column sort: `orderBy: [{ column: "name", dir: "asc" }, { column: "createdAt", dir: "desc" }]`. Tenant isolation and soft-delete filters are applied automatically.
|
|
109
109
|
|
|
110
|
+
### Aggregates (SUM / GROUP BY / DISTINCT)
|
|
111
|
+
|
|
112
|
+
To total, average, or group **in the database** — instead of loading rows and reducing in memory — use `aggregate`. Filtering is identical to `findMany`/`count` (the `query` equality arg plus `dateFilters`/`search`/`in`/`notEq`), and tenant scoping, soft-delete, and encrypted-field guards all apply.
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
// Grand total over a filtered scope — one row, even over zero matches:
|
|
116
|
+
const [totals] = await ctx.data.ProjectCostLedger.aggregate(
|
|
117
|
+
{ projectId },
|
|
118
|
+
{ dateFilters: { recordedAt: { gte: monthStart } }, sum: "cost", count: true },
|
|
119
|
+
);
|
|
120
|
+
totals.sum_cost; // number (empty scope = 0); totals.count // number
|
|
121
|
+
|
|
122
|
+
// GROUP BY with per-group aggregates, ordered by an aggregate, limited:
|
|
123
|
+
const byProvider = await ctx.data.ProjectCostLedger.aggregate(
|
|
124
|
+
{},
|
|
125
|
+
{ groupBy: "provider", sum: "cost", count: true, orderBy: "sum_cost", orderDir: "desc", limit: 10 },
|
|
126
|
+
);
|
|
127
|
+
// → [{ provider: "openai", sum_cost: 41.2, count: 318 }, ...]
|
|
128
|
+
|
|
129
|
+
// COUNT(DISTINCT), min/max/avg also supported:
|
|
130
|
+
await ctx.data.WorkflowStep.aggregate({}, { countDistinct: "projectId" }); // [{ countDistinct_projectId: 7 }]
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Result rows (`AggregateRow`) key each `groupBy` column by its value, plus `count` (when `count: true`), `sum_<col>`, `avg_<col>`, `min_<col>`, `max_<col>`, and `countDistinct_<col>` per requested column. `sum_*`, `count`, and `countDistinct_*` are numbers (an empty `SUM` is `0`, not `null`); `avg_*`/`min_*`/`max_*` are `null` over an empty set. Without `groupBy` you always get exactly one grand-total row; with `groupBy`, one row per group that has matching records. `orderBy` may reference a group column or an aggregate alias (e.g. `"sum_cost"`); `limit` is clamped to 1–1000. Requesting neither a group column nor an aggregate throws. Aggregating an `encrypted: true` field is rejected. Add a matching composite index (e.g. `indexes: [["projectId", "recordedAt"]]`) so the aggregate runs as an index scan.
|
|
134
|
+
|
|
110
135
|
Repositories automatically:
|
|
111
136
|
- Inject `tenantId` from `ctx.auth.tenantId` (if `tenantScoped: true`)
|
|
112
137
|
- Record audit events for mutations
|
|
@@ -15,6 +15,7 @@ Read this file **before** editing `peerDependencies` in any `packages/*/package.
|
|
|
15
15
|
|---|---|---|
|
|
16
16
|
| Most add-ons (chat, chat-ui, knowledge-base, mcp, api, browser-extension) | `"0.5.x \|\| 0.6.x"` | `packages/mcp/package.json` |
|
|
17
17
|
| Voice only (requires core 0.6+ media/cost APIs) | `"0.6.x"` | `packages/voice/package.json` |
|
|
18
|
+
| Auth only (requires core 0.6.8+ HttpAuthenticationRuntime) | `"0.6.x"` | `packages/auth/package.json` |
|
|
18
19
|
|
|
19
20
|
When adding a **new** publishable add-on under `packages/`, use `"0.5.x || 0.6.x"` unless the package genuinely requires core 0.6+ only (then use the voice pattern).
|
|
20
21
|
|
|
@@ -27,8 +28,10 @@ When adding a **new** publishable add-on under `packages/`, use `"0.5.x || 0.6.x
|
|
|
27
28
|
| `@plumbus/chat` | `@plumbus/knowledge-base` | `"^0.1.0"` | optional | `packages/chat/package.json` |
|
|
28
29
|
| `@plumbus/chat-ui` | `@plumbus/chat` | `"0.1.x"` | required | `packages/chat-ui/package.json` |
|
|
29
30
|
| `@plumbus/chat-ui` | `@plumbus/core` | `"0.5.x \|\| 0.6.x"` | required | `packages/chat-ui/package.json` |
|
|
31
|
+
| `@plumbus/auth` | `@plumbus/core` | `"0.6.x"` | required | `packages/auth/package.json` |
|
|
32
|
+
| `@plumbus/auth-cognito` | `@plumbus/auth` | `"0.1.x"` | required | `packages/auth-cognito/package.json` |
|
|
30
33
|
|
|
31
|
-
**Peering direction:** add-ons declare `@plumbus/core` as a peer — consumer apps install both. `@plumbus/core` optionally peers `@plumbus/mcp` and `@plumbus/api` when those packages are present. `@plumbus/chat` optionally peers `@plumbus/knowledge-base` for registry-backed context sources — **not** the reverse. `@plumbus/knowledge-base` only peers `@plumbus/core`.
|
|
34
|
+
**Peering direction:** add-ons declare `@plumbus/core` as a peer — consumer apps install both. `@plumbus/core` optionally peers `@plumbus/mcp` and `@plumbus/api` when those packages are present. `@plumbus/chat` optionally peers `@plumbus/knowledge-base` for registry-backed context sources — **not** the reverse. `@plumbus/knowledge-base` only peers `@plumbus/core`. `@plumbus/auth-cognito` peers `@plumbus/auth` only — not `@plumbus/core` directly.
|
|
32
35
|
|
|
33
36
|
## Forbidden patterns
|
|
34
37
|
|
package/instructions/security.md
CHANGED
|
@@ -64,6 +64,8 @@ Entity fields with `classification: "sensitive"` or `"highly_sensitive"`:
|
|
|
64
64
|
- Trigger governance warnings if used in AI prompts
|
|
65
65
|
- Can be flagged for encryption at rest (`encrypted: true` + `PLUMBUS_ENCRYPTION_KEY`)
|
|
66
66
|
|
|
67
|
+
When encryption is enabled, repositories reject `findMany`/`aggregate` filters and aggregate functions on encrypted string columns (ciphertext is not queryable at the SQL layer). See [entities.md](./entities.md#aggregates-sum--group-by--distinct).
|
|
68
|
+
|
|
67
69
|
**AI prompt scanning** is separate and **opt-in**: configure `aiProviders.security` (or `AI_SECURITY_*` env) to warn/redact/block classified fields in `ctx.ai.*` inputs. Without that config, classification alone does not scan prompts. See `ai.md` § Security.
|
|
68
70
|
|
|
69
71
|
### Edit Zones
|
package/instructions/testing.md
CHANGED
|
@@ -47,6 +47,35 @@ expect(page1.data.items).not.toEqual(page2.data.items);
|
|
|
47
47
|
expect(page1.data.total).toBeGreaterThan(page1.data.limit);
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
### Aggregate / dashboard capabilities
|
|
51
|
+
|
|
52
|
+
When testing capabilities that call `aggregate()` (totals, grouped rollups, `COUNT(DISTINCT)`), use `createTestContext()` or `createInMemoryRepository()` — both mirror production aggregate semantics without a database:
|
|
53
|
+
|
|
54
|
+
- Assert **grand totals** return a single row (even over an empty filter scope, where `SUM` is `0`)
|
|
55
|
+
- Assert **GROUP BY** returns one row per group with the expected `sum_*` / `count` / `countDistinct_*` keys
|
|
56
|
+
- Assert **filters** (`query`, `dateFilters`, `search`, `in`, `notEq`) narrow the scope the same way as `findMany`/`count`
|
|
57
|
+
- Assert **empty scope** for grouped queries returns no rows; ungrouped empty scope returns `[{ sum_*: 0, count: 0 }]`
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const ctx = createTestContext({
|
|
61
|
+
data: {
|
|
62
|
+
Ledger: [
|
|
63
|
+
{ id: "1", provider: "openai", cost: 1.5 },
|
|
64
|
+
{ id: "2", provider: "openai", cost: 2.5 },
|
|
65
|
+
{ id: "3", provider: "anthropic", cost: 3 },
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const rows = await ctx.data.Ledger.aggregate(
|
|
71
|
+
{ provider: "openai" },
|
|
72
|
+
{ sum: "cost", count: true },
|
|
73
|
+
);
|
|
74
|
+
expect(rows).toEqual([{ sum_cost: 4, count: 2 }]);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
See [entities.md](./entities.md#aggregates-sum--group-by--distinct) for result shape and guards.
|
|
78
|
+
|
|
50
79
|
### `simulateFlow`
|
|
51
80
|
|
|
52
81
|
Simulate flow execution and inspect step history:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumbus/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
4
4
|
"description": "Plumbus framework core — types, SDK, runtime, CLI, test utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"@vitest/browser": "^3.0.0",
|
|
96
96
|
"esbuild": "^0.25.12",
|
|
97
97
|
"typescript": "^5.7.0",
|
|
98
|
-
"@plumbus/api": "0.1.
|
|
98
|
+
"@plumbus/api": "0.1.3",
|
|
99
99
|
"@plumbus/mcp": "0.5.1",
|
|
100
100
|
"@plumbus/voice": "0.3.0"
|
|
101
101
|
},
|