@forestfuture/active-record 0.0.0 → 0.7.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ForestFuture
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,28 @@
1
- # Forest Future: Active Record
1
+ # @forestfuture/active-record
2
2
 
3
- Placeholder: install 0.6.0 or later.
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
+
5
+ ```sh
6
+ npm install @forestfuture/active-record
7
+ ```
8
+
9
+ Name your database, generate a Model and its table, then use it in your Worker:
10
+
11
+ ```sh
12
+ npx active-record init
13
+ npx active-record g model Post 'title:string!' publishedAt:datetime
14
+ npx active-record migrate
15
+ ```
16
+
17
+ ```ts
18
+ import { Post } from "./models/post";
19
+
20
+ const drafts = await Post.where({ publishedAt: null })
21
+ .order({ createdAt: "desc" })
22
+ .limit(10)
23
+ .toArray();
24
+ ```
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/`.
27
+
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,56 @@
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 the Wrangler config beside this file.",
25
+ "type": "object",
26
+ "properties": {
27
+ "adapter": { "description": "The database's adapter.", "const": "d1" }
28
+ },
29
+ "required": ["adapter"],
30
+ "additionalProperties": false
31
+ },
32
+ "postgresql": {
33
+ "description": "A Postgres database. `${NAME}` in a connection string reads the variable NAME from the environment.",
34
+ "type": "object",
35
+ "properties": {
36
+ "adapter": { "description": "The database's adapter.", "const": "postgresql" },
37
+ "migrationsDir": {
38
+ "description": "Its migrations folder, relative to this file.",
39
+ "type": "string",
40
+ "default": "migrations"
41
+ },
42
+ "url": {
43
+ "description": "The local database: what migrate and the console use.",
44
+ "type": "string"
45
+ },
46
+ "remoteUrl": { "description": "The real database, for --remote.", "type": "string" },
47
+ "schemaUrl": {
48
+ "description": "A server the schema may be read on, for an extension PGlite doesn't have.",
49
+ "type": "string"
50
+ }
51
+ },
52
+ "required": ["adapter"],
53
+ "additionalProperties": false
54
+ }
55
+ }
56
+ }