@forestfuture/active-record 0.8.1 → 0.8.2
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/dist/adapter.d.mts +2 -2
- package/dist/adapter.mjs +4 -4
- package/dist/{batch-Ms5p9lKq.mjs → batch-D3nP3g83.mjs} +6147 -5558
- package/dist/cli.mjs +3 -3
- package/dist/command.mjs +5 -5
- package/dist/d1.d.mts +2 -2
- package/dist/d1.mjs +4 -4
- package/dist/{identifiers-Dh5DFACX.mjs → epoch-storage-C7186hd1.mjs} +86 -86
- package/dist/{for-adapters-BbIMUNcz.mjs → for-adapters-CgEQfuyD.mjs} +2 -2
- package/dist/{for-adapters-BT2GDjIA.d.mts → for-adapters-DAn1wSYz.d.mts} +1 -1
- package/dist/{for-adapters-C-MQxaIx.mjs → for-adapters-l4rNitkK.mjs} +1 -1
- package/dist/{generated-model-DJA8vmNE.mjs → generated-model-FB7oT7V1.mjs} +285 -281
- package/dist/{index-D5getfHx.d.mts → index-BfX3Dgy_.d.mts} +26 -5
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +4 -4
- package/dist/{plugin-CZPDqguF.mjs → plugin-BY2QaRpq.mjs} +3 -3
- package/dist/{plugin-Cf-5Z0_h.mjs → plugin-IHD0I6Rg.mjs} +3 -3
- package/dist/postgresql.d.mts +1 -1
- package/dist/postgresql.mjs +4 -4
- package/dist/{src-BAVZKQ7J.mjs → src-DnuvSHF6.mjs} +2 -2
- package/dist/{storage-override-0ZgeP2sc.mjs → storage-override-BFC-GSR0.mjs} +1 -1
- package/dist/{validations-BSZ5gVeI.d.mts → validations-DFLjJ203.d.mts} +239 -188
- package/llms-full.txt +1163 -339
- package/package.json +1 -1
- package/skills/active-record/SKILL.md +2 -2
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { I as DatetimeAttributeKey, L as NumberAttributeKey, O as AnyDatabase, at as BelongsTo, ct as HasManyDependent, dt as HasOneDependent, f as Model, ft as HasOneThrough, g as DatabaseSchema, ht as ThroughOptions, it as AssociationOptions, lt as HasManyThrough, mt as ThroughDependent, ot as HasMany, p as ModelClass, pt as PolymorphicBelongsTo, ut as HasOne } from "./validations-DFLjJ203.mjs";
|
|
2
2
|
/** One of the attributes of `C`'s records, which a counter cache names. */
|
|
3
3
|
type CounterName<C extends ModelClass> = NumberAttributeKey<InstanceType<C>>;
|
|
4
|
+
/** One of the datetime attributes of `C`'s records, which a belongsTo's or hasOne's `touch` names. */
|
|
5
|
+
type TouchName<C extends ModelClass> = DatetimeAttributeKey<InstanceType<C>>;
|
|
6
|
+
/** What a belongsTo's or hasOne's `touch` sets: `updatedAt`, and the datetime attributes named. */
|
|
7
|
+
type TouchedAttributes<C extends ModelClass> = true | TouchName<C> | readonly TouchName<C>[];
|
|
8
|
+
/** What a hasOne takes to touch its record (#497). */
|
|
9
|
+
interface HasOneTouchOptions<C extends ModelClass> {
|
|
10
|
+
/**
|
|
11
|
+
* Touches the record when this one is updated, destroyed or touched (not created), in the
|
|
12
|
+
* same batch: `true` sets its `updatedAt`, and a datetime attribute's name, or a list, sets
|
|
13
|
+
* those too. The record is loaded first, so its `afterTouch` and commit callbacks run. A
|
|
14
|
+
* record this one's own save writes (built through it, or autosaved), or its `dependent`
|
|
15
|
+
* removes, is left to that write.
|
|
16
|
+
*/
|
|
17
|
+
touch?: TouchedAttributes<C>;
|
|
18
|
+
}
|
|
4
19
|
/** What only a belongsTo takes; `C` is its target, whose attribute a counter cache names. */
|
|
5
20
|
interface BelongsToOptions<C extends ModelClass = ModelClass> {
|
|
6
21
|
/** The record may point at nothing: saving doesn't require its record (#339). */
|
|
@@ -16,6 +31,12 @@ interface BelongsToOptions<C extends ModelClass = ModelClass> {
|
|
|
16
31
|
attribute?: CounterName<C>;
|
|
17
32
|
active?: false;
|
|
18
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Touches the target when this record is created, updated, destroyed or touched (#353), in the
|
|
36
|
+
* same batch: `true` sets its `updatedAt`, and a datetime attribute's name, or a list, sets
|
|
37
|
+
* those too. The target is loaded first, so its `afterTouch` and commit callbacks run.
|
|
38
|
+
*/
|
|
39
|
+
touch?: TouchedAttributes<C>;
|
|
19
40
|
}
|
|
20
41
|
/**
|
|
21
42
|
* What a polymorphic belongsTo takes (#60): no `scope` (#436), and the attribute holding the
|
|
@@ -66,8 +87,8 @@ declare function hasMany<C extends ModelClass>(target: C, options?: AssociationO
|
|
|
66
87
|
* One `target` record points at this record through `foreignKey` (its own); or, with
|
|
67
88
|
* `through`, this record reaches it through another of its associations (#59).
|
|
68
89
|
*/
|
|
69
|
-
declare function hasOne<C extends ModelClass>(target: C, options: ThroughOptions<C>): HasOneThrough<C>;
|
|
70
|
-
declare function hasOne<C extends ModelClass>(target: C, options?: AssociationOptions<C> & ToPolymorphicOptions & {
|
|
90
|
+
declare function hasOne<C extends ModelClass>(target: C, options: ThroughOptions<C> & HasOneTouchOptions<C>): HasOneThrough<C>;
|
|
91
|
+
declare function hasOne<C extends ModelClass>(target: C, options?: AssociationOptions<C> & ToPolymorphicOptions & HasOneTouchOptions<C> & {
|
|
71
92
|
dependent?: HasOneDependent;
|
|
72
93
|
}): HasOne<C>;
|
|
73
94
|
/** Base class for every error the library throws on purpose. */
|
|
@@ -180,8 +201,8 @@ declare class RecordNotSaved extends ActiveRecordError {
|
|
|
180
201
|
}
|
|
181
202
|
/**
|
|
182
203
|
* `abort()` was thrown from an after-write callback (`afterSave`, `afterCreate`, `afterUpdate`,
|
|
183
|
-
* `afterDestroy`, `afterTouch`)
|
|
184
|
-
* back.
|
|
204
|
+
* `afterDestroy`, `afterTouch`), or from an around callback once its `next()` resolved. That's a
|
|
205
|
+
* mistake: the write already succeeded and nothing rolls back.
|
|
185
206
|
*/
|
|
186
207
|
declare class AbortAfterPersistence extends ActiveRecordError {
|
|
187
208
|
name: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { _ as defineType, a as AttributeType, g as CustomType, i as AttributeSpecs, l as EpochStorage, r as AttributeSpec } from "./metadata-CzntpYzC.mjs";
|
|
2
|
-
import { $ as
|
|
3
|
-
import { A as PolymorphicBelongsToOptions, C as RecordNotUnique, D as UnknownAttribute, E as UnknownAssociation, M as hasMany, N as hasOne, O as UnknownModelName, S as RecordNotSaved, T as StrictValidationFailed, _ as ReadonlyAssociation, a as AssociationNotLoaded, b as RecordNotDestroyed, c as ConstraintViolation, d as InvalidForeignKey, f as InvalidModel, g as NotNullViolation, h as NoDatabase, i as ActiveRecordError, j as belongsTo, k as abort, l as DeleteRestriction, m as MissingAttribute, n as withDatabase, o as CallbackAbort, p as IrreversibleOrder, r as AbortAfterPersistence, s as CheckViolation, t as defineSchema, u as IncompatibleRelation, v as RecordDestroyed, w as SoleRecordExceeded, x as RecordNotFound, y as RecordInvalid } from "./index-
|
|
2
|
+
import { $ as ReturnedRow, At as QuerySql, B as ValidationContext, Bt as ComparisonBound, C as QueryEvent, Ct as gt, Dt as QueryPart, Et as lte, F as RecordStatement, Ft as ColumnValue, G as Scoped, H as Relation, It as SafeSql, J as Page, K as IterationOptions, Lt as column, M as BatchResults, N as batch, Ot as InOrderOfOptions, P as Batch, Pt as ColumnReference, Q as Init, R as SaveOptions, Rt as sql, St as between, Tt as lt, U as Scope, V as ValidationContexts, Vt as ComparisonOptions, W as ScopeMethods, X as TouchOptions, Y as PageOptions, Z as GroupedRelation, _ as TableSchema, _t as InsertOptions, a as ValidationOptions, at as BelongsTo, bt as UpsertOptions, c as AttributeErrorMessages, ct as HasManyDependent, d as RestrictMessages, dt as HasOneDependent, et as Statement, f as Model, ft as HasOneThrough, g as DatabaseSchema, gt as Conditions, h as TableAttributes, ht as ThroughOptions, i as UniquenessOptions, it as AssociationOptions, j as BatchEntry, k as RelationsFor, l as ErrorMessage, lt as HasManyThrough, m as ScopeStatic, mt as ThroughDependent, n as LengthOptions, o as Errors, ot as HasMany, pt as PolymorphicBelongsTo, q as CountlessPage, r as NumericalityOptions, s as ValidationError, st as HasManyCollection, t as AssociatedValidationOptions, tt as WriteResult, u as ErrorMessages, ut as HasOne, v as TableSchemas, vt as OrderSpec, w as QueryListener, wt as gte, x as AttributeConversions, xt as Comparison, y as FilterAttribute, yt as Returning, z as ValidationCallbackOptions, zt as Comparable } from "./validations-DFLjJ203.mjs";
|
|
3
|
+
import { A as PolymorphicBelongsToOptions, C as RecordNotUnique, D as UnknownAttribute, E as UnknownAssociation, M as hasMany, N as hasOne, O as UnknownModelName, S as RecordNotSaved, T as StrictValidationFailed, _ as ReadonlyAssociation, a as AssociationNotLoaded, b as RecordNotDestroyed, c as ConstraintViolation, d as InvalidForeignKey, f as InvalidModel, g as NotNullViolation, h as NoDatabase, i as ActiveRecordError, j as belongsTo, k as abort, l as DeleteRestriction, m as MissingAttribute, n as withDatabase, o as CallbackAbort, p as IrreversibleOrder, r as AbortAfterPersistence, s as CheckViolation, t as defineSchema, u as IncompatibleRelation, v as RecordDestroyed, w as SoleRecordExceeded, x as RecordNotFound, y as RecordInvalid } from "./index-BfX3Dgy_.mjs";
|
|
4
4
|
export { AbortAfterPersistence, ActiveRecordError, type AssociatedValidationOptions, AssociationNotLoaded, type AssociationOptions, type AttributeConversions, type AttributeErrorMessages, type AttributeSpec, type AttributeSpecs, type AttributeType, type Batch, type BatchEntry, type BatchResults, type BelongsTo, CallbackAbort, CheckViolation, type ColumnReference, type ColumnValue, type Comparable, type Comparison, type ComparisonBound, type ComparisonOptions, type Conditions, ConstraintViolation, type CountlessPage, type CustomType, type DatabaseSchema, DeleteRestriction, type EpochStorage, type ErrorMessage, type ErrorMessages, Errors, type FilterAttribute, type GroupedRelation, type HasMany, type HasManyCollection, type HasManyDependent, type HasManyThrough, type HasOne, type HasOneDependent, type HasOneThrough, type InOrderOfOptions, IncompatibleRelation, type Init, type InsertOptions, InvalidForeignKey, InvalidModel, IrreversibleOrder, type IterationOptions, type LengthOptions, MissingAttribute, Model, NoDatabase, NotNullViolation, type NumericalityOptions, type OrderSpec, type Page, type PageOptions, type PolymorphicBelongsTo, type PolymorphicBelongsToOptions, type QueryEvent, type QueryListener, type QueryPart, type QuerySql, ReadonlyAssociation, RecordDestroyed, RecordInvalid, RecordNotDestroyed, RecordNotFound, RecordNotSaved, RecordNotUnique, type RecordStatement, Relation, type RelationsFor, type RestrictMessages, type ReturnedRow, type Returning, type SafeSql, type SaveOptions, type Scope, type ScopeMethods, type ScopeStatic, type Scoped, SoleRecordExceeded, type Statement, StrictValidationFailed, type TableAttributes, type TableSchema, type TableSchemas, type ThroughDependent, type ThroughOptions, type TouchOptions, type UniquenessOptions, UnknownAssociation, UnknownAttribute, UnknownModelName, type UpsertOptions, type ValidationCallbackOptions, type ValidationContext, type ValidationContexts, type ValidationError, type ValidationOptions, type WriteResult, abort, batch, belongsTo, between, column, defineSchema, defineType, gt, gte, hasMany, hasOne, lt, lte, sql, withDatabase };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as abort, A as CallbackAbort, B as NotNullViolation, D as AbortAfterPersistence, F as InvalidForeignKey, G as RecordNotFound, H as RecordDestroyed, I as InvalidModel, J as SoleRecordExceeded, K as RecordNotSaved, L as IrreversibleOrder, M as ConstraintViolation, N as DeleteRestriction, O as ActiveRecordError, P as IncompatibleRelation, Q as UnknownModelName, R as MissingAttribute, U as RecordInvalid, V as ReadonlyAssociation, W as RecordNotDestroyed, X as UnknownAssociation, Y as StrictValidationFailed, Z as UnknownAttribute, j as CheckViolation, k as AssociationNotLoaded, q as RecordNotUnique, z as NoDatabase } from "./
|
|
2
|
-
import { b as hasOne, c as Relation, d as
|
|
3
|
-
import {
|
|
4
|
-
import { t as defineSchema } from "./src-
|
|
1
|
+
import { $ as abort, A as CallbackAbort, B as NotNullViolation, D as AbortAfterPersistence, F as InvalidForeignKey, G as RecordNotFound, H as RecordDestroyed, I as InvalidModel, J as SoleRecordExceeded, K as RecordNotSaved, L as IrreversibleOrder, M as ConstraintViolation, N as DeleteRestriction, O as ActiveRecordError, P as IncompatibleRelation, Q as UnknownModelName, R as MissingAttribute, U as RecordInvalid, V as ReadonlyAssociation, W as RecordNotDestroyed, X as UnknownAssociation, Y as StrictValidationFailed, Z as UnknownAttribute, j as CheckViolation, k as AssociationNotLoaded, q as RecordNotUnique, z as NoDatabase } from "./epoch-storage-C7186hd1.mjs";
|
|
2
|
+
import { _ as lte, b as hasOne, c as Relation, d as sql, g as lt, h as gte, m as gt, n as Model, p as between, r as withDatabase, t as batch, u as column, v as belongsTo, y as hasMany } from "./batch-D3nP3g83.mjs";
|
|
3
|
+
import { f as Errors, z as defineType } from "./generated-model-FB7oT7V1.mjs";
|
|
4
|
+
import { t as defineSchema } from "./src-DnuvSHF6.mjs";
|
|
5
5
|
export { AbortAfterPersistence, ActiveRecordError, AssociationNotLoaded, CallbackAbort, CheckViolation, ConstraintViolation, DeleteRestriction, Errors, IncompatibleRelation, InvalidForeignKey, InvalidModel, IrreversibleOrder, MissingAttribute, Model, NoDatabase, NotNullViolation, ReadonlyAssociation, RecordDestroyed, RecordInvalid, RecordNotDestroyed, RecordNotFound, RecordNotSaved, RecordNotUnique, Relation, SoleRecordExceeded, StrictValidationFailed, UnknownAssociation, UnknownAttribute, UnknownModelName, abort, batch, belongsTo, between, column, defineSchema, defineType, gt, gte, hasMany, hasOne, lt, lte, sql, withDatabase };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as attributeName, n as castDefault, s as listed, t as storageOverride, u as parseJsonc } from "./storage-override-
|
|
2
|
-
import { a as migrationSql, i as withDigits, n as namesInList, o as quotedName, r as withGeneratedEnum, s as indexName, t as generatedSchema } from "./for-adapters-
|
|
3
|
-
import { E as underscore } from "./
|
|
1
|
+
import { i as attributeName, n as castDefault, s as listed, t as storageOverride, u as parseJsonc } from "./storage-override-BFC-GSR0.mjs";
|
|
2
|
+
import { a as migrationSql, i as withDigits, n as namesInList, o as quotedName, r as withGeneratedEnum, s as indexName, t as generatedSchema } from "./for-adapters-CgEQfuyD.mjs";
|
|
3
|
+
import { E as underscore } from "./epoch-storage-C7186hd1.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { existsSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as attributeName, n as castDefault, p as byVersion, r as isCastDefaultType, u as parseJsonc } from "./storage-override-
|
|
2
|
-
import { a as migrationSql, i as withDigits, n as namesInList, o as quotedName, r as withGeneratedEnum, t as generatedSchema } from "./for-adapters-
|
|
3
|
-
import { E as underscore } from "./
|
|
1
|
+
import { i as attributeName, n as castDefault, p as byVersion, r as isCastDefaultType, u as parseJsonc } from "./storage-override-BFC-GSR0.mjs";
|
|
2
|
+
import { a as migrationSql, i as withDigits, n as namesInList, o as quotedName, r as withGeneratedEnum, t as generatedSchema } from "./for-adapters-CgEQfuyD.mjs";
|
|
3
|
+
import { E as underscore } from "./epoch-storage-C7186hd1.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
6
6
|
import { basename, dirname, join } from "node:path";
|
package/dist/postgresql.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as QueryEvent$1, D as SchemaAdapter, O as AnyDatabase, w as QueryListener$1 } from "./validations-
|
|
1
|
+
import { C as QueryEvent$1, D as SchemaAdapter, O as AnyDatabase, w as QueryListener$1 } from "./validations-DFLjJ203.mjs";
|
|
2
2
|
import pg from "pg";
|
|
3
3
|
/** The Postgres database a generated schema's Models query: `adapter: postgresql({ binding: "HYPERDRIVE" })`. */
|
|
4
4
|
export declare function postgresql({ binding }: {
|
package/dist/postgresql.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { n as onlyRequested, t as workersEnv } from "./for-adapters-
|
|
3
|
-
import { z as NoDatabase } from "./
|
|
4
|
-
import {
|
|
1
|
+
import { a as databaseExecutor, i as AnyDatabase, l as DatabaseExecutor } from "./batch-D3nP3g83.mjs";
|
|
2
|
+
import { n as onlyRequested, t as workersEnv } from "./for-adapters-l4rNitkK.mjs";
|
|
3
|
+
import { z as NoDatabase } from "./epoch-storage-C7186hd1.mjs";
|
|
4
|
+
import { O as boundValue } from "./generated-model-FB7oT7V1.mjs";
|
|
5
5
|
import pg from "pg";
|
|
6
6
|
// src/adapters/postgresql/connect-timeout.ts
|
|
7
7
|
/** The limit when the connection string sets none, in milliseconds. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { $ as modelNameOf, et as ownValueSetter, ot as ancestors, st as staticBelow } from "./generated-model-
|
|
1
|
+
import { n as Model, o as readyModel, s as isReservedScopeName } from "./batch-D3nP3g83.mjs";
|
|
2
|
+
import { $ as modelNameOf, et as ownValueSetter, ot as ancestors, st as staticBelow } from "./generated-model-FB7oT7V1.mjs";
|
|
3
3
|
// src/define-schema.ts
|
|
4
4
|
const listed = /* @__PURE__ */ new Set();
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as underscore, T as camelize,
|
|
1
|
+
import { E as underscore, T as camelize, g as reservedWords, l as uncastable, o as castValue, t as epochStorages } from "./epoch-storage-C7186hd1.mjs";
|
|
2
2
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
// cli/project/paths.ts
|