@jxsuite/connector 0.1.0
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 +78 -0
- package/jx-extension.json +20 -0
- package/package.json +72 -0
- package/schemas/project.fragment.schema.json +122 -0
- package/src/Connections.class.json +29 -0
- package/src/D1.class.json +94 -0
- package/src/Data.class.json +106 -0
- package/src/Sqlite.class.json +81 -0
- package/src/Supabase.class.json +81 -0
- package/src/TableDelete.class.json +56 -0
- package/src/TableEntry.class.json +65 -0
- package/src/TableInsert.class.json +59 -0
- package/src/TableQuery.class.json +75 -0
- package/src/TableUpdate.class.json +65 -0
- package/src/columns.ts +292 -0
- package/src/connectors.ts +65 -0
- package/src/d1.ts +64 -0
- package/src/ddl.ts +201 -0
- package/src/dialects/bun-sqlite.ts +130 -0
- package/src/dialects/d1-http.ts +113 -0
- package/src/provider-utils.ts +86 -0
- package/src/query.ts +199 -0
- package/src/sqlite.ts +51 -0
- package/src/supabase.ts +81 -0
- package/src/table-actions.ts +156 -0
- package/src/table-delete.ts +28 -0
- package/src/table-insert.ts +29 -0
- package/src/table-node.ts +111 -0
- package/src/table-shared.ts +131 -0
- package/src/table-state.ts +134 -0
- package/src/table-update.ts +29 -0
- package/src/types.ts +139 -0
- package/src/validate.ts +193 -0
- package/src/worker.ts +612 -0
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# `@jxsuite/connector`
|
|
2
|
+
|
|
3
|
+
> Database connections and dynamic data tables for Jx sites.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@jxsuite/connector` is the Jx extension bridging sites to live databases. It contributes two
|
|
8
|
+
project.json sections and serves them over the canonical `/_jx/data` wire contract
|
|
9
|
+
(specs/extensions.md §11–§12):
|
|
10
|
+
|
|
11
|
+
- **`connections`** — named database connections. Entries carry identifiers and env-var _names_
|
|
12
|
+
only (`binding`, `databaseId`, `urlEnv`, `hyperdriveId`); secret values live in `.dev.vars`
|
|
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.
|
|
22
|
+
|
|
23
|
+
## Enable it
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"extensions": ["@jxsuite/parser", "@jxsuite/connector"],
|
|
28
|
+
"connections": { "main": { "provider": "sqlite" } },
|
|
29
|
+
"data": {
|
|
30
|
+
"comments": {
|
|
31
|
+
"connection": "main",
|
|
32
|
+
"permissions": { "read": "public", "insert": "public" },
|
|
33
|
+
"schema": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"properties": { "message": { "type": "string" } },
|
|
36
|
+
"required": ["message"]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
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.
|
|
47
|
+
|
|
48
|
+
## State classes
|
|
49
|
+
|
|
50
|
+
- `TableQuery` / `TableEntry` — rows (content filter grammar: `filter`, `sort`, `limit`,
|
|
51
|
+
`offset`, `include`) and single rows by id (`#/$params/<name>` refs resolve against the route).
|
|
52
|
+
- `TableInsert` / `TableUpdate` / `TableDelete` — form-friendly write actions
|
|
53
|
+
(`"onsubmit": { "$ref": "#/state/addComment" }` reads the form's FormData).
|
|
54
|
+
|
|
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 — 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.
|
|
60
|
+
|
|
61
|
+
## Permissions (fail-closed)
|
|
62
|
+
|
|
63
|
+
`public` rules pass without auth; `none` always denies; every other rule requires the auth
|
|
64
|
+
extension's hooks on the shared server context — absent auth means 401. Defaults: read `public`,
|
|
65
|
+
writes `none`. Owner rules scope reads/writes via `ownerField`.
|
|
66
|
+
|
|
67
|
+
## Field-union extras
|
|
68
|
+
|
|
69
|
+
Table columns are plain core field schemas plus relationship refs, so this package ships **no**
|
|
70
|
+
`schemas.fields` fragment — the manifest convention (a fragment whose `$defs` members join the
|
|
71
|
+
per-project field union) exists for extensions that need shapes beyond the core union.
|
|
72
|
+
|
|
73
|
+
## Versioning
|
|
74
|
+
|
|
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`).
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jxsuite/connector",
|
|
3
|
+
"title": "Data & Connections",
|
|
4
|
+
"description": "Database connections and dynamic data tables served over /_jx/data",
|
|
5
|
+
"classes": {
|
|
6
|
+
"D1": "./src/D1.class.json",
|
|
7
|
+
"Supabase": "./src/Supabase.class.json",
|
|
8
|
+
"Sqlite": "./src/Sqlite.class.json",
|
|
9
|
+
"Connections": "./src/Connections.class.json",
|
|
10
|
+
"Data": "./src/Data.class.json",
|
|
11
|
+
"TableQuery": "./src/TableQuery.class.json",
|
|
12
|
+
"TableEntry": "./src/TableEntry.class.json",
|
|
13
|
+
"TableInsert": "./src/TableInsert.class.json",
|
|
14
|
+
"TableUpdate": "./src/TableUpdate.class.json",
|
|
15
|
+
"TableDelete": "./src/TableDelete.class.json"
|
|
16
|
+
},
|
|
17
|
+
"schemas": {
|
|
18
|
+
"project": "./schemas/project.fragment.schema.json"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jxsuite/connector",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Jx database connections and dynamic data tables served over /_jx/data",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/jxsuite/jx.git",
|
|
9
|
+
"directory": "extensions/connector"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"src/",
|
|
13
|
+
"jx-extension.json",
|
|
14
|
+
"schemas/"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./src/connectors.ts",
|
|
19
|
+
"./types": "./src/types.ts",
|
|
20
|
+
"./columns": "./src/columns.ts",
|
|
21
|
+
"./ddl": "./src/ddl.ts",
|
|
22
|
+
"./query": "./src/query.ts",
|
|
23
|
+
"./validate": "./src/validate.ts",
|
|
24
|
+
"./worker": "./src/worker.ts",
|
|
25
|
+
"./d1": "./src/d1.ts",
|
|
26
|
+
"./supabase": "./src/supabase.ts",
|
|
27
|
+
"./sqlite": "./src/sqlite.ts",
|
|
28
|
+
"./table-state": "./src/table-state.ts",
|
|
29
|
+
"./table-node": "./src/table-node.ts",
|
|
30
|
+
"./table-shared": "./src/table-shared.ts",
|
|
31
|
+
"./table-actions": "./src/table-actions.ts",
|
|
32
|
+
"./table-insert": "./src/table-insert.ts",
|
|
33
|
+
"./table-update": "./src/table-update.ts",
|
|
34
|
+
"./table-delete": "./src/table-delete.ts",
|
|
35
|
+
"./provider-utils": "./src/provider-utils.ts",
|
|
36
|
+
"./dialects/bun-sqlite": "./src/dialects/bun-sqlite.ts",
|
|
37
|
+
"./dialects/d1-http": "./src/dialects/d1-http.ts",
|
|
38
|
+
"./jx-extension.json": "./jx-extension.json",
|
|
39
|
+
"./schemas/project.fragment.schema.json": "./schemas/project.fragment.schema.json",
|
|
40
|
+
"./D1.class.json": "./src/D1.class.json",
|
|
41
|
+
"./Supabase.class.json": "./src/Supabase.class.json",
|
|
42
|
+
"./Sqlite.class.json": "./src/Sqlite.class.json",
|
|
43
|
+
"./Connections.class.json": "./src/Connections.class.json",
|
|
44
|
+
"./Data.class.json": "./src/Data.class.json",
|
|
45
|
+
"./TableQuery.class.json": "./src/TableQuery.class.json",
|
|
46
|
+
"./TableEntry.class.json": "./src/TableEntry.class.json",
|
|
47
|
+
"./TableInsert.class.json": "./src/TableInsert.class.json",
|
|
48
|
+
"./TableUpdate.class.json": "./src/TableUpdate.class.json",
|
|
49
|
+
"./TableDelete.class.json": "./src/TableDelete.class.json"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"provenance": false
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"test": "bun test --isolate",
|
|
56
|
+
"test:coverage": "bun test --isolate --coverage",
|
|
57
|
+
"upgrade": "bunx npm-check-updates -u && bun install"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@jxsuite/schema": "workspace:^",
|
|
61
|
+
"kysely": "^0.28.17",
|
|
62
|
+
"kysely-d1": "^0.4.0",
|
|
63
|
+
"kysely-postgres-js": "^3.0.0",
|
|
64
|
+
"postgres": "^3.4.9"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@cloudflare/workers-types": "^5.20260711.1",
|
|
68
|
+
"ajv": "^8.20.0",
|
|
69
|
+
"hono": "^4.11.3"
|
|
70
|
+
},
|
|
71
|
+
"jx": "./jx-extension.json"
|
|
72
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "https://jxsuite.com/schema/ext/connector/project/v1",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"title": "Connector project fragment",
|
|
5
|
+
"description": "Project-schema fragment contributed by @jxsuite/connector: the `connections` section naming database connections (identifiers only — secret values never enter project.json) and the `data` section declaring dynamic tables served over /_jx/data.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"connections": {
|
|
9
|
+
"description": "Named database connections. Entries carry identifiers and env-var NAMES only; secret values live in .dev.vars locally and the platform secret store in production (specs/extensions.md §13).",
|
|
10
|
+
"type": "object",
|
|
11
|
+
"additionalProperties": {
|
|
12
|
+
"description": "Connection definition. `provider` names a connector class provider id from an enabled extension (\"d1\", \"supabase\", \"sqlite\").",
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"provider": {
|
|
16
|
+
"description": "Connector provider id (the `connector.provider` of an enabled connector class).",
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
"binding": {
|
|
20
|
+
"description": "Cloudflare binding name for this connection (D1 database binding, or the Hyperdrive binding for postgres providers).",
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"databaseId": {
|
|
24
|
+
"description": "Cloudflare D1 database UUID (identifier, not a secret).",
|
|
25
|
+
"type": "string"
|
|
26
|
+
},
|
|
27
|
+
"accountId": {
|
|
28
|
+
"description": "Cloudflare account id for HTTP-API access (falls back to the CLOUDFLARE_ACCOUNT_ID env var).",
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"urlEnv": {
|
|
32
|
+
"description": "NAME of the env var holding the postgres connection URL (e.g. \"SUPABASE_DB_URL\"). The value itself is a secret and never enters project.json.",
|
|
33
|
+
"type": "string"
|
|
34
|
+
},
|
|
35
|
+
"hyperdriveId": {
|
|
36
|
+
"description": "Cloudflare Hyperdrive configuration id fronting a postgres connection from Workers.",
|
|
37
|
+
"type": "string"
|
|
38
|
+
},
|
|
39
|
+
"file": {
|
|
40
|
+
"description": "SQLite database file path relative to the project root (defaults to ./.jx/data/<name>.sqlite).",
|
|
41
|
+
"type": "string"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"required": ["provider"]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"data": {
|
|
48
|
+
"description": "Dynamic data tables. Each key names a table served at /_jx/data/<name>; rows live in the named connection's database. Schema sync is additive-only (`jx db push`).",
|
|
49
|
+
"type": "object",
|
|
50
|
+
"additionalProperties": {
|
|
51
|
+
"description": "Table definition: connection, column schema, id strategy, and permissions.",
|
|
52
|
+
"type": "object",
|
|
53
|
+
"properties": {
|
|
54
|
+
"connection": {
|
|
55
|
+
"description": "Name of a `connections` entry this table lives in.",
|
|
56
|
+
"type": "string"
|
|
57
|
+
},
|
|
58
|
+
"schema": {
|
|
59
|
+
"description": "Column schema. `properties` values are field schemas from the effective project field union (relationship refs included).",
|
|
60
|
+
"type": "object",
|
|
61
|
+
"properties": {
|
|
62
|
+
"type": { "const": "object" },
|
|
63
|
+
"properties": {
|
|
64
|
+
"description": "Column definitions; values are field schemas from the effective project field union.",
|
|
65
|
+
"type": "object",
|
|
66
|
+
"additionalProperties": { "$ref": "https://jxsuite.com/schema/project/fields/v2" }
|
|
67
|
+
},
|
|
68
|
+
"required": {
|
|
69
|
+
"description": "Columns every row must provide on insert.",
|
|
70
|
+
"type": "array",
|
|
71
|
+
"items": { "type": "string" }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"id": {
|
|
76
|
+
"description": "Primary-key strategy: \"uuid\" (text ids via crypto.randomUUID) or \"integer\" (auto-increment).",
|
|
77
|
+
"enum": ["uuid", "integer"],
|
|
78
|
+
"default": "uuid"
|
|
79
|
+
},
|
|
80
|
+
"timestamps": {
|
|
81
|
+
"description": "Maintain created_at / updated_at columns (ISO 8601 strings set by the data mount).",
|
|
82
|
+
"type": "boolean",
|
|
83
|
+
"default": true
|
|
84
|
+
},
|
|
85
|
+
"indexes": {
|
|
86
|
+
"description": "Secondary indexes: a column name, or an array of column names for a composite index.",
|
|
87
|
+
"type": "array",
|
|
88
|
+
"items": {
|
|
89
|
+
"oneOf": [
|
|
90
|
+
{ "type": "string" },
|
|
91
|
+
{ "type": "array", "items": { "type": "string" }, "minItems": 1 }
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"permissions": {
|
|
96
|
+
"description": "Per-action access rules. Defaults: read \"public\", writes \"none\". Rules beyond \"public\" require the auth extension; without it the data mount fails closed.",
|
|
97
|
+
"type": "object",
|
|
98
|
+
"additionalProperties": false,
|
|
99
|
+
"properties": {
|
|
100
|
+
"read": { "$ref": "#/$defs/PermissionRule" },
|
|
101
|
+
"insert": { "$ref": "#/$defs/PermissionRule" },
|
|
102
|
+
"update": { "$ref": "#/$defs/PermissionRule" },
|
|
103
|
+
"delete": { "$ref": "#/$defs/PermissionRule" }
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"ownerField": {
|
|
107
|
+
"description": "Column recording the owning user id — required by \"owner\" permission rules; set on insert and used to scope owner reads/writes.",
|
|
108
|
+
"type": "string"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"required": ["connection", "schema"]
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"$defs": {
|
|
116
|
+
"PermissionRule": {
|
|
117
|
+
"description": "Access rule: public | none | authenticated | owner | role:<role>.",
|
|
118
|
+
"type": "string",
|
|
119
|
+
"pattern": "^(public|none|authenticated|owner|role:.+)$"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://jxsuite.com/schemas/connector/Connections.class.json",
|
|
4
|
+
"title": "Connections",
|
|
5
|
+
"description": "Owner of the project.json `connections` section: named database connections carrying identifiers and env-var names only — secret values never enter project.json",
|
|
6
|
+
"$prototype": "Class",
|
|
7
|
+
"extends": "Object",
|
|
8
|
+
|
|
9
|
+
"project": {
|
|
10
|
+
"key": "connections",
|
|
11
|
+
"title": "Connections",
|
|
12
|
+
"description": "Named database connections (identifiers only; secrets live in .dev.vars / the platform secret store)"
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
"$studio": {
|
|
16
|
+
"settings": {
|
|
17
|
+
"icon": "sp-icon-data",
|
|
18
|
+
"label": "Connections",
|
|
19
|
+
"order": 60,
|
|
20
|
+
"layout": "map",
|
|
21
|
+
"entry": {
|
|
22
|
+
"ui": {
|
|
23
|
+
"urlEnv": { "control": "secret" }
|
|
24
|
+
},
|
|
25
|
+
"newEntry": { "provider": "sqlite" }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://jxsuite.com/schemas/connector/D1.class.json",
|
|
4
|
+
"title": "D1",
|
|
5
|
+
"description": "Cloudflare D1 connection provider: binding-backed inside Workers, HTTP-API-backed for deploys, tests, and compiler bakes",
|
|
6
|
+
"$prototype": "Class",
|
|
7
|
+
"extends": "Object",
|
|
8
|
+
"$implementation": "./d1.js",
|
|
9
|
+
|
|
10
|
+
"connector": {
|
|
11
|
+
"provider": "d1",
|
|
12
|
+
"kind": "sqlite",
|
|
13
|
+
"local": "sqlite",
|
|
14
|
+
"serve": "@jxsuite/connector/worker",
|
|
15
|
+
"module": "@jxsuite/connector/d1"
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
"$defs": {
|
|
19
|
+
"methods": {
|
|
20
|
+
"dialect": {
|
|
21
|
+
"role": "dialect",
|
|
22
|
+
"$prototype": "Function",
|
|
23
|
+
"access": "public",
|
|
24
|
+
"scope": "static",
|
|
25
|
+
"identifier": "dialect",
|
|
26
|
+
"timing": ["compiler", "server"],
|
|
27
|
+
"parameters": [
|
|
28
|
+
{
|
|
29
|
+
"identifier": "connection",
|
|
30
|
+
"type": { "type": "object" },
|
|
31
|
+
"description": "Connection definition (with $name injected by the host)"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"identifier": "env",
|
|
35
|
+
"type": { "type": "object" },
|
|
36
|
+
"description": "Host environment: bindings and env vars"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"returnType": { "type": "object" },
|
|
40
|
+
"description": "Kysely dialect for the connection: the D1 binding when present, else the D1 HTTP API via CLOUDFLARE_API_TOKEN"
|
|
41
|
+
},
|
|
42
|
+
"deploySchema": {
|
|
43
|
+
"role": "deploySchema",
|
|
44
|
+
"$prototype": "Function",
|
|
45
|
+
"access": "public",
|
|
46
|
+
"scope": "static",
|
|
47
|
+
"identifier": "deploySchema",
|
|
48
|
+
"timing": ["compiler", "server"],
|
|
49
|
+
"parameters": [
|
|
50
|
+
{
|
|
51
|
+
"identifier": "tables",
|
|
52
|
+
"type": { "type": "object" },
|
|
53
|
+
"description": "Table definitions of this connection"
|
|
54
|
+
},
|
|
55
|
+
{ "identifier": "connection", "type": { "type": "object" } },
|
|
56
|
+
{
|
|
57
|
+
"identifier": "options",
|
|
58
|
+
"type": {
|
|
59
|
+
"type": "object",
|
|
60
|
+
"properties": { "env": { "type": "object" }, "dryRun": { "type": "boolean" } }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"returnType": { "type": "object" },
|
|
65
|
+
"description": "Additive schema sync: { statements, applied, warnings }"
|
|
66
|
+
},
|
|
67
|
+
"bindings": {
|
|
68
|
+
"role": "bindings",
|
|
69
|
+
"$prototype": "Function",
|
|
70
|
+
"access": "public",
|
|
71
|
+
"scope": "static",
|
|
72
|
+
"identifier": "bindings",
|
|
73
|
+
"timing": ["compiler", "server"],
|
|
74
|
+
"parameters": [{ "identifier": "connection", "type": { "type": "object" } }],
|
|
75
|
+
"returnType": { "type": "object" },
|
|
76
|
+
"description": "Wrangler config fragment: the d1_databases binding for this connection"
|
|
77
|
+
},
|
|
78
|
+
"testConnection": {
|
|
79
|
+
"role": "testConnection",
|
|
80
|
+
"$prototype": "Function",
|
|
81
|
+
"access": "public",
|
|
82
|
+
"scope": "static",
|
|
83
|
+
"identifier": "testConnection",
|
|
84
|
+
"timing": ["compiler", "server"],
|
|
85
|
+
"parameters": [
|
|
86
|
+
{ "identifier": "connection", "type": { "type": "object" } },
|
|
87
|
+
{ "identifier": "env", "type": { "type": "object" } }
|
|
88
|
+
],
|
|
89
|
+
"returnType": { "type": "object" },
|
|
90
|
+
"description": "Probe the connection with `select 1`: { ok, error? }"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://jxsuite.com/schemas/connector/Data.class.json",
|
|
4
|
+
"title": "Data",
|
|
5
|
+
"description": "Owner of the project.json `data` section (dynamic tables) and the /_jx/data server mount implementing the canonical data wire contract",
|
|
6
|
+
"$prototype": "Class",
|
|
7
|
+
"extends": "Object",
|
|
8
|
+
"$implementation": "./worker.js",
|
|
9
|
+
|
|
10
|
+
"project": {
|
|
11
|
+
"key": "data",
|
|
12
|
+
"title": "Data Tables",
|
|
13
|
+
"description": "Connection-backed dynamic tables served at /_jx/data/<table>",
|
|
14
|
+
"referenceable": true
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
"server": {
|
|
18
|
+
"basePath": "/_jx/data",
|
|
19
|
+
"order": 20,
|
|
20
|
+
"module": "@jxsuite/connector/worker"
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
"$studio": {
|
|
24
|
+
"settings": {
|
|
25
|
+
"icon": "sp-icon-table",
|
|
26
|
+
"label": "Data Tables",
|
|
27
|
+
"order": 55,
|
|
28
|
+
"layout": "map",
|
|
29
|
+
"entry": {
|
|
30
|
+
"ui": {
|
|
31
|
+
"schema": { "control": "schema-builder" },
|
|
32
|
+
"connection": { "enum": { "$ref": "#/$context/connections" } }
|
|
33
|
+
},
|
|
34
|
+
"newEntry": {
|
|
35
|
+
"connection": "",
|
|
36
|
+
"schema": { "type": "object", "properties": {}, "required": [] },
|
|
37
|
+
"permissions": { "read": "public" }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
"$defs": {
|
|
44
|
+
"returnTypes": {
|
|
45
|
+
"SectionData": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"description": "Map of table name → table definition, stored as _project.data"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
"methods": {
|
|
52
|
+
"projectData": {
|
|
53
|
+
"role": "projectData",
|
|
54
|
+
"$prototype": "Function",
|
|
55
|
+
"access": "public",
|
|
56
|
+
"scope": "static",
|
|
57
|
+
"identifier": "projectData",
|
|
58
|
+
"timing": ["compiler", "server"],
|
|
59
|
+
"parameters": [
|
|
60
|
+
{
|
|
61
|
+
"identifier": "sectionValue",
|
|
62
|
+
"type": { "type": "object" },
|
|
63
|
+
"description": "The project.json `data` section value (table name → definition)"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"identifier": "ctx",
|
|
67
|
+
"type": { "type": "object" },
|
|
68
|
+
"description": "Host context: { projectConfig, root, registry, io }"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"returnType": { "$ref": "#/$defs/returnTypes/SectionData" },
|
|
72
|
+
"description": "Expose the table definitions under _project.data (rows stay in the database; reads go through TableQuery/TableEntry or /_jx/data)"
|
|
73
|
+
},
|
|
74
|
+
"mount": {
|
|
75
|
+
"role": "mount",
|
|
76
|
+
"$prototype": "Function",
|
|
77
|
+
"access": "public",
|
|
78
|
+
"scope": "static",
|
|
79
|
+
"identifier": "mount",
|
|
80
|
+
"timing": ["server"],
|
|
81
|
+
"parameters": [
|
|
82
|
+
{
|
|
83
|
+
"identifier": "options",
|
|
84
|
+
"type": {
|
|
85
|
+
"type": "object",
|
|
86
|
+
"properties": {
|
|
87
|
+
"basePath": { "type": "string" },
|
|
88
|
+
"sections": { "type": "object" },
|
|
89
|
+
"connectors": { "type": "object" },
|
|
90
|
+
"autoSync": { "type": "boolean" }
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"description": "Inlined mount options: project sections, provider constructors, sync mode"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"identifier": "ctx",
|
|
97
|
+
"type": { "type": "object" },
|
|
98
|
+
"description": "Shared JxServerContext (the auth mount populates ctx.auth)"
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"returnType": { "type": "object" },
|
|
102
|
+
"description": "Fetch-style handler (request, env) → Response serving the /_jx/data wire contract; fail-closed without ctx.auth"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://jxsuite.com/schemas/connector/Sqlite.class.json",
|
|
4
|
+
"title": "Sqlite",
|
|
5
|
+
"description": "File-backed SQLite connection provider over bun:sqlite — the dev-server default and the `local: \"sqlite\"` stand-in target",
|
|
6
|
+
"$prototype": "Class",
|
|
7
|
+
"extends": "Object",
|
|
8
|
+
"$implementation": "./sqlite.js",
|
|
9
|
+
|
|
10
|
+
"connector": {
|
|
11
|
+
"provider": "sqlite",
|
|
12
|
+
"kind": "sqlite",
|
|
13
|
+
"serve": "@jxsuite/connector/worker",
|
|
14
|
+
"module": "@jxsuite/connector/sqlite"
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
"$defs": {
|
|
18
|
+
"methods": {
|
|
19
|
+
"dialect": {
|
|
20
|
+
"role": "dialect",
|
|
21
|
+
"$prototype": "Function",
|
|
22
|
+
"access": "public",
|
|
23
|
+
"scope": "static",
|
|
24
|
+
"identifier": "dialect",
|
|
25
|
+
"timing": ["compiler", "server"],
|
|
26
|
+
"parameters": [
|
|
27
|
+
{ "identifier": "connection", "type": { "type": "object" } },
|
|
28
|
+
{ "identifier": "env", "type": { "type": "object" } }
|
|
29
|
+
],
|
|
30
|
+
"returnType": { "type": "object" },
|
|
31
|
+
"description": "Kysely bun:sqlite dialect at <JX_PROJECT_ROOT>/.jx/data/<name>.sqlite (or the connection's file path)"
|
|
32
|
+
},
|
|
33
|
+
"deploySchema": {
|
|
34
|
+
"role": "deploySchema",
|
|
35
|
+
"$prototype": "Function",
|
|
36
|
+
"access": "public",
|
|
37
|
+
"scope": "static",
|
|
38
|
+
"identifier": "deploySchema",
|
|
39
|
+
"timing": ["compiler", "server"],
|
|
40
|
+
"parameters": [
|
|
41
|
+
{ "identifier": "tables", "type": { "type": "object" } },
|
|
42
|
+
{ "identifier": "connection", "type": { "type": "object" } },
|
|
43
|
+
{
|
|
44
|
+
"identifier": "options",
|
|
45
|
+
"type": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"properties": { "env": { "type": "object" }, "dryRun": { "type": "boolean" } }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"returnType": { "type": "object" },
|
|
52
|
+
"description": "Additive schema sync: { statements, applied, warnings }"
|
|
53
|
+
},
|
|
54
|
+
"bindings": {
|
|
55
|
+
"role": "bindings",
|
|
56
|
+
"$prototype": "Function",
|
|
57
|
+
"access": "public",
|
|
58
|
+
"scope": "static",
|
|
59
|
+
"identifier": "bindings",
|
|
60
|
+
"timing": ["compiler", "server"],
|
|
61
|
+
"parameters": [{ "identifier": "connection", "type": { "type": "object" } }],
|
|
62
|
+
"returnType": { "type": "object" },
|
|
63
|
+
"description": "Empty fragment — SQLite is not a Cloudflare service"
|
|
64
|
+
},
|
|
65
|
+
"testConnection": {
|
|
66
|
+
"role": "testConnection",
|
|
67
|
+
"$prototype": "Function",
|
|
68
|
+
"access": "public",
|
|
69
|
+
"scope": "static",
|
|
70
|
+
"identifier": "testConnection",
|
|
71
|
+
"timing": ["compiler", "server"],
|
|
72
|
+
"parameters": [
|
|
73
|
+
{ "identifier": "connection", "type": { "type": "object" } },
|
|
74
|
+
{ "identifier": "env", "type": { "type": "object" } }
|
|
75
|
+
],
|
|
76
|
+
"returnType": { "type": "object" },
|
|
77
|
+
"description": "Probe the database file with `select 1`: { ok, error? }"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|