@vibeorm/schema 5.8.0 → 5.10.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/dist/capabilities.d.ts +40 -0
- package/dist/exclusion.d.ts +8 -0
- package/dist/extension.d.ts +0 -5
- package/dist/failure-kind.d.ts +72 -0
- package/dist/index-include.d.ts +18 -0
- package/dist/index.d.ts +14 -3
- package/dist/index.js +874 -42
- package/dist/index.js.map +20 -12
- package/dist/ir.d.ts +63 -0
- package/dist/native-rls-admission.d.ts +1 -1
- package/dist/partial-predicate.d.ts +18 -0
- package/dist/reserved.d.ts +0 -10
- package/dist/row-rules.d.ts +1 -22
- package/dist/sealed.d.ts +16 -0
- package/dist/suggest.d.ts +53 -0
- package/dist/table-storage.d.ts +66 -0
- package/dist/unique-keys.d.ts +48 -0
- package/dist/validate.d.ts +27 -1
- package/package.json +1 -1
package/dist/capabilities.d.ts
CHANGED
|
@@ -61,6 +61,10 @@ export type DialectCapabilities = {
|
|
|
61
61
|
readonly externalObjects: boolean;
|
|
62
62
|
/** Qualified PostgreSQL index operator classes. */
|
|
63
63
|
readonly indexOperatorClasses: boolean;
|
|
64
|
+
/** Non-key `INCLUDE (…)` columns on an index (covering indexes). */
|
|
65
|
+
readonly indexIncludeColumns: boolean;
|
|
66
|
+
/** Declared table storage parameters (`fillfactor`, autovacuum, `toast.` …): `WITH (…)` and `ALTER TABLE … SET/RESET (…)`. */
|
|
67
|
+
readonly tableStorageParameters: boolean;
|
|
64
68
|
/** Explicit database-normalized CHECK inspection; text-only engines never guess equivalence. */
|
|
65
69
|
/** PostgreSQL GiST exclusion constraints and their shared extension requirement. */
|
|
66
70
|
readonly exclusionConstraints: boolean;
|
|
@@ -151,6 +155,22 @@ export type DialectCapabilities = {
|
|
|
151
155
|
* built.
|
|
152
156
|
*/
|
|
153
157
|
readonly dateTruncation: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* How a filtered aggregate (`_filtered` on `aggregate` and `groupBy`)
|
|
160
|
+
* renders. `"filterClause"`: the standard `AGG(x) FILTER (WHERE …)`
|
|
161
|
+
* (SQLite 3.30 or later). `"caseWhen"`: `AGG(CASE WHEN … THEN x END)`, and
|
|
162
|
+
* `COUNT(*)` as `COUNT(CASE WHEN … THEN 1 END)`. Both give the same answers:
|
|
163
|
+
* a count of no matching row is 0, every other aggregate NULL.
|
|
164
|
+
*/
|
|
165
|
+
readonly filteredAggregates: "filterClause" | "caseWhen";
|
|
166
|
+
/**
|
|
167
|
+
* `groupBy` grouping sets (`groupingSets`). `"groupingSets"`: any list of
|
|
168
|
+
* sets (`GROUP BY GROUPING SETS (…)`). `"rollup"`: only the rollup chain
|
|
169
|
+
* of `by` in order (`GROUP BY a, b WITH ROLLUP`). `"none"`: refused. Every
|
|
170
|
+
* other shape is refused with `VIBE_UNSUPPORTED_CAPABILITY` when the query
|
|
171
|
+
* is built.
|
|
172
|
+
*/
|
|
173
|
+
readonly groupingSets: "groupingSets" | "rollup" | "none";
|
|
154
174
|
/**
|
|
155
175
|
* Row capture (`$transaction(…, { capture })`): a data-modifying statement
|
|
156
176
|
* reports the declared columns of the rows it changed as they were before
|
|
@@ -160,6 +180,26 @@ export type DialectCapabilities = {
|
|
|
160
180
|
* transaction opens.
|
|
161
181
|
*/
|
|
162
182
|
readonly rowCapture: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* `UPDATE … FROM (SELECT … FOR UPDATE) AS prev … RETURNING prev."col"`: an
|
|
185
|
+
* UPDATE's RETURNING may read the joined source, so ONE statement locks the
|
|
186
|
+
* row, writes it and returns its values from before the write (`update({
|
|
187
|
+
* previous })`). SQLite's RETURNING sees the target table alone and MySQL has
|
|
188
|
+
* no RETURNING: there the runtime reads the row (locking where the dialect
|
|
189
|
+
* can) and then writes it, inside the call's transaction.
|
|
190
|
+
*/
|
|
191
|
+
readonly returningReadsJoinedSource: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* `skipUnchanged: true` on `upsert` / `upsertMany`: a conflicting row whose
|
|
194
|
+
* every written column already holds the incoming value is not rewritten and
|
|
195
|
+
* keeps its `@updatedAt` stamp. PostgreSQL and SQLite put the comparison on
|
|
196
|
+
* the conflict arm's `WHERE`; MySQL's ON DUPLICATE KEY UPDATE has none, so
|
|
197
|
+
* the stamp's assignment goes first and keeps the stored stamp when the
|
|
198
|
+
* stored row equals the incoming one byte for byte (`IF(… <=> …, stamp, ?)`,
|
|
199
|
+
* assignments run left to right), and MySQL itself skips a row whose
|
|
200
|
+
* assignments change nothing. Without it `skipUnchanged` is refused.
|
|
201
|
+
*/
|
|
202
|
+
readonly upsertSkipUnchanged: boolean;
|
|
163
203
|
};
|
|
164
204
|
export declare const POSTGRES_CAPABILITIES: DialectCapabilities;
|
|
165
205
|
export declare const SQLITE_CAPABILITIES: DialectCapabilities;
|
package/dist/exclusion.d.ts
CHANGED
|
@@ -37,4 +37,12 @@ export type ExclusionIR = {
|
|
|
37
37
|
readonly normalizationSource?: string;
|
|
38
38
|
readonly catalogDefinition?: true;
|
|
39
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* The model fields an exclusion constraint compares, in declaration order: its
|
|
42
|
+
* keys' fields, then its range endpoints'. `undefined` when the constraint has
|
|
43
|
+
* no structured source (a definition read back from the catalog).
|
|
44
|
+
*/
|
|
45
|
+
export declare function exclusionFields(params: {
|
|
46
|
+
readonly exclusion: ExclusionIR;
|
|
47
|
+
}): readonly string[] | undefined;
|
|
40
48
|
//# sourceMappingURL=exclusion.d.ts.map
|
package/dist/extension.d.ts
CHANGED
|
@@ -326,11 +326,6 @@ export declare function buildExtensionRegistry(params: {
|
|
|
326
326
|
}): ExtensionRegistry;
|
|
327
327
|
/** An empty registry — the default when no extensions are configured. */
|
|
328
328
|
export declare const EMPTY_EXTENSION_REGISTRY: ExtensionRegistry;
|
|
329
|
-
/** Whether built-in declarations establish public-only physical ownership for this model. */
|
|
330
|
-
export declare function hasPublicExtensionDeclaration(params: {
|
|
331
|
-
schema: SchemaIR;
|
|
332
|
-
model: string;
|
|
333
|
-
}): boolean;
|
|
334
329
|
/** Refuse placement that built-in extension SQL and ownership cannot preserve. */
|
|
335
330
|
export declare function assertExtensionModelPlacement(params: {
|
|
336
331
|
namespace?: string;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What kind of failure an error is, read from its `code` and `meta` alone:
|
|
3
|
+
* the answer a retry policy or an error report needs, without matching
|
|
4
|
+
* message text.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The closed set of `meta.reason` values a `VIBE_ADAPTER` error carries when
|
|
8
|
+
* the database could not be reached, the link died, the server is going away
|
|
9
|
+
* or no connection was free. Each such error also carries
|
|
10
|
+
* `meta.mayHaveReachedServer`: `false` only when the driver proves the
|
|
11
|
+
* statement was never sent, `true` otherwise.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CONNECTION_FAILURE_REASONS: readonly [
|
|
14
|
+
"connection-refused",
|
|
15
|
+
"connection-timeout",
|
|
16
|
+
"connection-lost",
|
|
17
|
+
"connection-not-writable",
|
|
18
|
+
"acquire-timeout",
|
|
19
|
+
"pool-exhausted",
|
|
20
|
+
"pool-closed",
|
|
21
|
+
"too-many-connections",
|
|
22
|
+
"server-shutdown"
|
|
23
|
+
];
|
|
24
|
+
/** One member of {@link CONNECTION_FAILURE_REASONS}. */
|
|
25
|
+
export type ConnectionFailureReason = (typeof CONNECTION_FAILURE_REASONS)[number];
|
|
26
|
+
/** Whether `value` is one of {@link CONNECTION_FAILURE_REASONS}. */
|
|
27
|
+
export declare function isConnectionFailureReason(params: {
|
|
28
|
+
value: unknown;
|
|
29
|
+
}): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The kinds {@link failureKindOf} answers:
|
|
32
|
+
*
|
|
33
|
+
* - `"connection"`: the database could not be reached, the link died, the
|
|
34
|
+
* server is going away or no connection was free. `meta.reason` says which
|
|
35
|
+
* and `meta.mayHaveReachedServer` whether the statement can have run.
|
|
36
|
+
* - `"conflict"`: the engine rolled the transaction back to resolve a
|
|
37
|
+
* conflict with another one (deadlock, serialization failure, SQLite's busy
|
|
38
|
+
* database file). Running the whole transaction again is the remedy.
|
|
39
|
+
* - `"timeout"`: a statement or transaction deadline ran out and the work was
|
|
40
|
+
* cancelled before it committed.
|
|
41
|
+
* - `"constraint"`: the database refused the data: a unique, foreign-key,
|
|
42
|
+
* exclusion, CHECK or NOT NULL constraint, or a declared row rule. Retrying
|
|
43
|
+
* the same data fails the same way.
|
|
44
|
+
*/
|
|
45
|
+
export declare const FAILURE_KINDS: readonly ["connection", "conflict", "timeout", "constraint"];
|
|
46
|
+
/** One member of {@link FAILURE_KINDS}. */
|
|
47
|
+
export type FailureKind = (typeof FAILURE_KINDS)[number];
|
|
48
|
+
/**
|
|
49
|
+
* The kind of failure `error` is, or `undefined` when it is none of
|
|
50
|
+
* {@link FAILURE_KINDS} (a bug, bad input caught before the database, a
|
|
51
|
+
* refusal by a restricted handle, a lock that was not available, a commit whose
|
|
52
|
+
* outcome is unknown). Read from the error's `code` and `meta` only, never from
|
|
53
|
+
* its message or its `cause`; an error that wraps a VibeORM error is not
|
|
54
|
+
* unwrapped. Any object with a VibeORM `code` and a `meta` object is read, so a
|
|
55
|
+
* second installed copy of `@vibeorm/schema` answers the same.
|
|
56
|
+
*
|
|
57
|
+
* It agrees with `transactionOutcomeOf`: `"conflict"` and `"timeout"` are
|
|
58
|
+
* failures that ended a transaction before it committed, and a `COMMIT` whose
|
|
59
|
+
* reply was lost is `VIBE_TRANSACTION` with `meta.reason:
|
|
60
|
+
* "transaction-outcome-unknown"`, which answers `undefined`. Decide a retry
|
|
61
|
+
* of a whole transaction from `transactionOutcomeOf`, of one statement from
|
|
62
|
+
* `meta.mayHaveReachedServer`.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* const kind = failureKindOf({ error });
|
|
66
|
+
* if (kind === "conflict") return runAgain();
|
|
67
|
+
* if (kind === "connection" && (error as VibeError).meta.mayHaveReachedServer === false) return retryLater();
|
|
68
|
+
*/
|
|
69
|
+
export declare function failureKindOf(params: {
|
|
70
|
+
error: unknown;
|
|
71
|
+
}): FailureKind | undefined;
|
|
72
|
+
//# sourceMappingURL=failure-kind.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Dialect, SchemaIR } from "./ir.ts";
|
|
2
|
+
/** Index kinds whose PostgreSQL access method stores `INCLUDE (…)` columns. */
|
|
3
|
+
export declare const INCLUDE_INDEX_KINDS: readonly string[];
|
|
4
|
+
/** Whether any index of the schema declares `INCLUDE` columns. */
|
|
5
|
+
export declare function hasIndexIncludeColumns(params: {
|
|
6
|
+
schema: SchemaIR;
|
|
7
|
+
}): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Refuse `INCLUDE` columns that cannot be created: a malformed list, a dialect
|
|
10
|
+
* without covering indexes (`indexIncludeColumns`), an access method without
|
|
11
|
+
* them, an unknown field, a repeated field, or a field that is already a plain
|
|
12
|
+
* key column of the same index.
|
|
13
|
+
*/
|
|
14
|
+
export declare function assertIndexIncludeColumns(params: {
|
|
15
|
+
schema: SchemaIR;
|
|
16
|
+
dialect: Dialect;
|
|
17
|
+
}): void;
|
|
18
|
+
//# sourceMappingURL=index-include.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export { modelSqlNamespace } from "./model-sql-namespace.ts";
|
|
|
8
8
|
export type { RowRuleIR, RowRuleWhenIR, RowRuleSpec, RowRuleCapability, RowRuleIdentities, RowRuleObject, RowRuleEvent, RowRuleValidationIssue } from "./row-rules.ts";
|
|
9
9
|
export { MYSQL_ROW_RULE_MESSAGE_MAX_BYTES, mysqlRowRuleMessageByteLength, SQLITE_ROW_RULE_ERROR_PREFIX, sqliteRowRuleConstraint, rowRuleTriggerName, assertRowRuleReferentialActions, assertRowRuleCapability, assertRowRuleEquality, defaultRowRuleName, normalizeRowRules, rowRuleCapability, rowRuleGateField, rowRuleGeneratedFields, rowRuleIdentities, rowRuleObjectNames, rowRulePrismaAttribute, rowRuleProtectedFields, rowRuleShapeIssue, schemaRowRuleIdentities, validateRowRules } from "./row-rules.ts";
|
|
10
10
|
export { assertIndexOperatorClasses } from "./index-operator-classes.ts";
|
|
11
|
+
export { INCLUDE_INDEX_KINDS, assertIndexIncludeColumns, hasIndexIncludeColumns } from "./index-include.ts";
|
|
12
|
+
export { TABLE_STORAGE_KEYS, TABLE_STORAGE_PARAMETERS, assertTableStorage, hasTableStorage, isToastStorageKey, parseTableStorageValue, renderTableStorageValue, tableStorageEntries, tableStorageKeyFromPrisma, tableStoragePrismaKey } from "./table-storage.ts";
|
|
13
|
+
export type { TableStorageParameterSpec } from "./table-storage.ts";
|
|
11
14
|
export { MYSQL_FUNCTIONAL_KEY_LIMITS, assertIndexExpressions, indexKeyDefinitionKey, indexKeyDsl, indexKeyFieldNames, indexKeyPrisma, indexKeyTerms, isExpressionIndex, mysqlIndexKeyWidth, validateIndexExpressions } from "./index-expressions.ts";
|
|
12
15
|
export type { IndexExpressionValidationIssue, MysqlIndexKeyWidth } from "./index-expressions.ts";
|
|
13
16
|
export type { GeneratedColumnIR, GeneratedColumnOptions, GeneratedColumnValidationIssue } from "./generated-columns.ts";
|
|
@@ -15,8 +18,9 @@ export { assertGeneratedColumn, assertGeneratedColumns, generatedColumnFromSql,
|
|
|
15
18
|
export type { DatabaseModuleOptions, DatabaseModuleManifest, DatabaseModuleArtifact } from "./database-module.ts";
|
|
16
19
|
export { prepareDatabaseModuleSchema } from "./module-schema.ts";
|
|
17
20
|
export type { ExclusionIR, ExclusionSpec, ExclusionKey, ExclusionEndpoint } from "./exclusion.ts";
|
|
21
|
+
export { exclusionFields } from "./exclusion.ts";
|
|
18
22
|
export { DIALECTS, ENUM_STORAGES, enumStorageOf, fieldTypeIdentity, isEnumType, providerToDialect } from "./ir.ts";
|
|
19
|
-
export type { CascadeAction, DatasourceIR, DefaultValueIR, Dialect, EnumIR, EnumStorage, ExtensionDeclIR, FieldIR, FieldType, JsonSchemaRefIR, ValidatorRefIR, IndexFieldIR, IndexKeyTermIR, CheckIR, IndexIR, IndexKind, ModelIR, Provider, RelationIR, RelationType, ScalarType, SchemaIR, } from "./ir.ts";
|
|
23
|
+
export type { CascadeAction, DatasourceIR, DefaultValueIR, Dialect, EnumIR, EnumStorage, ExtensionDeclIR, FieldIR, FieldType, JsonSchemaRefIR, ValidatorRefIR, IndexFieldIR, IndexKeyTermIR, CheckIR, IndexIR, IndexKind, ModelIR, Provider, RelationIR, RelationType, ScalarType, SchemaIR, TableStorageParameters, TableStorageValue, VacuumStorageParameters, } from "./ir.ts";
|
|
20
24
|
export { PREDICATE_COMPARISON_OPS, assertPredicateCapabilities, inspectPredicate, inspectPredicateExpression, isPredicateFieldRef, predicateCapabilityIssue, predicateFieldNames, predicateKey } from "./predicate.ts";
|
|
21
25
|
export type { PredicateBooleanUsage, PredicateCapabilityInput, PredicateCapabilityIssue, PredicateCapabilityTable, PredicateComparisonOp, PredicateExpression, PredicateFieldRef, PredicateInspection, PredicateIR, PredicateNodeKind, PredicateNumericType, PredicateOperand, PredicateResultType, PredicateUsage, PredicateValue } from "./predicate.ts";
|
|
22
26
|
export { CHECK_RULE_GROUP_MAX, checkRulePredicate } from "./check-rules.ts";
|
|
@@ -32,18 +36,25 @@ export { isLocalDateField, isCanonicalLocalDate, localDateCheckName } from "./lo
|
|
|
32
36
|
export { dialectCollation, isMysqlCollationName } from "./collation.ts";
|
|
33
37
|
export { READ_ONLY_REFUSAL_REASONS, ReadOnlyClientError, SCOPED_REFUSAL_REASONS, ScopedQueryError, VIBE_ERROR_CODES, VibeError, internalError, invalidStoredData, unsupportedCapability, } from "./errors.ts";
|
|
34
38
|
export type { ReadOnlyRefusalReason, ScopedRefusalReason, VibeErrorCode } from "./errors.ts";
|
|
39
|
+
export { CONNECTION_FAILURE_REASONS, FAILURE_KINDS, failureKindOf, isConnectionFailureReason } from "./failure-kind.ts";
|
|
40
|
+
export type { ConnectionFailureReason, FailureKind } from "./failure-kind.ts";
|
|
41
|
+
export { didYouMean, editDistance, isUnknownNameRefusal, suggestName, withSuggestion } from "./suggest.ts";
|
|
35
42
|
export { decodePrismaString, encodePrismaString, exactDecimalLiteral, exactIntegerLiteral } from "./prisma-literal.ts";
|
|
36
43
|
export { RESERVED_CLIENT_NAMES, RESERVED_DELEGATE_NAMES, isReservedClientName, isReservedDelegateName, } from "./reserved.ts";
|
|
37
44
|
export { assertExtensionModelPlacement, assertExtensionPlacement, EMPTY_EXTENSION_REGISTRY, buildExtensionRegistry, defineExtension, extensionDeclarations, extensionManifestEntry, extensionOptionsHash, mergeExtensionDeclarations, } from "./extension.ts";
|
|
38
45
|
export type { ExtensionArtifact, ExtensionArtifactOwner, ExtensionAttributeArgs, ExtensionAttributeValue, ExtensionClientContribution, ExtensionClientPlane, ExtensionDoctorCheck, ExtensionDoctorHook, ExtensionDoctorReport, ExtensionFieldType, ExtensionImportSpec, ExtensionManifestEntry, ExtensionMigratePlane, ExtensionModelAttribute, ExtensionModelTypeNames, ExtensionRegistry, ExtensionRuntimePlane, ExtensionSchemaContext, ExtensionSqlExecutor, ExtensionSqlPlane, ExtensionWhereOperator, SqlFragmentPart, SqlFragmentSpec, VibeExtension, } from "./extension.ts";
|
|
39
46
|
export { buildComputedManifest, validateComputedConfig } from "./computed.ts";
|
|
40
47
|
export type { ComputedConfig, ComputedFieldSpec, ComputedManifestEntry } from "./computed.ts";
|
|
41
|
-
export { RESERVED_ENUM_NAMES, assertValidSchemaIR, validateSchemaIR } from "./validate.ts";
|
|
42
|
-
export type { ValidationIssue } from "./validate.ts";
|
|
48
|
+
export { RESERVED_ENUM_NAMES, assertValidSchemaIR, generatedTypeNames, validateSchemaIR } from "./validate.ts";
|
|
49
|
+
export type { DisambiguatedTypeSuffix, GeneratedTypeNames, ValidationIssue } from "./validate.ts";
|
|
50
|
+
export { sealSchemaIR } from "./sealed.ts";
|
|
43
51
|
export { implicitJoinTable } from "./m2m.ts";
|
|
44
52
|
export type { ImplicitJoinTable } from "./m2m.ts";
|
|
45
53
|
export { IDENTIFIER_LIMITS, assertIdentifierFits, defaultForeignKeyName, defaultIndexName, defaultExpressionIndexName, defaultPrimaryKeyName, fitDefaultName, identifierLength, implicitJoinTableObjectNames, postgresGeneratedObjectName, } from "./physical-names.ts";
|
|
46
54
|
export type { IdentifierLimit, ImplicitJoinTableObjectNames } from "./physical-names.ts";
|
|
55
|
+
export { modelUniqueKeys } from "./unique-keys.ts";
|
|
56
|
+
export { normalizeWhere } from "./partial-predicate.ts";
|
|
57
|
+
export type { UniqueKeyIR } from "./unique-keys.ts";
|
|
47
58
|
export type { NativeRlsIR, RlsContextFieldIR, RlsContextIR, RlsContextRefIR, RlsContextScalar, RlsPolicyIR } from "./ir.ts";
|
|
48
59
|
export { DIALECT_CAPABILITIES, MYSQL_CAPABILITIES, POSTGRES_CAPABILITIES, SQLITE_CAPABILITIES } from "./capabilities.ts";
|
|
49
60
|
export { RLS_CONTEXT_REASONS, RlsContextError } from "./errors.ts";
|