@vibeorm/schema 5.9.0 → 5.11.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 +33 -0
- package/dist/errors.d.ts +11 -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.d.ts +8 -0
- package/dist/index.js +523 -7
- package/dist/index.js.map +17 -11
- 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/unique-keys.d.ts +48 -0
- package/dist/validate.d.ts +4 -1
- package/package.json +1 -1
package/dist/capabilities.d.ts
CHANGED
|
@@ -189,6 +189,39 @@ export type DialectCapabilities = {
|
|
|
189
189
|
* can) and then writes it, inside the call's transaction.
|
|
190
190
|
*/
|
|
191
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;
|
|
203
|
+
/**
|
|
204
|
+
* Carrier rows: under the `"join"` relation strategy, the lists, counts and
|
|
205
|
+
* aggregates below a to-one that several rows of one statement share are
|
|
206
|
+
* built and sent once per distinct target. The first row of each target
|
|
207
|
+
* carries them (window ordinals over the statement's rows) in a lateral
|
|
208
|
+
* gated on "this row is the carrier", and the dialect's planner must not
|
|
209
|
+
* run that lateral for the other rows (PostgreSQL: a One-Time Filter).
|
|
210
|
+
* Without it such a level nests on a level of few rows and loads by key
|
|
211
|
+
* after the statement otherwise.
|
|
212
|
+
*/
|
|
213
|
+
readonly carrierRows: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* A dictionary of shared lists: under the `"join"` relation strategy, the
|
|
216
|
+
* lists, counts and aggregates below a to-one that sits under a list level
|
|
217
|
+
* are built and sent once per distinct target of the whole statement. The
|
|
218
|
+
* statement keeps its rows in a common table expression, reads the targets'
|
|
219
|
+
* keys back out of the JSON it built for them, builds one entry per
|
|
220
|
+
* distinct key and returns the entries on its first row. Without it such a
|
|
221
|
+
* level nests on a level of few rows and loads by key after the statement
|
|
222
|
+
* otherwise.
|
|
223
|
+
*/
|
|
224
|
+
readonly sharedListDictionary: boolean;
|
|
192
225
|
};
|
|
193
226
|
export declare const POSTGRES_CAPABILITIES: DialectCapabilities;
|
|
194
227
|
export declare const SQLITE_CAPABILITIES: DialectCapabilities;
|
package/dist/errors.d.ts
CHANGED
|
@@ -30,6 +30,17 @@ export declare const VIBE_ERROR_CODES: readonly [
|
|
|
30
30
|
"VIBE_SCHEMA_INVALID",
|
|
31
31
|
/** Feature requested on a dialect that does not support it. */
|
|
32
32
|
"VIBE_UNSUPPORTED_CAPABILITY",
|
|
33
|
+
/**
|
|
34
|
+
* One value of a statement's result passed the size limit the server sets
|
|
35
|
+
* for a single value, so the server could not send the result.
|
|
36
|
+
* `meta.limit` names the limit: `"max_allowed_packet"` on MySQL (a server
|
|
37
|
+
* setting, 64 MB by default) or `"MaxAllocSize"` on PostgreSQL (1 GB,
|
|
38
|
+
* fixed). `meta.relation` names the relation whose payload it was, where
|
|
39
|
+
* the runtime knows it. The `"join"` relation strategy sends the lists of a
|
|
40
|
+
* relation level as one JSON value; the `"query"` strategy reads them as
|
|
41
|
+
* rows and has no such limit.
|
|
42
|
+
*/
|
|
43
|
+
"VIBE_RESULT_TOO_LARGE",
|
|
33
44
|
/** Generated client is stale relative to config/schema — re-run generate. */
|
|
34
45
|
"VIBE_STALE_CLIENT",
|
|
35
46
|
/** Configuration problem (vibeorm.config.ts, flags, env). */
|
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
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { assertGeneratedColumn, assertGeneratedColumns, generatedColumnFromSql,
|
|
|
18
18
|
export type { DatabaseModuleOptions, DatabaseModuleManifest, DatabaseModuleArtifact } from "./database-module.ts";
|
|
19
19
|
export { prepareDatabaseModuleSchema } from "./module-schema.ts";
|
|
20
20
|
export type { ExclusionIR, ExclusionSpec, ExclusionKey, ExclusionEndpoint } from "./exclusion.ts";
|
|
21
|
+
export { exclusionFields } from "./exclusion.ts";
|
|
21
22
|
export { DIALECTS, ENUM_STORAGES, enumStorageOf, fieldTypeIdentity, isEnumType, providerToDialect } from "./ir.ts";
|
|
22
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";
|
|
23
24
|
export { PREDICATE_COMPARISON_OPS, assertPredicateCapabilities, inspectPredicate, inspectPredicateExpression, isPredicateFieldRef, predicateCapabilityIssue, predicateFieldNames, predicateKey } from "./predicate.ts";
|
|
@@ -35,6 +36,9 @@ export { isLocalDateField, isCanonicalLocalDate, localDateCheckName } from "./lo
|
|
|
35
36
|
export { dialectCollation, isMysqlCollationName } from "./collation.ts";
|
|
36
37
|
export { READ_ONLY_REFUSAL_REASONS, ReadOnlyClientError, SCOPED_REFUSAL_REASONS, ScopedQueryError, VIBE_ERROR_CODES, VibeError, internalError, invalidStoredData, unsupportedCapability, } from "./errors.ts";
|
|
37
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";
|
|
38
42
|
export { decodePrismaString, encodePrismaString, exactDecimalLiteral, exactIntegerLiteral } from "./prisma-literal.ts";
|
|
39
43
|
export { RESERVED_CLIENT_NAMES, RESERVED_DELEGATE_NAMES, isReservedClientName, isReservedDelegateName, } from "./reserved.ts";
|
|
40
44
|
export { assertExtensionModelPlacement, assertExtensionPlacement, EMPTY_EXTENSION_REGISTRY, buildExtensionRegistry, defineExtension, extensionDeclarations, extensionManifestEntry, extensionOptionsHash, mergeExtensionDeclarations, } from "./extension.ts";
|
|
@@ -43,10 +47,14 @@ export { buildComputedManifest, validateComputedConfig } from "./computed.ts";
|
|
|
43
47
|
export type { ComputedConfig, ComputedFieldSpec, ComputedManifestEntry } from "./computed.ts";
|
|
44
48
|
export { RESERVED_ENUM_NAMES, assertValidSchemaIR, generatedTypeNames, validateSchemaIR } from "./validate.ts";
|
|
45
49
|
export type { DisambiguatedTypeSuffix, GeneratedTypeNames, ValidationIssue } from "./validate.ts";
|
|
50
|
+
export { sealSchemaIR } from "./sealed.ts";
|
|
46
51
|
export { implicitJoinTable } from "./m2m.ts";
|
|
47
52
|
export type { ImplicitJoinTable } from "./m2m.ts";
|
|
48
53
|
export { IDENTIFIER_LIMITS, assertIdentifierFits, defaultForeignKeyName, defaultIndexName, defaultExpressionIndexName, defaultPrimaryKeyName, fitDefaultName, identifierLength, implicitJoinTableObjectNames, postgresGeneratedObjectName, } from "./physical-names.ts";
|
|
49
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";
|
|
50
58
|
export type { NativeRlsIR, RlsContextFieldIR, RlsContextIR, RlsContextRefIR, RlsContextScalar, RlsPolicyIR } from "./ir.ts";
|
|
51
59
|
export { DIALECT_CAPABILITIES, MYSQL_CAPABILITIES, POSTGRES_CAPABILITIES, SQLITE_CAPABILITIES } from "./capabilities.ts";
|
|
52
60
|
export { RLS_CONTEXT_REASONS, RlsContextError } from "./errors.ts";
|