@vibeorm/schema 5.8.0 → 5.9.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.
@@ -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,15 @@ 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;
163
192
  };
164
193
  export declare const POSTGRES_CAPABILITIES: DialectCapabilities;
165
194
  export declare const SQLITE_CAPABILITIES: DialectCapabilities;
@@ -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";
@@ -16,7 +19,7 @@ export type { DatabaseModuleOptions, DatabaseModuleManifest, DatabaseModuleArtif
16
19
  export { prepareDatabaseModuleSchema } from "./module-schema.ts";
17
20
  export type { ExclusionIR, ExclusionSpec, ExclusionKey, ExclusionEndpoint } from "./exclusion.ts";
18
21
  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";
22
+ 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
23
  export { PREDICATE_COMPARISON_OPS, assertPredicateCapabilities, inspectPredicate, inspectPredicateExpression, isPredicateFieldRef, predicateCapabilityIssue, predicateFieldNames, predicateKey } from "./predicate.ts";
21
24
  export type { PredicateBooleanUsage, PredicateCapabilityInput, PredicateCapabilityIssue, PredicateCapabilityTable, PredicateComparisonOp, PredicateExpression, PredicateFieldRef, PredicateInspection, PredicateIR, PredicateNodeKind, PredicateNumericType, PredicateOperand, PredicateResultType, PredicateUsage, PredicateValue } from "./predicate.ts";
22
25
  export { CHECK_RULE_GROUP_MAX, checkRulePredicate } from "./check-rules.ts";
@@ -38,8 +41,8 @@ export { assertExtensionModelPlacement, assertExtensionPlacement, EMPTY_EXTENSIO
38
41
  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
42
  export { buildComputedManifest, validateComputedConfig } from "./computed.ts";
40
43
  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";
44
+ export { RESERVED_ENUM_NAMES, assertValidSchemaIR, generatedTypeNames, validateSchemaIR } from "./validate.ts";
45
+ export type { DisambiguatedTypeSuffix, GeneratedTypeNames, ValidationIssue } from "./validate.ts";
43
46
  export { implicitJoinTable } from "./m2m.ts";
44
47
  export type { ImplicitJoinTable } from "./m2m.ts";
45
48
  export { IDENTIFIER_LIMITS, assertIdentifierFits, defaultForeignKeyName, defaultIndexName, defaultExpressionIndexName, defaultPrimaryKeyName, fitDefaultName, identifierLength, implicitJoinTableObjectNames, postgresGeneratedObjectName, } from "./physical-names.ts";