@forestfuture/active-record 0.9.0 → 0.9.1
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-Ca1JtVcK.mjs → batch-DpMoy3-7.mjs} +830 -698
- package/dist/cli.d.mts +1 -1
- 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/{for-adapters-D35a5x3t.mjs → for-adapters-DSVRZL3n.mjs} +2 -2
- package/dist/{for-adapters-DoyXc8Dq.d.mts → for-adapters-GQfwyuMl.d.mts} +1 -1
- package/dist/{for-adapters-Bl6BCiR1.mjs → for-adapters-unqbZQM7.mjs} +1 -1
- package/dist/{generated-model-L4WAqgOZ.mjs → generated-model-CKIciUat.mjs} +37 -3
- package/dist/{identifiers-CzqYL_nC.mjs → identifiers-BP6aRwew.mjs} +38 -1
- package/dist/{index-Fq4gT3c8.d.mts → index-DkWlkGy2.d.mts} +26 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +5 -5
- package/dist/{metadata-BIUbGJlS.d.mts → metadata-nKZ_6DzA.d.mts} +17 -2
- package/dist/{plugin-BHUP4ssD.mjs → plugin-A93qwqAh.mjs} +3 -3
- package/dist/{plugin-BMAJKgj6.mjs → plugin-CsOOLZkx.mjs} +3 -3
- package/dist/postgresql.d.mts +1 -1
- package/dist/postgresql.mjs +4 -4
- package/dist/{src-fYq-nVHE.mjs → src-CB2AUq70.mjs} +2 -2
- package/dist/{storage-override-yF2NT5ST.mjs → storage-override-B7WTiA_U.mjs} +1 -1
- package/dist/{validations-CKPJoSj4.d.mts → validations-C2-HKi1V.d.mts} +80 -60
- package/llms-full.txt +220 -11
- package/package.json +1 -1
- package/skills/active-record/SKILL.md +1 -0
package/dist/cli.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AttributeType } from "./metadata-
|
|
1
|
+
import { a as AttributeType } from "./metadata-nKZ_6DzA.mjs";
|
|
2
2
|
type ColumnType = "string" | "integer" | "real" | "decimal" | "boolean" | "datetime" | "date" | "time" | "json" | "binary" | "references";
|
|
3
3
|
/** One column as the generators' syntax gives it: `email:string!:unique`, `user:references`. */
|
|
4
4
|
interface ColumnArg {
|
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as pluralize, D as underscore } from "./identifiers-
|
|
2
|
-
import { a as migrationSql, c as migrationPlan, i as withDigits, n as namesInList, o as quotedName, r as withGeneratedEnum, s as indexName, t as generatedSchema } from "./for-adapters-
|
|
3
|
-
import { f as byName, i as attributeName, l as configFileName, n as castDefault, o as exportName, p as byVersion, r as isCastDefaultType, s as listed, t as storageOverride, u as parseJsonc } from "./storage-override-
|
|
1
|
+
import { C as pluralize, D as underscore } from "./identifiers-BP6aRwew.mjs";
|
|
2
|
+
import { a as migrationSql, c as migrationPlan, i as withDigits, n as namesInList, o as quotedName, r as withGeneratedEnum, s as indexName, t as generatedSchema } from "./for-adapters-DSVRZL3n.mjs";
|
|
3
|
+
import { f as byName, i as attributeName, l as configFileName, n as castDefault, o as exportName, p as byVersion, r as isCastDefaultType, s as listed, t as storageOverride, u as parseJsonc } from "./storage-override-B7WTiA_U.mjs";
|
|
4
4
|
export { attributeName, byName, byVersion, castDefault, configFileName, exportName, generatedSchema, indexName, isCastDefaultType, listed, migrationPlan, migrationSql, namesInList, parseJsonc, pluralize, quotedName, storageOverride, underscore, withDigits, withGeneratedEnum };
|
package/dist/command.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { _ as importPath, a as classify, c as moduleName, d as projectDatabases, g as migrationsOf, h as leadingNumber, m as hasNestedMigrations, n as castDefault, p as byVersion, s as listed, t as storageOverride, u as parseJsonc, v as shown$1, y as slashed } from "./storage-override-
|
|
3
|
-
import { At as tableize, Mt as staticBelow, c as methodsOffFixes, d as enumNameProblem, f as enumScopeNames, i as isBase, jt as ancestors } from "./generated-model-
|
|
4
|
-
import { C as pluralize, D as underscore, T as camelize, h as digitsProblem, t as isIdentifier, w as singularize } from "./identifiers-
|
|
2
|
+
import { _ as importPath, a as classify, c as moduleName, d as projectDatabases, g as migrationsOf, h as leadingNumber, m as hasNestedMigrations, n as castDefault, p as byVersion, s as listed, t as storageOverride, u as parseJsonc, v as shown$1, y as slashed } from "./storage-override-B7WTiA_U.mjs";
|
|
3
|
+
import { At as tableize, Mt as staticBelow, c as methodsOffFixes, d as enumNameProblem, f as enumScopeNames, i as isBase, jt as ancestors } from "./generated-model-CKIciUat.mjs";
|
|
4
|
+
import { C as pluralize, D as underscore, T as camelize, h as digitsProblem, t as isIdentifier, w as singularize } from "./identifiers-BP6aRwew.mjs";
|
|
5
5
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
|
|
6
6
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
7
7
|
import { inspect, parseArgs, types } from "node:util";
|
|
@@ -68,11 +68,11 @@ function helpFor(subcommands) {
|
|
|
68
68
|
const adapters = {
|
|
69
69
|
d1: {
|
|
70
70
|
entry: "@forestfuture/active-record/d1",
|
|
71
|
-
plugin: async () => (await import("./plugin-
|
|
71
|
+
plugin: async () => (await import("./plugin-A93qwqAh.mjs")).cli
|
|
72
72
|
},
|
|
73
73
|
postgresql: {
|
|
74
74
|
entry: "@forestfuture/active-record/postgresql",
|
|
75
|
-
plugin: async () => (await import("./plugin-
|
|
75
|
+
plugin: async () => (await import("./plugin-CsOOLZkx.mjs")).cli
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
/** The adapters' names, in the registry's order. */
|
package/dist/d1.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as QueryEvent$1, D as SchemaAdapter, O as AnyDatabase, w as QueryListener$1 } from "./validations-
|
|
2
|
-
import { c as ActiveRecordError } from "./index-
|
|
1
|
+
import { C as QueryEvent$1, D as SchemaAdapter, O as AnyDatabase, w as QueryListener$1 } from "./validations-C2-HKi1V.mjs";
|
|
2
|
+
import { c as ActiveRecordError } from "./index-DkWlkGy2.mjs";
|
|
3
3
|
/** The D1 database a generated schema's Models query: `adapter: d1({ binding: "DB" })`. */
|
|
4
4
|
export declare function d1({ binding }: {
|
|
5
5
|
binding: string;
|
package/dist/d1.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as databaseExecutor, i as AnyDatabase, l as workersEnv, r as withDatabase, u as DatabaseExecutor } from "./batch-
|
|
2
|
-
import { t as onlyRequested } from "./for-adapters-
|
|
3
|
-
import { V as NoDatabase, i as hexOf, k as ActiveRecordError } from "./identifiers-
|
|
4
|
-
import { w as boundValue } from "./generated-model-
|
|
1
|
+
import { a as databaseExecutor, i as AnyDatabase, l as workersEnv, r as withDatabase, u as DatabaseExecutor } from "./batch-DpMoy3-7.mjs";
|
|
2
|
+
import { t as onlyRequested } from "./for-adapters-unqbZQM7.mjs";
|
|
3
|
+
import { V as NoDatabase, i as hexOf, k as ActiveRecordError } from "./identifiers-BP6aRwew.mjs";
|
|
4
|
+
import { w as boundValue } from "./generated-model-CKIciUat.mjs";
|
|
5
5
|
// src/adapters/d1/errors.ts
|
|
6
6
|
/** D1's error for a Session's bookmark it can't use, and the bookmark it repeats (#237). */
|
|
7
7
|
const rejectedBookmark = /invalid commitToken bookmark provided: (.*)$/s;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as pluralize, D as underscore, h as digitsProblem } from "./identifiers-
|
|
2
|
-
import { f as byName, o as exportName } from "./storage-override-
|
|
1
|
+
import { C as pluralize, D as underscore, h as digitsProblem } from "./identifiers-BP6aRwew.mjs";
|
|
2
|
+
import { f as byName, o as exportName } from "./storage-override-B7WTiA_U.mjs";
|
|
3
3
|
// cli/generate/migration-plan.ts
|
|
4
4
|
/** What to do, read from a migration's name: `create_products`, `add_sku_to_products`, …; else empty. */
|
|
5
5
|
function migrationPlan(name) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as AnyDatabase } from "./validations-
|
|
1
|
+
import { O as AnyDatabase } from "./validations-C2-HKi1V.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Bytes as hex text, two digits each, for SQL that reads bytes from JSON (`unhex`, `\\x…`). The
|
|
4
4
|
* digits' character codes are written into one array and decoded once: mapping each byte to a
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as MissingAttribute, C as pluralize, D as underscore, E as capitalized, L as InvalidModel, S as listedNames, V as NoDatabase, W as
|
|
1
|
+
import { B as MissingAttribute, C as pluralize, D as underscore, E as capitalized, K as RecordDestroyed, L as InvalidModel, S as listedNames, V as NoDatabase, W as ReadonlyAttribute, _ as enumEntries, a as isSameCell, c as castValue, d as uncastable, h as digitsProblem, l as isInvalidDate, n as reservedWords, nt as UnknownAttribute, o as castCondition, p as writeValue, r as epochStorages, s as castKey, t as isIdentifier, u as readValue, v as enumProblem, x as isEnumValues } from "./identifiers-BP6aRwew.mjs";
|
|
2
2
|
// src/ancestors.ts
|
|
3
3
|
/** A class and every class (and object) it extends, nearest first. */
|
|
4
4
|
function ancestors(model) {
|
|
@@ -629,7 +629,17 @@ const rules = {
|
|
|
629
629
|
requires: "virtual",
|
|
630
630
|
conflictsWith: ["default"]
|
|
631
631
|
},
|
|
632
|
-
secureToken: secureTokenRule()
|
|
632
|
+
secureToken: secureTokenRule(),
|
|
633
|
+
readonly: {
|
|
634
|
+
isWellFormed: (value) => typeof value === "boolean",
|
|
635
|
+
describedAs: "readonly",
|
|
636
|
+
isGiven: isGivenUnless(false),
|
|
637
|
+
conflictsWith: [
|
|
638
|
+
"virtual",
|
|
639
|
+
"securePassword",
|
|
640
|
+
"secureToken"
|
|
641
|
+
]
|
|
642
|
+
}
|
|
633
643
|
};
|
|
634
644
|
/** The rule for `secureToken`: a string's random token, generated for a new record (#355). */
|
|
635
645
|
function secureTokenRule() {
|
|
@@ -1339,6 +1349,8 @@ var RecordState = class {
|
|
|
1339
1349
|
isMarkedForDestruction = false;
|
|
1340
1350
|
/** Whether the save being prepared sends a locked UPDATE, which sets the row's version (#357). */
|
|
1341
1351
|
isSavingVersion = false;
|
|
1352
|
+
/** Marked read-only (#358): by `markReadonly()`, or loaded through a `readonly()` Relation. */
|
|
1353
|
+
isReadonly = false;
|
|
1342
1354
|
/** Whether its last save created it (#351). */
|
|
1343
1355
|
isPreviouslyNew = false;
|
|
1344
1356
|
/** The contexts it's being validated in, while it is (#51). */
|
|
@@ -1421,6 +1433,7 @@ var RecordState = class {
|
|
|
1421
1433
|
this.#requireNotDestroyed("be changed");
|
|
1422
1434
|
const name = attributeName(this.#model, given);
|
|
1423
1435
|
const assigned = this.#attribute(name).assigned(value);
|
|
1436
|
+
this.#requireSameIfReadonly(name, assigned);
|
|
1424
1437
|
const digest = digestOf(this.#model.attributeDefinitions, name);
|
|
1425
1438
|
if (digest !== void 0 && assigned === "") return;
|
|
1426
1439
|
if (digest !== void 0 && assigned === null) {
|
|
@@ -1435,7 +1448,18 @@ var RecordState = class {
|
|
|
1435
1448
|
*/
|
|
1436
1449
|
writeKey(name, value, association) {
|
|
1437
1450
|
this.#requireNotDestroyed("be changed");
|
|
1438
|
-
|
|
1451
|
+
const key = this.#attribute(name).key(value, association);
|
|
1452
|
+
this.#requireSameIfReadonly(name, key);
|
|
1453
|
+
this.#store(name, key);
|
|
1454
|
+
}
|
|
1455
|
+
/**
|
|
1456
|
+
* Takes a value the database already holds, as stored, such as a count a counter cache changed
|
|
1457
|
+
* (#61): no read-only check (#358), and nothing to save.
|
|
1458
|
+
*/
|
|
1459
|
+
takeStored(given, value) {
|
|
1460
|
+
const name = attributeName(this.#model, given);
|
|
1461
|
+
this.#store(name, this.#attribute(name).assigned(value));
|
|
1462
|
+
this.commitColumns([name]);
|
|
1439
1463
|
}
|
|
1440
1464
|
/** Stores an attribute's already-cast value, as assigned. */
|
|
1441
1465
|
#store(name, value) {
|
|
@@ -1662,6 +1686,16 @@ var RecordState = class {
|
|
|
1662
1686
|
#requireNotDestroyed(action) {
|
|
1663
1687
|
if (this.#lifecycle === "destroyed") throw new RecordDestroyed(`${this.#model.name} record was destroyed; it can't ${action}`);
|
|
1664
1688
|
}
|
|
1689
|
+
/**
|
|
1690
|
+
* A persisted record's read-only attribute takes only the value it holds, cast and normalized
|
|
1691
|
+
* (#358), so a form can post it back unchanged.
|
|
1692
|
+
*/
|
|
1693
|
+
#requireSameIfReadonly(name, assigned) {
|
|
1694
|
+
if (this.#definition(name).readonly !== true || this.#lifecycle !== "persisted") return;
|
|
1695
|
+
const before = this.#isInSnapshot(name) ? this.#snapshotValue(name) : void 0;
|
|
1696
|
+
if (before !== void 0 && this.#attribute(name).isSame(before, assigned)) return;
|
|
1697
|
+
throw new ReadonlyAttribute(this.#model.name, name);
|
|
1698
|
+
}
|
|
1665
1699
|
/** An unknown name is UnknownAttribute, even one every object inherits (`constructor`, #84). */
|
|
1666
1700
|
#requireAttribute(name) {
|
|
1667
1701
|
this.#definition(name);
|
|
@@ -137,6 +137,43 @@ var StaleRecord = class extends ActiveRecordError {
|
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
/**
|
|
140
|
+
* Assigning a persisted record's read-only attribute a value other than the one it holds (#358):
|
|
141
|
+
* it's written when the record is created, and never changed by it after.
|
|
142
|
+
*/
|
|
143
|
+
var ReadonlyAttribute = class extends ActiveRecordError {
|
|
144
|
+
name = "ReadonlyAttribute";
|
|
145
|
+
attribute;
|
|
146
|
+
constructor(model, attribute) {
|
|
147
|
+
super(`${model}'s "${attribute}" is read-only once it's created; it can't be changed`);
|
|
148
|
+
this.attribute = attribute;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* A write of a read-only record (#358): one marked by `markReadonly()`, or loaded through a
|
|
153
|
+
* `readonly()` Relation. Nothing ran and nothing was sent.
|
|
154
|
+
*/
|
|
155
|
+
var ReadonlyRecord = class extends ActiveRecordError {
|
|
156
|
+
name = "ReadonlyRecord";
|
|
157
|
+
record;
|
|
158
|
+
action;
|
|
159
|
+
constructor(record, action) {
|
|
160
|
+
super(`${record.constructor.name} record is read-only; it can't ${verbs[action]}`);
|
|
161
|
+
this.record = record;
|
|
162
|
+
this.action = action;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
/** How a refused action reads after "it can't". */
|
|
166
|
+
const verbs = {
|
|
167
|
+
save: "be saved",
|
|
168
|
+
destroy: "be destroyed",
|
|
169
|
+
touch: "be touched",
|
|
170
|
+
updateColumns: "be written by updateColumns",
|
|
171
|
+
updateColumn: "be written by updateColumn",
|
|
172
|
+
incrementColumn: "be written by incrementColumn",
|
|
173
|
+
decrementColumn: "be written by decrementColumn",
|
|
174
|
+
toggleColumn: "be written by toggleColumn"
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
140
177
|
* `abort()` was thrown from an after-write callback (`afterSave`, `afterCreate`, `afterUpdate`,
|
|
141
178
|
* `afterDestroy`, `afterTouch`), or from an around callback once its `next()` resolved. That's a
|
|
142
179
|
* mistake: the write already succeeded and nothing rolls back.
|
|
@@ -1011,4 +1048,4 @@ function isIdentifier(name) {
|
|
|
1011
1048
|
}
|
|
1012
1049
|
/** Words JavaScript doesn't allow as a declaration's name in a module (strict mode). */
|
|
1013
1050
|
const reservedWords = new Set("break case catch class const continue debugger default delete do else enum export extends false finally for function if import in instanceof new null return super switch this throw true try typeof var void while with yield let static implements interface package private protected public await arguments eval".split(" "));
|
|
1014
|
-
export {
|
|
1051
|
+
export { StaleRecord as $, AssociationNotLoaded as A, MissingAttribute as B, pluralize as C, underscore as D, capitalized as E, IncompatibleRelation as F, ReadonlyRecord as G, NotNullViolation as H, InvalidForeignKey as I, RecordNotDestroyed as J, RecordDestroyed as K, InvalidModel as L, CheckViolation as M, ConstraintViolation as N, AbortAfterPersistence as O, DeleteRestriction as P, SoleRecordExceeded as Q, InvalidToken as R, listedNames as S, camelize as T, ReadonlyAssociation as U, NoDatabase as V, ReadonlyAttribute as W, RecordNotSaved as X, RecordNotFound as Y, RecordNotUnique as Z, enumEntries as _, isSameCell as a, enumValuesOf as b, castValue as c, uncastable as d, StrictValidationFailed as et, writeUntypedValue as f, orderDecimal as g, digitsProblem as h, hexOf as i, abort as it, CallbackAbort as j, ActiveRecordError as k, isInvalidDate as l, zonelessDateTime as m, reservedWords as n, UnknownAttribute as nt, castCondition as o, writeValue as p, RecordInvalid as q, epochStorages as r, UnknownModelName as rt, castKey as s, isIdentifier as t, UnknownAssociation as tt, readValue as u, enumProblem as v, singularize as w, isEnumValues as x, enumValidations as y, IrreversibleOrder as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as DatetimeAttributeKey, L as NumberAttributeKey, O as AnyDatabase, _t as
|
|
1
|
+
import { I as DatetimeAttributeKey, L as NumberAttributeKey, O as AnyDatabase, _t as ThroughDependent, ct as BelongsTo, dt as HasManyDependent, f as Model, ft as HasManyThrough, g as DatabaseSchema, gt as PolymorphicBelongsTo, ht as HasOneThrough, lt as HasMany, mt as HasOneDependent, p as ModelClass, pt as HasOne, st as AssociationOptions, vt as ThroughOptions } from "./validations-C2-HKi1V.mjs";
|
|
2
2
|
/** Base class for every error the library throws on purpose. */
|
|
3
3
|
declare class ActiveRecordError extends Error {
|
|
4
4
|
name: string;
|
|
@@ -126,6 +126,30 @@ declare class StaleRecord extends ActiveRecordError {
|
|
|
126
126
|
readonly action: StaleAction;
|
|
127
127
|
constructor(record: Model, action: StaleAction, options?: ErrorOptions);
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Assigning a persisted record's read-only attribute a value other than the one it holds (#358):
|
|
131
|
+
* it's written when the record is created, and never changed by it after.
|
|
132
|
+
*/
|
|
133
|
+
declare class ReadonlyAttribute extends ActiveRecordError {
|
|
134
|
+
name: string;
|
|
135
|
+
readonly attribute: string;
|
|
136
|
+
constructor(model: string, attribute: string);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* What a read-only record was refused (#358): a save, a destroy, a `touch()`, or a write straight
|
|
140
|
+
* to its row, named by its method.
|
|
141
|
+
*/
|
|
142
|
+
type ReadonlyAction = "save" | "destroy" | "touch" | "updateColumns" | "updateColumn" | "incrementColumn" | "decrementColumn" | "toggleColumn";
|
|
143
|
+
/**
|
|
144
|
+
* A write of a read-only record (#358): one marked by `markReadonly()`, or loaded through a
|
|
145
|
+
* `readonly()` Relation. Nothing ran and nothing was sent.
|
|
146
|
+
*/
|
|
147
|
+
declare class ReadonlyRecord extends ActiveRecordError {
|
|
148
|
+
name: string;
|
|
149
|
+
readonly record: Model;
|
|
150
|
+
readonly action: ReadonlyAction;
|
|
151
|
+
constructor(record: Model, action: ReadonlyAction);
|
|
152
|
+
}
|
|
129
153
|
/**
|
|
130
154
|
* `abort()` was thrown from an after-write callback (`afterSave`, `afterCreate`, `afterUpdate`,
|
|
131
155
|
* `afterDestroy`, `afterTouch`), or from an around callback once its `next()` resolved. That's a
|
|
@@ -279,4 +303,4 @@ declare function withDatabase<R>(databases: AnyDatabase | readonly AnyDatabase[]
|
|
|
279
303
|
* which defines the scope on it; on any other, it's `undefined`.
|
|
280
304
|
*/
|
|
281
305
|
declare function defineSchema<const S extends DatabaseSchema>(schema: S): S;
|
|
282
|
-
export {
|
|
306
|
+
export { RecordNotSaved as A, ReadonlyAssociation as C, RecordInvalid as D, RecordDestroyed as E, StrictValidationFailed as F, UnknownAssociation as I, UnknownAttribute as L, SoleRecordExceeded as M, StaleAction as N, RecordNotDestroyed as O, StaleRecord as P, UnknownModelName as R, ReadonlyAction as S, ReadonlyRecord as T, InvalidToken as _, hasMany as a, NoDatabase as b, ActiveRecordError as c, CheckViolation as d, ConstraintViolation as f, InvalidModel as g, InvalidForeignKey as h, belongsTo as i, RecordNotUnique as j, RecordNotFound as k, AssociationNotLoaded as l, IncompatibleRelation as m, withDatabase as n, hasOne as o, DeleteRestriction as p, PolymorphicBelongsToOptions as r, AbortAfterPersistence as s, defineSchema as t, CallbackAbort as u, IrreversibleOrder as v, ReadonlyAttribute as w, NotNullViolation as x, MissingAttribute as y, abort as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as defineType, C as SecurePasswordOptions, D as Duration, E as PasswordAlgorithm, _ as SecureTokenOptions, a as AttributeType, i as AttributeSpecs, k as CustomType, r as AttributeSpec, u as EpochStorage, v as generateSecureToken } from "./metadata-
|
|
2
|
-
import { $ as TouchOptions, At as
|
|
3
|
-
import { A as
|
|
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 Duration, type EpochStorage, type ErrorMessage, type ErrorMessages, Errors, type FilterAttribute, type FindSignedOptions, 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, InvalidToken, IrreversibleOrder, type IterationOptions, type LengthOptions, MissingAttribute, Model, NoDatabase, NotNullViolation, type NumericalityOptions, type OrderSpec, type Page, type PageOptions, type PasswordAlgorithm, 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, type SecurePasswordOptions, type SecureTokenOptions, type SignedIdOptions, type SigningEnv, type SigningSecrets, SoleRecordExceeded, type StaleAction, StaleRecord, type Statement, StrictValidationFailed, type TableAttributes, type TableSchema, type TableSchemas, type ThroughDependent, type ThroughOptions, type TokenForOptions, 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, generateSecureToken, gt, gte, hasMany, hasOne, lt, lte, sql, withDatabase };
|
|
1
|
+
import { A as defineType, C as SecurePasswordOptions, D as Duration, E as PasswordAlgorithm, _ as SecureTokenOptions, a as AttributeType, i as AttributeSpecs, k as CustomType, r as AttributeSpec, u as EpochStorage, v as generateSecureToken } from "./metadata-nKZ_6DzA.mjs";
|
|
2
|
+
import { $ as TouchOptions, At as QueryPart, B as SaveOptions, Bt as ColumnValue, C as QueryEvent, Ct as UpsertOptions, Dt as gte, Et as gt, F as RecordStatement, Ft as QuerySql, G as Relation, Gt as ComparisonBound, H as ValidationContext, Ht as column, J as Scoped, K as Scope, Kt as ComparisonOptions, M as BatchResults, Mt as SignedIdOptions, N as batch, Nt as InOrderOfOptions, Ot as lt, P as Batch, Q as PageOptions, R as SigningEnv, St as Returning, Tt as between, U as ValidationContexts, Ut as sql, V as ValidationCallbackOptions, Vt as SafeSql, W as TokenForOptions, Wt as Comparable, X as CountlessPage, Y as IterationOptions, Z as Page, _ as TableSchema, _t as ThroughDependent, a as ValidationOptions, bt as InsertOptions, c as AttributeErrorMessages, ct as BelongsTo, d as RestrictMessages, dt as HasManyDependent, et as GroupedRelation, f as Model, ft as HasManyThrough, g as DatabaseSchema, gt as PolymorphicBelongsTo, h as TableAttributes, ht as HasOneThrough, i as UniquenessOptions, it as WriteResult, j as BatchEntry, jt as FindSignedOptions, k as RelationsFor, kt as lte, l as ErrorMessage, lt as HasMany, m as ScopeStatic, mt as HasOneDependent, n as LengthOptions, nt as ReturnedRow, o as Errors, pt as HasOne, q as ScopeMethods, r as NumericalityOptions, rt as Statement, s as ValidationError, st as AssociationOptions, t as AssociatedValidationOptions, tt as Init, u as ErrorMessages, ut as HasManyCollection, v as TableSchemas, vt as ThroughOptions, w as QueryListener, wt as Comparison, x as AttributeConversions, xt as OrderSpec, y as FilterAttribute, yt as Conditions, z as SigningSecrets, zt as ColumnReference } from "./validations-C2-HKi1V.mjs";
|
|
3
|
+
import { A as RecordNotSaved, C as ReadonlyAssociation, D as RecordInvalid, E as RecordDestroyed, F as StrictValidationFailed, I as UnknownAssociation, L as UnknownAttribute, M as SoleRecordExceeded, N as StaleAction, O as RecordNotDestroyed, P as StaleRecord, R as UnknownModelName, S as ReadonlyAction, T as ReadonlyRecord, _ as InvalidToken, a as hasMany, b as NoDatabase, c as ActiveRecordError, d as CheckViolation, f as ConstraintViolation, g as InvalidModel, h as InvalidForeignKey, i as belongsTo, j as RecordNotUnique, k as RecordNotFound, l as AssociationNotLoaded, m as IncompatibleRelation, n as withDatabase, o as hasOne, p as DeleteRestriction, r as PolymorphicBelongsToOptions, s as AbortAfterPersistence, t as defineSchema, u as CallbackAbort, v as IrreversibleOrder, w as ReadonlyAttribute, x as NotNullViolation, y as MissingAttribute, z as abort } from "./index-DkWlkGy2.mjs";
|
|
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 Duration, type EpochStorage, type ErrorMessage, type ErrorMessages, Errors, type FilterAttribute, type FindSignedOptions, 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, InvalidToken, IrreversibleOrder, type IterationOptions, type LengthOptions, MissingAttribute, Model, NoDatabase, NotNullViolation, type NumericalityOptions, type OrderSpec, type Page, type PageOptions, type PasswordAlgorithm, type PolymorphicBelongsTo, type PolymorphicBelongsToOptions, type QueryEvent, type QueryListener, type QueryPart, type QuerySql, type ReadonlyAction, ReadonlyAssociation, ReadonlyAttribute, ReadonlyRecord, 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, type SecurePasswordOptions, type SecureTokenOptions, type SignedIdOptions, type SigningEnv, type SigningSecrets, SoleRecordExceeded, type StaleAction, StaleRecord, type Statement, StrictValidationFailed, type TableAttributes, type TableSchema, type TableSchemas, type ThroughDependent, type ThroughOptions, type TokenForOptions, 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, generateSecureToken, gt, gte, hasMany, hasOne, lt, lte, sql, withDatabase };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { _ as lt, b as hasMany, c as Relation, d as column, f as sql, g as gte, h as gt, m as between, n as Model, r as withDatabase, t as batch, v as lte, x as hasOne, y as belongsTo } from "./batch-
|
|
3
|
-
import { Y as Errors, dt as defineType, st as generateSecureToken } from "./generated-model-
|
|
4
|
-
import { t as defineSchema } from "./src-
|
|
5
|
-
export { AbortAfterPersistence, ActiveRecordError, AssociationNotLoaded, CallbackAbort, CheckViolation, ConstraintViolation, DeleteRestriction, Errors, IncompatibleRelation, InvalidForeignKey, InvalidModel, InvalidToken, IrreversibleOrder, MissingAttribute, Model, NoDatabase, NotNullViolation, ReadonlyAssociation, RecordDestroyed, RecordInvalid, RecordNotDestroyed, RecordNotFound, RecordNotSaved, RecordNotUnique, Relation, SoleRecordExceeded, StaleRecord, StrictValidationFailed, UnknownAssociation, UnknownAttribute, UnknownModelName, abort, batch, belongsTo, between, column, defineSchema, defineType, generateSecureToken, gt, gte, hasMany, hasOne, lt, lte, sql, withDatabase };
|
|
1
|
+
import { $ as StaleRecord, A as AssociationNotLoaded, B as MissingAttribute, F as IncompatibleRelation, G as ReadonlyRecord, H as NotNullViolation, I as InvalidForeignKey, J as RecordNotDestroyed, K as RecordDestroyed, L as InvalidModel, M as CheckViolation, N as ConstraintViolation, O as AbortAfterPersistence, P as DeleteRestriction, Q as SoleRecordExceeded, R as InvalidToken, U as ReadonlyAssociation, V as NoDatabase, W as ReadonlyAttribute, X as RecordNotSaved, Y as RecordNotFound, Z as RecordNotUnique, et as StrictValidationFailed, it as abort, j as CallbackAbort, k as ActiveRecordError, nt as UnknownAttribute, q as RecordInvalid, rt as UnknownModelName, tt as UnknownAssociation, z as IrreversibleOrder } from "./identifiers-BP6aRwew.mjs";
|
|
2
|
+
import { _ as lt, b as hasMany, c as Relation, d as column, f as sql, g as gte, h as gt, m as between, n as Model, r as withDatabase, t as batch, v as lte, x as hasOne, y as belongsTo } from "./batch-DpMoy3-7.mjs";
|
|
3
|
+
import { Y as Errors, dt as defineType, st as generateSecureToken } from "./generated-model-CKIciUat.mjs";
|
|
4
|
+
import { t as defineSchema } from "./src-CB2AUq70.mjs";
|
|
5
|
+
export { AbortAfterPersistence, ActiveRecordError, AssociationNotLoaded, CallbackAbort, CheckViolation, ConstraintViolation, DeleteRestriction, Errors, IncompatibleRelation, InvalidForeignKey, InvalidModel, InvalidToken, IrreversibleOrder, MissingAttribute, Model, NoDatabase, NotNullViolation, ReadonlyAssociation, ReadonlyAttribute, ReadonlyRecord, RecordDestroyed, RecordInvalid, RecordNotDestroyed, RecordNotFound, RecordNotSaved, RecordNotUnique, Relation, SoleRecordExceeded, StaleRecord, StrictValidationFailed, UnknownAssociation, UnknownAttribute, UnknownModelName, abort, batch, belongsTo, between, column, defineSchema, defineType, generateSecureToken, gt, gte, hasMany, hasOne, lt, lte, sql, withDatabase };
|
|
@@ -231,6 +231,11 @@ interface SpecObject {
|
|
|
231
231
|
* `regenerate…()` (#355): `true`, or its options. Only a string has one.
|
|
232
232
|
*/
|
|
233
233
|
secureToken?: boolean | SecureTokenOptions;
|
|
234
|
+
/**
|
|
235
|
+
* Written when a record is created, and refused once it's persisted (#358): assigning it a value
|
|
236
|
+
* other than the one it holds throws `ReadonlyAttribute`.
|
|
237
|
+
*/
|
|
238
|
+
readonly?: boolean;
|
|
234
239
|
}
|
|
235
240
|
/** How an enum's value is validated: `true`, or `{ allowNull: true }` to let it be null. */
|
|
236
241
|
type EnumValidation = boolean | {
|
|
@@ -262,6 +267,14 @@ type NoDigits = {
|
|
|
262
267
|
type NoToken = {
|
|
263
268
|
secureToken?: never;
|
|
264
269
|
};
|
|
270
|
+
/** A string's secure token, which `regenerate…()` changes, so it's never read-only (#358). */
|
|
271
|
+
type TokenOrReadonly = {
|
|
272
|
+
secureToken?: boolean | SecureTokenOptions;
|
|
273
|
+
readonly?: false;
|
|
274
|
+
} | {
|
|
275
|
+
secureToken?: false;
|
|
276
|
+
readonly: true;
|
|
277
|
+
};
|
|
265
278
|
/** The spec's keys that only some types have, each written by the type's own branch below. */
|
|
266
279
|
type PerTypeKeys = "type" | "generateId" | "storage" | "enum" | "precision" | "scale" | "secureToken";
|
|
267
280
|
type AttributeSpec = AttributeType | AnyCustomType | (SpecObjectByType & Placement);
|
|
@@ -271,14 +284,14 @@ type Placement = {
|
|
|
271
284
|
} | {
|
|
272
285
|
virtual: true;
|
|
273
286
|
column?: never;
|
|
287
|
+
readonly?: never;
|
|
274
288
|
};
|
|
275
289
|
/** A spec written out, by its type: the keys each type may have. */
|
|
276
290
|
type SpecObjectByType = (Omit<SpecObject, "default" | PerTypeKeys> & {
|
|
277
291
|
type: "string";
|
|
278
292
|
storage?: never;
|
|
279
293
|
enum?: TextEnum;
|
|
280
|
-
|
|
281
|
-
} & ValueSource & NoDigits) | (Omit<SpecObject, PerTypeKeys> & NoDigits & NoToken & {
|
|
294
|
+
} & TokenOrReadonly & ValueSource & NoDigits) | (Omit<SpecObject, PerTypeKeys> & NoDigits & NoToken & {
|
|
282
295
|
type: "integer";
|
|
283
296
|
generateId?: false;
|
|
284
297
|
storage?: never;
|
|
@@ -342,6 +355,8 @@ interface AttributeDefinition {
|
|
|
342
355
|
securePassword?: true | SecurePasswordOptions;
|
|
343
356
|
/** A secure token, generated for a new record (#355). */
|
|
344
357
|
secureToken?: true | SecureTokenOptions;
|
|
358
|
+
/** Written on create, and not changed once persisted (#358). */
|
|
359
|
+
readonly?: true;
|
|
345
360
|
}
|
|
346
361
|
/** The JavaScript value an attribute of a built-in type holds: a `Date` for a `datetime`. */
|
|
347
362
|
type BuiltInValue<T extends AttributeType> = T extends "string" ? string : T extends "integer" | "real" ? number : T extends "boolean" ? boolean : T extends "datetime" ? Date : T extends "binary" ? Uint8Array : T extends "decimal" | "date" | "time" ? string : unknown;
|
|
@@ -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 { D as underscore } from "./identifiers-
|
|
1
|
+
import { i as attributeName, n as castDefault, s as listed, t as storageOverride, u as parseJsonc } from "./storage-override-B7WTiA_U.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-DSVRZL3n.mjs";
|
|
3
|
+
import { D as underscore } from "./identifiers-BP6aRwew.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 { D as underscore } from "./identifiers-
|
|
1
|
+
import { i as attributeName, n as castDefault, p as byVersion, r as isCastDefaultType, u as parseJsonc } from "./storage-override-B7WTiA_U.mjs";
|
|
2
|
+
import { a as migrationSql, i as withDigits, n as namesInList, o as quotedName, r as withGeneratedEnum, t as generatedSchema } from "./for-adapters-DSVRZL3n.mjs";
|
|
3
|
+
import { D as underscore } from "./identifiers-BP6aRwew.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-C2-HKi1V.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 databaseExecutor, i as AnyDatabase, l as workersEnv, u as DatabaseExecutor } from "./batch-
|
|
2
|
-
import { t as onlyRequested } from "./for-adapters-
|
|
3
|
-
import { V as NoDatabase } from "./identifiers-
|
|
4
|
-
import { w as boundValue } from "./generated-model-
|
|
1
|
+
import { a as databaseExecutor, i as AnyDatabase, l as workersEnv, u as DatabaseExecutor } from "./batch-DpMoy3-7.mjs";
|
|
2
|
+
import { t as onlyRequested } from "./for-adapters-unqbZQM7.mjs";
|
|
3
|
+
import { V as NoDatabase } from "./identifiers-BP6aRwew.mjs";
|
|
4
|
+
import { w as boundValue } from "./generated-model-CKIciUat.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 Model, o as readyModel, s as isReservedScopeName } from "./batch-
|
|
2
|
-
import { Mt as staticBelow, Tt as ownValueSetter, jt as ancestors, wt as modelNameOf } from "./generated-model-
|
|
1
|
+
import { n as Model, o as readyModel, s as isReservedScopeName } from "./batch-DpMoy3-7.mjs";
|
|
2
|
+
import { Mt as staticBelow, Tt as ownValueSetter, jt as ancestors, wt as modelNameOf } from "./generated-model-CKIciUat.mjs";
|
|
3
3
|
// src/define-schema.ts
|
|
4
4
|
const listed = /* @__PURE__ */ new Set();
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as underscore, T as camelize, c as castValue, d as uncastable, n as reservedWords, r as epochStorages } from "./identifiers-
|
|
1
|
+
import { D as underscore, T as camelize, c as castValue, d as uncastable, n as reservedWords, r as epochStorages } from "./identifiers-BP6aRwew.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
|