@vibeorm/sql 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.
Files changed (47) hide show
  1. package/dist/ast.d.ts +337 -4
  2. package/dist/codecs.d.ts +106 -12
  3. package/dist/composable.d.ts +44 -4
  4. package/dist/dialect.d.ts +73 -1
  5. package/dist/dialects/migration-inventory.d.ts +0 -11
  6. package/dist/dialects/mysql-generated-columns.d.ts +1 -5
  7. package/dist/dialects/mysql-index-expressions.d.ts +1 -19
  8. package/dist/dialects/mysql-json-keys.d.ts +26 -0
  9. package/dist/dialects/mysql-row-rules.d.ts +1 -7
  10. package/dist/dialects/postgres-generated-columns.d.ts +0 -5
  11. package/dist/dialects/postgres-index-expressions.d.ts +1 -11
  12. package/dist/dialects/postgres-rls-readiness.d.ts +0 -2
  13. package/dist/dialects/postgres-rls.d.ts +7 -1
  14. package/dist/dialects/postgres-row-rules.d.ts +1 -24
  15. package/dist/dialects/sqlite-fts.d.ts +2 -2
  16. package/dist/dialects/sqlite-generated-columns.d.ts +1 -12
  17. package/dist/dialects/sqlite-index-expressions.d.ts +1 -24
  18. package/dist/dialects/sqlite-json-equality.d.ts +1 -14
  19. package/dist/dialects/sqlite-row-rules.d.ts +1 -7
  20. package/dist/dialects/sqlite-table-definition.d.ts +0 -19
  21. package/dist/dialects/test-databases.d.ts +96 -0
  22. package/dist/expr-fragment.d.ts +13 -0
  23. package/dist/identifiers.d.ts +1 -4
  24. package/dist/index.d.ts +11 -6
  25. package/dist/index.js +3023 -2064
  26. package/dist/index.js.map +47 -43
  27. package/dist/json-patch.d.ts +0 -14
  28. package/dist/json-path.d.ts +1 -2
  29. package/dist/key-list.d.ts +38 -21
  30. package/dist/native-types.d.ts +3 -1
  31. package/dist/params.d.ts +0 -2
  32. package/dist/query/expressions.d.ts +1 -33
  33. package/dist/query/index.js.map +7 -7
  34. package/dist/query/mutations.d.ts +1 -14
  35. package/dist/query/reusable.d.ts +1 -16
  36. package/dist/query/select.d.ts +1 -10
  37. package/dist/query/sources.d.ts +1 -36
  38. package/dist/query/state.d.ts +1 -77
  39. package/dist/query-plan.d.ts +2 -2
  40. package/dist/result-decoder.d.ts +21 -1
  41. package/dist/row-rules.d.ts +1 -19
  42. package/dist/sql-bindings.d.ts +7 -43
  43. package/dist/sql-handles.d.ts +1 -3
  44. package/dist/sql-input.d.ts +8 -24
  45. package/dist/timestamp-identity.d.ts +6 -12
  46. package/dist/timestamp-text.d.ts +36 -0
  47. package/package.json +2 -2
@@ -19,8 +19,6 @@
19
19
  * purpose with a marker the client maps back to a typed error:
20
20
  * `__vibe_veto:json_patch:<nonce>:<check index>:<found type>`.
21
21
  */
22
- import type { SqlDialect } from "./dialect.ts";
23
- import type { ParamCollector } from "./params.ts";
24
22
  /** One step of a JSON patch; `value` is the JSON text the Json codec wrote. */
