@forestfuture/active-record 0.6.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/README.md +5 -4
- package/config-schema.json +56 -0
- package/dist/{adapter-BSvFhTDf.d.mts → adapter-AGKp6wfO.d.mts} +42 -9
- package/dist/adapter.d.mts +3 -2
- package/dist/adapter.mjs +4 -3
- package/dist/{batch-DBeYk5wx.mjs → batch-BS_WseLf.mjs} +128 -44
- package/dist/cli.d.mts +176 -28
- package/dist/cli.mjs +3 -2
- package/dist/command.mjs +746 -432
- package/dist/d1.d.mts +68 -0
- package/dist/d1.mjs +0 -0
- package/dist/for-adapters-Ch6CoHD4.mjs +240 -0
- package/dist/for-adapters-D_Iu0gS_.mjs +33 -0
- package/dist/for-adapters-t3-LukJQ.d.mts +21 -0
- package/dist/{generated-model-CfDggoVN.mjs → generated-model-Cnt0Ot9q.mjs} +4 -0
- package/dist/index-CyCJuM96.d.mts +149 -0
- package/dist/index.d.mts +3 -143
- package/dist/index.mjs +3 -2
- package/dist/plugin-Cyoej7qV.mjs +600 -0
- package/dist/plugin-XOHYndhP.mjs +939 -0
- package/dist/postgresql.d.mts +72 -0
- package/dist/postgresql.mjs +588 -0
- package/dist/src-la_KkjCS.mjs +1 -0
- package/dist/storage-override-CpbkdIqE.mjs +187 -0
- package/llms-full.txt +837 -201
- package/package.json +25 -2
- package/skills/active-record/SKILL.md +4 -4
- package/dist/storage-override-BYBYP8Mj.mjs +0 -91
package/dist/index.d.mts
CHANGED
|
@@ -1,143 +1,3 @@
|
|
|
1
|
-
import { $ as ErrorMessages, A as Page, B as Comparison, C as HasOne, D as ScopeMethods, E as Scope, F as Conditions, G as lte, H as gt, I as InsertOptions, J as TableSchemas, K as DatabaseSchema, L as OrderSpec, M as ReturnedRow, N as Statement, O as Scoped, P as WriteResult, Q as ErrorMessage, R as Returning, S as HasManyDependent, T as Relation, U as gte, V as between, W as lt, X as ValidationError, Y as Errors, Z as AttributeErrorMessages, _ as UniquenessOptions, _t as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare function belongsTo<C extends ModelClass>(target: C, options?: Omit<AssociationOptions<C>, "dependent">): BelongsTo<C>;
|
|
5
|
-
/** Many `target` records point at this record through `foreignKey` (theirs). */
|
|
6
|
-
export declare function hasMany<C extends ModelClass>(target: C, options?: AssociationOptions<C> & {
|
|
7
|
-
dependent?: HasManyDependent;
|
|
8
|
-
}): HasMany<C>;
|
|
9
|
-
/** One `target` record points at this record through `foreignKey` (its own). */
|
|
10
|
-
export declare function hasOne<C extends ModelClass>(target: C, options?: AssociationOptions<C> & {
|
|
11
|
-
dependent?: HasOneDependent;
|
|
12
|
-
}): HasOne<C>;
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/errors.d.ts
|
|
15
|
-
/** Base class for every error the library throws on purpose. */
|
|
16
|
-
export declare class ActiveRecordError extends Error {
|
|
17
|
-
name: string;
|
|
18
|
-
}
|
|
19
|
-
/** A Model's declaration is invalid, e.g. an association's foreign key isn't an attribute. */
|
|
20
|
-
export declare class InvalidModel extends ActiveRecordError {
|
|
21
|
-
name: string;
|
|
22
|
-
}
|
|
23
|
-
/** A key that isn't a declared attribute of the Model. */
|
|
24
|
-
export declare class UnknownAttribute extends ActiveRecordError {
|
|
25
|
-
name: string;
|
|
26
|
-
}
|
|
27
|
-
/** A record constructed directly (`new User()`) was used for something that needs D1. */
|
|
28
|
-
export declare class NoDatabase extends ActiveRecordError {
|
|
29
|
-
name: string;
|
|
30
|
-
}
|
|
31
|
-
/** No record matched a lookup that requires one (`find`, `findByOrThrow`). */
|
|
32
|
-
export declare class RecordNotFound extends ActiveRecordError {
|
|
33
|
-
name: string;
|
|
34
|
-
}
|
|
35
|
-
/** Reading an attribute that wasn't loaded, e.g. one left out of `select(...)`. */
|
|
36
|
-
export declare class MissingAttribute extends ActiveRecordError {
|
|
37
|
-
name: string;
|
|
38
|
-
}
|
|
39
|
-
/** Destroying a record whose `dependent: "restrictWithException"` association still has records. */
|
|
40
|
-
export declare class DeleteRestriction extends ActiveRecordError {
|
|
41
|
-
name: string;
|
|
42
|
-
}
|
|
43
|
-
/** `last()` can't reverse an order given as an `sql` fragment (Rails' IrreversibleOrderError). */
|
|
44
|
-
export declare class IrreversibleOrder extends ActiveRecordError {
|
|
45
|
-
name: string;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Things that can't be combined: relations in `or`/`merge` (e.g. of different Models),
|
|
49
|
-
* `includes` or a write statement with `distinct()`, or statements of two Databases in a batch.
|
|
50
|
-
*/
|
|
51
|
-
export declare class IncompatibleRelation extends ActiveRecordError {
|
|
52
|
-
name: string;
|
|
53
|
-
}
|
|
54
|
-
/** Using a destroyed record as a live one: `save`, `update`, `destroy` or `reload` after `destroy()`. */
|
|
55
|
-
export declare class RecordDestroyed extends ActiveRecordError {
|
|
56
|
-
name: string;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* D1 rejected a write because of a database constraint. `table`, `columns` and `attributes`
|
|
60
|
-
* are filled in when D1's message names them. `table` is null only for a batch writing to
|
|
61
|
-
* several tables, when D1 doesn't say which one failed. The original D1 error is the `cause`.
|
|
62
|
-
*/
|
|
63
|
-
export declare class ConstraintViolation extends ActiveRecordError {
|
|
64
|
-
name: string;
|
|
65
|
-
readonly table: string | null;
|
|
66
|
-
readonly columns: readonly string[];
|
|
67
|
-
readonly attributes: readonly string[];
|
|
68
|
-
constructor(message: string, details: {
|
|
69
|
-
table: string | null;
|
|
70
|
-
columns: readonly string[];
|
|
71
|
-
attributes: readonly string[];
|
|
72
|
-
cause: unknown;
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/** A UNIQUE constraint failed, e.g. another request won the race after validation passed. */
|
|
76
|
-
export declare class RecordNotUnique extends ConstraintViolation {
|
|
77
|
-
name: string;
|
|
78
|
-
}
|
|
79
|
-
/** A FOREIGN KEY constraint failed. SQLite's message doesn't name the column. */
|
|
80
|
-
export declare class InvalidForeignKey extends ConstraintViolation {
|
|
81
|
-
name: string;
|
|
82
|
-
}
|
|
83
|
-
/** A NOT NULL constraint failed. */
|
|
84
|
-
export declare class NotNullViolation extends ConstraintViolation {
|
|
85
|
-
name: string;
|
|
86
|
-
}
|
|
87
|
-
/** A CHECK constraint failed. */
|
|
88
|
-
export declare class CheckViolation extends ConstraintViolation {
|
|
89
|
-
name: string;
|
|
90
|
-
}
|
|
91
|
-
/** A `…OrThrow` save was refused because the record is invalid; `record.errors` says why. */
|
|
92
|
-
export declare class RecordInvalid extends ActiveRecordError {
|
|
93
|
-
name: string;
|
|
94
|
-
readonly record: Model;
|
|
95
|
-
constructor(record: Model);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Thrown by a callback to refuse a save or destroy: `throw abort("Account is suspended")`.
|
|
99
|
-
* Only this exact class halts a lifecycle; returning `false` never does.
|
|
100
|
-
*/
|
|
101
|
-
export declare class CallbackAbort extends ActiveRecordError {
|
|
102
|
-
name: string;
|
|
103
|
-
readonly reason: string;
|
|
104
|
-
constructor(reason: string);
|
|
105
|
-
}
|
|
106
|
-
/** Makes the sentinel a pre-write callback throws to refuse: `throw abort("reason")`. */
|
|
107
|
-
export declare function abort(reason?: string): CallbackAbort;
|
|
108
|
-
/** A `…OrThrow` save was refused by a callback's `abort(reason)`. */
|
|
109
|
-
export declare class RecordNotSaved extends ActiveRecordError {
|
|
110
|
-
name: string;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* `abort()` was thrown from an after-write callback (`afterSave`, `afterCreate`, `afterUpdate`,
|
|
114
|
-
* `afterDestroy`). That's a mistake: the save or destroy already succeeded and nothing rolls back.
|
|
115
|
-
*/
|
|
116
|
-
export declare class AbortAfterPersistence extends ActiveRecordError {
|
|
117
|
-
name: string;
|
|
118
|
-
readonly callback: string;
|
|
119
|
-
readonly reason: string;
|
|
120
|
-
constructor(callback: string, lifecycle: "save" | "destroy", abortion: CallbackAbort);
|
|
121
|
-
}
|
|
122
|
-
/** A `destroyOrThrow()` was refused by a `beforeDestroy` callback's `abort(reason)`. */
|
|
123
|
-
export declare class RecordNotDestroyed extends ActiveRecordError {
|
|
124
|
-
name: string;
|
|
125
|
-
}
|
|
126
|
-
/** A name passed to `includes()` or `loaded()` that isn't one of the Model's associations. */
|
|
127
|
-
export declare class UnknownAssociation extends ActiveRecordError {
|
|
128
|
-
name: string;
|
|
129
|
-
}
|
|
130
|
-
/** `record.loaded(name)` for an association that wasn't preloaded or read yet. */
|
|
131
|
-
export declare class AssociationNotLoaded extends ActiveRecordError {
|
|
132
|
-
name: string;
|
|
133
|
-
}
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/current-database.d.ts
|
|
136
|
-
/**
|
|
137
|
-
* Runs `fn` with `databases` as the request's own: queries started from a Model inside it (and
|
|
138
|
-
* everything it awaits) use the one on that Model's binding, with its Session and `onQuery`.
|
|
139
|
-
* Usually called once per request, in middleware. Nested calls add to the outer ones.
|
|
140
|
-
*/
|
|
141
|
-
export declare function withDatabase<R>(databases: AnyDatabase | readonly AnyDatabase[], fn: () => R | Promise<R>): Promise<R>;
|
|
142
|
-
//#endregion
|
|
143
|
-
export { type AssociationOptions, type AttributeConversions, type AttributeErrorMessages, type AttributeSpec, type AttributeSpecs, type AttributeType, type BatchEntry, type BatchResults, type BelongsTo, type ColumnReference, type ColumnValue, type Comparison, type Conditions, type CountlessPage, type DatabaseSchema, type EpochStorage, type ErrorMessage, type ErrorMessages, Errors, type FilterAttribute, type HasMany, type HasManyDependent, type HasOne, type HasOneDependent, type InsertOptions, type LengthOptions, Model, type NumericalityOptions, type OrderSpec, type Page, type PageOptions, type QueryEvent, type QueryListener, type QuerySql, type RecordStatement, Relation, type RelationsFor, type RestrictMessages, type ReturnedRow, type Returning, type SafeSql, type Scope, type ScopeMethods, type ScopeStatic, type Scoped, type Statement, type TableAttributes, type TableSchema, type TableSchemas, type UniquenessOptions, type UpsertOptions, type ValidationError, type ValidationOptions, type WriteResult, batch, between, column, gt, gte, lt, lte, sql };
|
|
1
|
+
import { $ as ErrorMessages, A as Page, B as Comparison, C as HasOne, D as ScopeMethods, E as Scope, F as Conditions, G as lte, H as gt, I as InsertOptions, J as TableSchemas, K as DatabaseSchema, L as OrderSpec, M as ReturnedRow, N as Statement, O as Scoped, P as WriteResult, Q as ErrorMessage, R as Returning, S as HasManyDependent, T as Relation, U as gte, V as between, W as lt, X as ValidationError, Y as Errors, Z as AttributeErrorMessages, _ as UniquenessOptions, _t as ColumnReference, a as RelationsFor, at as AttributeSpecs, b as BelongsTo, bt as column, c as BatchResults, d as Model, et as RestrictMessages, g as NumericalityOptions, h as LengthOptions, it as AttributeSpec, j as PageOptions, k as CountlessPage, l as batch, lt as QueryEvent, m as TableAttributes, mt as QuerySql, ot as AttributeType, p as ScopeStatic, q as TableSchema, rt as AttributeConversions, s as BatchEntry, st as EpochStorage, tt as FilterAttribute, u as RecordStatement, ut as QueryListener, v as ValidationOptions, vt as ColumnValue, w as HasOneDependent, x as HasMany, xt as sql, y as AssociationOptions, yt as SafeSql, z as UpsertOptions } from "./adapter-AGKp6wfO.mjs";
|
|
2
|
+
import { C as UnknownAttribute, D as hasOne, E as hasMany, S as UnknownAssociation, T as belongsTo, _ as RecordInvalid, a as CallbackAbort, b as RecordNotSaved, c as DeleteRestriction, d as InvalidModel, f as IrreversibleOrder, g as RecordDestroyed, h as NotNullViolation, i as AssociationNotLoaded, l as IncompatibleRelation, m as NoDatabase, n as AbortAfterPersistence, o as CheckViolation, p as MissingAttribute, r as ActiveRecordError, s as ConstraintViolation, t as withDatabase, u as InvalidForeignKey, v as RecordNotDestroyed, w as abort, x as RecordNotUnique, y as RecordNotFound } from "./index-CyCJuM96.mjs";
|
|
3
|
+
export { AbortAfterPersistence, ActiveRecordError, AssociationNotLoaded, type AssociationOptions, type AttributeConversions, type AttributeErrorMessages, type AttributeSpec, type AttributeSpecs, type AttributeType, type BatchEntry, type BatchResults, type BelongsTo, CallbackAbort, CheckViolation, type ColumnReference, type ColumnValue, type Comparison, type Conditions, ConstraintViolation, type CountlessPage, type DatabaseSchema, DeleteRestriction, type EpochStorage, type ErrorMessage, type ErrorMessages, Errors, type FilterAttribute, type HasMany, type HasManyDependent, type HasOne, type HasOneDependent, IncompatibleRelation, type InsertOptions, InvalidForeignKey, InvalidModel, IrreversibleOrder, type LengthOptions, MissingAttribute, Model, NoDatabase, NotNullViolation, type NumericalityOptions, type OrderSpec, type Page, type PageOptions, type QueryEvent, type QueryListener, type QuerySql, RecordDestroyed, RecordInvalid, RecordNotDestroyed, RecordNotFound, RecordNotSaved, RecordNotUnique, type RecordStatement, Relation, type RelationsFor, type RestrictMessages, type ReturnedRow, type Returning, type SafeSql, type Scope, type ScopeMethods, type ScopeStatic, type Scoped, type Statement, type TableAttributes, type TableSchema, type TableSchemas, type UniquenessOptions, UnknownAssociation, UnknownAttribute, type UpsertOptions, type ValidationError, type ValidationOptions, type WriteResult, abort, batch, belongsTo, between, column, gt, gte, hasMany, hasOne, lt, lte, sql, withDatabase };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { $ as CallbackAbort, Q as AssociationNotLoaded, X as AbortAfterPersistence, Z as ActiveRecordError, _t as UnknownAttribute, at as InvalidModel, ct as NoDatabase, d as Errors, dt as RecordInvalid, et as CheckViolation, ft as RecordNotDestroyed, gt as UnknownAssociation, ht as RecordNotUnique, it as InvalidForeignKey, lt as NotNullViolation, mt as RecordNotSaved, nt as DeleteRestriction, ot as IrreversibleOrder, pt as RecordNotFound, rt as IncompatibleRelation, st as MissingAttribute, tt as ConstraintViolation, ut as RecordDestroyed, vt as abort } from "./generated-model-
|
|
2
|
-
import { _ as
|
|
1
|
+
import { $ as CallbackAbort, Q as AssociationNotLoaded, X as AbortAfterPersistence, Z as ActiveRecordError, _t as UnknownAttribute, at as InvalidModel, ct as NoDatabase, d as Errors, dt as RecordInvalid, et as CheckViolation, ft as RecordNotDestroyed, gt as UnknownAssociation, ht as RecordNotUnique, it as InvalidForeignKey, lt as NotNullViolation, mt as RecordNotSaved, nt as DeleteRestriction, ot as IrreversibleOrder, pt as RecordNotFound, rt as IncompatibleRelation, st as MissingAttribute, tt as ConstraintViolation, ut as RecordDestroyed, vt as abort } from "./generated-model-Cnt0Ot9q.mjs";
|
|
2
|
+
import { _ as hasMany, d as between, f as gt, g as belongsTo, h as lte, l as column, m as lt, n as Model, o as Relation, p as gte, r as withDatabase, t as batch, u as sql, v as hasOne } from "./batch-BS_WseLf.mjs";
|
|
3
|
+
import "./src-la_KkjCS.mjs";
|
|
3
4
|
export { AbortAfterPersistence, ActiveRecordError, AssociationNotLoaded, CallbackAbort, CheckViolation, ConstraintViolation, DeleteRestriction, Errors, IncompatibleRelation, InvalidForeignKey, InvalidModel, IrreversibleOrder, MissingAttribute, Model, NoDatabase, NotNullViolation, RecordDestroyed, RecordInvalid, RecordNotDestroyed, RecordNotFound, RecordNotSaved, RecordNotUnique, Relation, UnknownAssociation, UnknownAttribute, abort, batch, belongsTo, between, column, gt, gte, hasMany, hasOne, lt, lte, sql, withDatabase };
|