@jxsuite/connector 0.5.7 → 0.6.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/README.md +13 -38
- package/package.json +6 -6
- package/src/Connections.class.json +1 -1
- package/src/Data.class.json +1 -1
- package/src/worker.ts +3 -4
package/README.md
CHANGED
|
@@ -4,21 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
`@jxsuite/connector` is the Jx extension bridging sites to live databases. It contributes two
|
|
8
|
-
|
|
9
|
-
(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
locally and the platform secret store in production. Providers: Cloudflare **D1**, **Supabase**
|
|
14
|
-
(postgres over postgres-js/Hyperdrive), and file-backed **Sqlite** (bun:sqlite).
|
|
15
|
-
- **`data`**: dynamic tables. Each entry names its connection, a column `schema` (plain Jx field
|
|
16
|
-
schemas plus relationship refs; see specs/relationships.md), an `id` strategy
|
|
17
|
-
(`"uuid"` | `"integer"`), `timestamps`, `indexes`, `permissions`
|
|
18
|
-
(`public | none | authenticated | owner | role:<r>`), and an optional `ownerField`.
|
|
19
|
-
|
|
20
|
-
Kysely is the data bridge: one JSON-drivable query/schema builder across D1, postgres, and
|
|
21
|
-
sqlite, on Workers, Bun, and node.
|
|
7
|
+
`@jxsuite/connector` is the Jx extension bridging sites to live databases. It contributes two project.json sections and serves them over the canonical `/_jx/data` wire contract (specs/extensions.md §11 and §12):
|
|
8
|
+
|
|
9
|
+
- **`connections`**: named database connections. Entries carry identifiers and env-var _names_ only (`binding`, `databaseId`, `urlEnv`, `hyperdriveId`); secret values live in `.dev.vars` locally and the platform secret store in production. Providers: Cloudflare **D1**, **Supabase** (postgres over postgres-js/Hyperdrive), and file-backed **Sqlite** (bun:sqlite).
|
|
10
|
+
- **`data`**: dynamic tables. Each entry names its connection, a column `schema` (plain Jx field schemas plus relationship refs; see specs/relationships.md), an `id` strategy (`"uuid"` | `"integer"`), `timestamps`, `indexes`, `permissions` (`public | none | authenticated | owner | role:<r>`), and an optional `ownerField`.
|
|
11
|
+
|
|
12
|
+
Kysely is the data bridge: one JSON-drivable query/schema builder across D1, postgres, and sqlite, on Workers, Bun, and node.
|
|
22
13
|
|
|
23
14
|
## Enable it
|
|
24
15
|
|
|
@@ -40,39 +31,23 @@ sqlite, on Workers, Bun, and node.
|
|
|
40
31
|
}
|
|
41
32
|
```
|
|
42
33
|
|
|
43
|
-
Then `jx schema` (regenerates the project schemas) and `jx db push [--dry-run]` (additive-only
|
|
44
|
-
schema sync: tables and columns are created, never dropped or retyped). In dev, the server
|
|
45
|
-
stands D1 connections in with local SQLite at `.jx/data/<connection>.sqlite`, auto-synced on
|
|
46
|
-
first touch.
|
|
34
|
+
Then `jx schema` (regenerates the project schemas) and `jx db push [--dry-run]` (additive-only schema sync: tables and columns are created, never dropped or retyped). In dev, the server stands D1 connections in with local SQLite at `.jx/data/<connection>.sqlite`, auto-synced on first touch.
|
|
47
35
|
|
|
48
36
|
## State classes
|
|
49
37
|
|
|
50
|
-
- `TableQuery` / `TableEntry`: rows (content filter grammar: `filter`, `sort`, `limit`,
|
|
51
|
-
|
|
52
|
-
- `TableInsert` / `TableUpdate` / `TableDelete`: form-friendly write actions
|
|
53
|
-
(`"onsubmit": { "$ref": "#/state/addComment" }` reads the form's FormData).
|
|
38
|
+
- `TableQuery` / `TableEntry`: rows (content filter grammar: `filter`, `sort`, `limit`, `offset`, `include`) and single rows by id (`#/$params/<name>` refs resolve against the route).
|
|
39
|
+
- `TableInsert` / `TableUpdate` / `TableDelete`: form-friendly write actions (`"onsubmit": { "$ref": "#/state/addComment" }` reads the form's FormData).
|
|
54
40
|
|
|
55
|
-
In compiled sites these **lower** to core defs (specs/extensions.md §8.3): queries become plain
|
|
56
|
-
`Request` fetches against `/_jx/data`, actions become inline `Function` handlers, so no extension
|
|
57
|
-
code ships to the browser. Read-after-write rides the `_v` convention: lowered queries append
|
|
58
|
-
`_v=${(state._v || 0)}` to their URL and successful writes bump `state._v`, re-running every
|
|
59
|
-
query effect on the page.
|
|
41
|
+
In compiled sites these **lower** to core defs (specs/extensions.md §8.3): queries become plain `Request` fetches against `/_jx/data`, actions become inline `Function` handlers, so no extension code ships to the browser. Read-after-write rides the `_v` convention: lowered queries append `_v=${(state._v || 0)}` to their URL and successful writes bump `state._v`, re-running every query effect on the page.
|
|
60
42
|
|
|
61
43
|
## Permissions (fail-closed)
|
|
62
44
|
|
|
63
|
-
`public` rules pass without auth; `none` always denies; every other rule requires the auth
|
|
64
|
-
extension's hooks on the shared server context, so absent auth means 401. Defaults: read `public`,
|
|
65
|
-
writes `none`. Owner rules scope reads/writes via `ownerField`.
|
|
45
|
+
`public` rules pass without auth; `none` always denies; every other rule requires the auth extension's hooks on the shared server context, so absent auth means 401. Defaults: read `public`, writes `none`. Owner rules scope reads/writes via `ownerField`.
|
|
66
46
|
|
|
67
47
|
## Field-union extras
|
|
68
48
|
|
|
69
|
-
Table columns are plain core field schemas plus relationship refs, so this package ships **no**
|
|
70
|
-
`schemas.fields` fragment. That manifest convention (a fragment whose `$defs` members join the
|
|
71
|
-
per-project field union) exists for extensions that need shapes beyond the core union.
|
|
49
|
+
Table columns are plain core field schemas plus relationship refs, so this package ships **no** `schemas.fields` fragment. That manifest convention (a fragment whose `$defs` members join the per-project field union) exists for extensions that need shapes beyond the core union.
|
|
72
50
|
|
|
73
51
|
## Versioning
|
|
74
52
|
|
|
75
|
-
Published to npm as `@jxsuite/connector`, TypeScript source like every `@jxsuite` package,
|
|
76
|
-
following the monorepo's release train. Extensions may depend on core packages
|
|
77
|
-
(`@jxsuite/schema`) but never the reverse; the auth extension builds on this package's
|
|
78
|
-
`resolveDialect` seam and permission types (`@jxsuite/connector/types`).
|
|
53
|
+
Published to npm as `@jxsuite/connector`, TypeScript source like every `@jxsuite` package, following the monorepo's release train. Extensions may depend on core packages (`@jxsuite/schema`) but never the reverse; the auth extension builds on this package's `resolveDialect` seam and permission types (`@jxsuite/connector/types`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/connector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Jx database connections and dynamic data tables served over /_jx/data",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -57,16 +57,16 @@
|
|
|
57
57
|
"upgrade": "bun update --latest && bun install"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@jxsuite/schema": "^2.
|
|
61
|
-
"kysely": "^0.29.
|
|
60
|
+
"@jxsuite/schema": "^2.3.0",
|
|
61
|
+
"kysely": "^0.29.6",
|
|
62
62
|
"kysely-d1": "^0.4.0",
|
|
63
|
-
"kysely-postgres-js": "^
|
|
63
|
+
"kysely-postgres-js": "^5.0.1",
|
|
64
64
|
"postgres": "^3.4.9"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@cloudflare/workers-types": "^5.
|
|
67
|
+
"@cloudflare/workers-types": "^5.20260926.1",
|
|
68
68
|
"ajv": "^8.20.0",
|
|
69
|
-
"hono": "^4.13.
|
|
69
|
+
"hono": "^4.13.10"
|
|
70
70
|
},
|
|
71
71
|
"jx": "./jx-extension.json"
|
|
72
72
|
}
|
package/src/Data.class.json
CHANGED
package/src/worker.ts
CHANGED
|
@@ -551,10 +551,9 @@ async function expandIncludes(
|
|
|
551
551
|
tables,
|
|
552
552
|
kind,
|
|
553
553
|
);
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
554
|
+
// Every row here came off this table's own SELECT, so its `id` (the primary key) is never
|
|
555
|
+
// Null — unlike `rows.map(r => r[spec.column])` above, which reads an optional FK column.
|
|
556
|
+
const rowIds = rows.map((r) => r.id);
|
|
558
557
|
const links = await db
|
|
559
558
|
.selectFrom(junction.table)
|
|
560
559
|
.selectAll()
|