25
23
  export type JsonPatchStep = {
26
24
  readonly set: readonly string[];
@@ -71,18 +69,6 @@ export type JsonPatchPlan = {
71
69
  export declare function planJsonPatch(params: {
72
70
  steps: readonly JsonPatchStep[];
73
71
  }): JsonPatchPlan;
74
- /**
75
- * The patched value of one Json column — `CASE WHEN <a container is not an
76
- * object> THEN <fail on purpose> … ELSE <patched document> END` — where `read`
77
- * is the column as the assignment reads it (qualified in a conflict update).
78
- * Every placeholder is collected in text order.
79
- */
80
- export declare function renderJsonPatch(params: {
81
- dialect: SqlDialect;
82
- patch: JsonPatchOperation;
83
- read: string;
84
- collector: ParamCollector;
85
- }): string;
86
72
  /** A refusal marker found in a database error message: the nonce, the check index, and the container's type as the database spelled it. */
87
73
  export type JsonPatchVeto = {
88
74
  readonly nonce: string;
@@ -1,3 +1,2 @@
1
- /** `$.a.b[0]` path string for sqlite/mysql — always bound, never spliced. */
2
- export declare function jsonPathString(path: readonly (string | number)[]): string;
1
+ export {};
3
2
  //# sourceMappingURL=json-path.d.ts.map
@@ -26,17 +26,6 @@ export declare function postgresKeyListElementTypeOf(params: {
26
26
  dialect: SqlDialect;
27
27
  member: KeyListMember;
28
28
  }): string | undefined;
29
- /**
30
- * The postgres element type a key-list member's array binds as
31
- * (`$n::<type>[]`), derived from the column's declared type facts.
32
- *
33
- * @throws VibeError `VIBE_UNSUPPORTED_CAPABILITY` for a member whose type has
34
- * no equality a key can use (Json) or a native type this list does not know.
35
- */
36
- export declare function postgresKeyListElementType(params: {
37
- dialect: SqlDialect;
38
- member: KeyListMember;
39
- }): string;
40
29
  /**
41
30
  * Whether a key list must bind its rows as a row-value list of UNTYPED
42
31
  * parameters, `(a, b) IN (($1, $2), …)`, instead of typed arrays on the
@@ -53,6 +42,44 @@ export declare function postgresKeyListElementType(params: {
53
42
  export declare function keyListBindsUntypedRows(params: {
54
43
  members: readonly KeyListMember[];
55
44
  }): boolean;
45
+ /** How MySQL types a key it reads back from JSON text; see {@link mysqlJsonKeyTypeOf}. */
46
+ export type MysqlJsonKeyType = "text" | "signed" | "unsigned";
47
+ /**
48
+ * How MySQL turns the text of a key column, read back out of JSON, into a
49
+ * value its foreign-key column compares with through its index, or
50
+ * `undefined` for a key type nobody measured. `"text"`: the unquoted JSON
51
+ * string, compared under the column's collation like a bound literal.
52
+ * `"signed"` / `"unsigned"`: `CAST(… AS SIGNED | UNSIGNED)`, exact over the
53
+ * whole 64-bit range (text against a BIGINT column compares as a double).
54
+ * Dates, decimals, floats, booleans, bytes and enums are not admitted.
55
+ */
56
+ export declare function mysqlJsonKeyTypeOf(params: {
57
+ member: KeyListMember;
58
+ }): MysqlJsonKeyType | undefined;
59
+ /**
60
+ * Does the token of a key read back from JSON (the key's text, written on the
61
+ * to-one's own row) need a text cast? A key the JSON carries as a number must
62
+ * travel as text, or a 64-bit integer would reach the client rounded; a MySQL
63
+ * string key is text already, and `CAST(… AS CHAR)` would convert it to the
64
+ * CONNECTION's character set, where a `utf8mb3` connection turns every
65
+ * character outside the BMP into `?` and two keys into one.
66
+ */
67
+ export declare function jsonKeyTokenCast(params: {
68
+ dialect: SqlDialect;
69
+ member: KeyListMember;
70
+ }): boolean;
71
+ /**
72
+ * Can `dialect` type every one of `members` from its JSON text, as
73
+ * `SelectStatement.fromJsonKeys` must? PostgreSQL casts the text to the
74
+ * key-list's base type (not a `DateTime` without a declared native type,
75
+ * whose column may be a zone-less `timestamp`); MySQL admits the types of
76
+ * {@link mysqlJsonKeyTypeOf}. The renderer throws for a member this refuses,
77
+ * so the runtime asks here before it builds a dictionary level.
78
+ */
79
+ export declare function jsonKeysTyped(params: {
80
+ dialect: SqlDialect;
81
+ members: readonly KeyListMember[];
82
+ }): boolean;
56
83
  /**
57
84
  * The cast after a bulk-insert column's array placeholder (`$n::<cast>[]`),
58
85
  * or `undefined` when the column has none and the insert must keep VALUES.
@@ -70,14 +97,4 @@ export declare function postgresBulkInsertArrayCastOf(params: {
70
97
  dialect: SqlDialect;
71
98
  member: KeyListMember;
72
99
  }): string | undefined;
73
- /**
74
- * The throwing form of {@link postgresBulkInsertArrayCastOf}, for the renderer.
75
- *
76
- * @throws VibeError `VIBE_UNSUPPORTED_CAPABILITY` for a native type the
77
- * bulk-insert form does not know.
78
- */
79
- export declare function postgresBulkInsertArrayCast(params: {
80
- dialect: SqlDialect;
81
- member: KeyListMember;
82
- }): string;
83
100
  //# sourceMappingURL=key-list.d.ts.map
@@ -40,7 +40,9 @@ export declare const POSTGRES_EXACT_EQUIVALENTS: Readonly<Partial<Record<ScalarT
40
40
  * Normalize a MySQL type string for comparison: lowercase, whitespace
41
41
  * stripped, base de-aliased, integer display widths dropped (MySQL 8.0.19+
42
42
  * omits them; older catalogs report `int(11)`) — EXCEPT `tinyint(1)`, which is
43
- * the Boolean marker and must survive normalization.
43
+ * the Boolean marker and must survive normalization. A zero fractional
44
+ * precision on a temporal type is dropped: the catalog reports
45
+ * `datetime(0)` as `datetime`.
44
46
  */
45
47
  export declare function normalizeMysqlNativeType(params: {
46
48
  readonly raw: string;
package/dist/params.d.ts CHANGED
@@ -4,8 +4,6 @@ export declare class ParamCollector {
4
4
  private reserved;
5
5
  readonly values: unknown[];
6
6
  constructor(dialect: SqlDialect);
7
- /** @internal Allocate recorded positions without inserting sample values. */
8
- reserve(): string;
9
7
  /** Actual positional slots, including repeats of a named input. */
10
8
  count(): number;
11
9
  /** Register one value; ordinary and reusable paths share transport spelling. */
@@ -1,36 +1,4 @@
1
- import type { ResultDecoder, ResultReadDecoder, SqlFragment, SqlInputContract } from "@vibeorm/sql";
2
- import type { ColumnDefinition, Expression, Expressions } from "./types.ts";
3
- import type { RenderContext } from "./state.ts";
4
- export declare function nullableDecoder<T>(decoder: ResultReadDecoder<T>): ResultReadDecoder<T | null>;
5
- export declare function assertDecoder(decoder: ResultReadDecoder<unknown>): void;
6
- /** Keep physical native refinements in the central codec implementations. */
7
- export declare function nativeColumnDefinition(definition: ColumnDefinition<unknown>): ColumnDefinition<unknown>;
8
- /** Transport conversion belongs only at the final result boundary. */
9
- export declare function transportProjection(params: {
10
- context: RenderContext;
11
- expression: string;
12
- definition: ColumnDefinition<unknown>;
13
- }): string;
14
- /** Write contracts carry encoding identity independently from projection output. */
15
- export declare function columnInputContract(definition: ColumnDefinition<unknown>): SqlInputContract;
16
- export declare function bindColumnValue(params: {
17
- context: RenderContext;
18
- definition: ColumnDefinition<unknown>;
19
- value: unknown;
20
- encoder?: ResultDecoder<unknown>;
21
- rejectNull?: boolean;
22
- }): string;
23
- /** Construct a typed value for the public qb.value contract. */
24
- export declare function literal<T>(params: {
25
- value: T;
26
- decoder: ResultDecoder<T>;
27
- }): Expression<T>;
28
- /** Construct an explicit fragment projection for the public qb.raw contract. */
29
- export declare function rawExpression<T>(params: {
30
- sql: SqlFragment;
31
- decoder: ResultReadDecoder<T>;
32
- references?: readonly Expression<unknown>[];
33
- }): Expression<T>;
1
+ import type { Expressions } from "./types.ts";
34
2
  /** Compare typed operands for equality, preserving SQL NULL propagation. */
35
3
  export declare const eq: Expressions["eq"];
36
4
  /** Compare typed operands for inequality. */