@forestfuture/active-record 0.6.0 → 0.8.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 CHANGED
@@ -1,14 +1,15 @@
1
1
  # @forestfuture/active-record
2
2
 
3
- A Rails-inspired Active Record for [Cloudflare Workers](https://developers.cloudflare.com/workers/): Models with validations, callbacks, associations, and change tracking; lazy, composable queries; and a predictable save lifecycle. It talks to a database through an adapter, such as [`@forestfuture/d1-record`](https://www.npmjs.com/package/@forestfuture/d1-record) for [D1](https://developers.cloudflare.com/d1/).
3
+ A Rails-inspired Active Record for [Cloudflare Workers](https://developers.cloudflare.com/workers/): Models with validations, callbacks, associations, and change tracking; lazy, composable queries; and a predictable save lifecycle. It talks to a database through an adapter it ships with: `@forestfuture/active-record/d1` for [D1](https://developers.cloudflare.com/d1/), and `@forestfuture/active-record/postgresql` for Postgres, with your own `pg`.
4
4
 
5
5
  ```sh
6
- npm install @forestfuture/active-record @forestfuture/d1-record
6
+ npm install @forestfuture/active-record
7
7
  ```
8
8
 
9
- Generate a Model and its table, then use it in your Worker:
9
+ Name your database, generate a Model and its table, then use it in your Worker:
10
10
 
11
11
  ```sh
12
+ npx active-record init
12
13
  npx active-record g model Post 'title:string!' publishedAt:datetime
13
14
  npx active-record migrate
14
15
  ```
@@ -24,4 +25,4 @@ const drafts = await Post.where({ publishedAt: null })
24
25
 
25
26
  The package also installs the `active-record` command (`ffar` for short), which generates the schema, Models and migrations, applies migrations, and opens a console. It ships the guide for its own version as `llms-full.txt`, and an agent skill in `skills/active-record/`.
26
27
 
27
- The guide is at [d1-record.forestfuture.dev](https://d1-record.forestfuture.dev). Coming from d1-record 0.5? See [Upgrading to 0.6](https://d1-record.forestfuture.dev/upgrading). The source is on [GitHub](https://github.com/forestfuture/active-record).
28
+ The guide is at [active-record.forestfuture.dev](https://active-record.forestfuture.dev). Coming from an earlier release? See [Upgrading](https://active-record.forestfuture.dev/upgrading). The source is on [GitHub](https://github.com/forestfuture/active-record).
@@ -0,0 +1,60 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "active-record.jsonc",
4
+ "description": "The project's databases and their adapter, which the active-record command reads. `npx active-record init` writes it.",
5
+ "type": "object",
6
+ "properties": {
7
+ "$schema": {
8
+ "description": "This schema, for an editor to complete and check the file's keys.",
9
+ "type": "string"
10
+ },
11
+ "databases": {
12
+ "description": "Each database by its binding: the name the Worker's env, and the generated schema, give it.",
13
+ "type": "object",
14
+ "minProperties": 1,
15
+ "additionalProperties": {
16
+ "oneOf": [{ "$ref": "#/definitions/d1" }, { "$ref": "#/definitions/postgresql" }]
17
+ }
18
+ }
19
+ },
20
+ "required": ["databases"],
21
+ "additionalProperties": false,
22
+ "definitions": {
23
+ "d1": {
24
+ "description": "A D1 database. Its migrations folder and the rest come from its d1_databases entry in its Wrangler config: the one beside this file, or the one wranglerConfig names.",
25
+ "type": "object",
26
+ "properties": {
27
+ "adapter": { "description": "The database's adapter.", "const": "d1" },
28
+ "wranglerConfig": {
29
+ "description": "Its Wrangler config, relative to this file, when it isn't beside this file: \"../worker/wrangler.jsonc\".",
30
+ "type": "string"
31
+ }
32
+ },
33
+ "required": ["adapter"],
34
+ "additionalProperties": false
35
+ },
36
+ "postgresql": {
37
+ "description": "A Postgres database. `${NAME}` in a connection string reads the variable NAME from the environment.",
38
+ "type": "object",
39
+ "properties": {
40
+ "adapter": { "description": "The database's adapter.", "const": "postgresql" },
41
+ "migrationsDir": {
42
+ "description": "Its migrations folder, relative to this file.",
43
+ "type": "string",
44
+ "default": "migrations"
45
+ },
46
+ "url": {
47
+ "description": "The local database: what migrate and the console use.",
48
+ "type": "string"
49
+ },
50
+ "remoteUrl": { "description": "The real database, for --remote.", "type": "string" },
51
+ "schemaUrl": {
52
+ "description": "A server the schema may be read on, for an extension PGlite doesn't have.",
53
+ "type": "string"
54
+ }
55
+ },
56
+ "required": ["adapter"],
57
+ "additionalProperties": false
58
+ }
59
+ }
60
+ }
@@ -1,2 +1,3 @@
1
- import { ct as DatabaseExecutor, dt as Driver, ft as StatementResult, ht as Dialect, i as AnyDatabase, lt as QueryEvent, n as ConstraintFailure, nt as boundValue, o as databaseExecutor, pt as CompiledSql, r as SchemaAdapter, t as Adapter, ut as QueryListener } from "./adapter-BSvFhTDf.mjs";
2
- export { type Adapter, AnyDatabase, type CompiledSql, type ConstraintFailure, DatabaseExecutor, type Dialect, type Driver, type QueryEvent, type QueryListener, type SchemaAdapter, type StatementResult, boundValue, databaseExecutor };
1
+ import { A as databaseExecutor, At as valueMark, C as QueryEvent, D as SchemaAdapter, Dt as CompiledSql, E as ConstraintFailure, O as AnyDatabase, S as DatabaseExecutor, T as Adapter, b as boundValue, ft as Driver, jt as Attribute, kt as Dialect, pt as StatementResult, w as QueryListener } from "./validations-DHDVV8hB.mjs";
2
+ import { i as hexOf, n as workersEnv, r as onlyRequested, t as WorkersEnv } from "./for-adapters-B0xMP6Dq.mjs";
3
+ export { type Adapter, AnyDatabase, type Attribute, type CompiledSql, type ConstraintFailure, DatabaseExecutor, type Dialect, type Driver, type QueryEvent, type QueryListener, type SchemaAdapter, type StatementResult, type WorkersEnv, boundValue, databaseExecutor, hexOf, onlyRequested, valueMark, workersEnv };
package/dist/adapter.mjs CHANGED
@@ -1,3 +1,5 @@
1
- import { L as boundValue } from "./generated-model-CfDggoVN.mjs";
2
- import { a as databaseExecutor, i as AnyDatabase, s as DatabaseExecutor } from "./batch-DBeYk5wx.mjs";
3
- export { AnyDatabase, DatabaseExecutor, boundValue, databaseExecutor };
1
+ import { p as hexOf } from "./epoch-storage-CDlQZcBB.mjs";
2
+ import { a as databaseExecutor, f as valueMark, i as AnyDatabase, l as DatabaseExecutor } from "./batch-ReqVoCfa.mjs";
3
+ import { M as boundValue } from "./generated-model-g5oWsDKE.mjs";
4
+ import { n as onlyRequested, t as workersEnv } from "./for-adapters-CfXMGeOu.mjs";
5
+ export { AnyDatabase, DatabaseExecutor, boundValue, databaseExecutor, hexOf, onlyRequested, valueMark, workersEnv };